Trên Linux với NVIDIA GPU, để model có tốc độ chạy nhanh nhất,
cần cài đặt cuda-toolkit và cudnn.
Đối với Linux Mint 21.3 (hoặc Ubuntu 22.04), NVIDIA GPU (CUDA 12):
-
Trước tiên làm theo hướng dẫn tại đây để cài
cudnn. -
Chạy lệnh sau để cài
cuda-toolkit:sudo apt install cuda-toolkit
Chạy lệnh sau để cài đặt tất cả các thư viện cần thiết:
pip install .Quy ước $PROJECT_ROOT/ là thư mục gốc của dự án.
-
Cách 1:
- Tạo thư mục
$PROJECT_ROOT/model_weight - Truy cập link sau: https://www.kaggle.com/datasets/nvnhat04/ser-model
- Tải về toàn bộ các file vào thư mục
$PROJECT_ROOT/model_weightvừa tạo. (Có thể tải file zip sau đó giải nén vào thư mục vừa tạo.)
- Tạo thư mục
-
Cách 2: Sử dụng Kaggle CLI:
cd $PROJECT_ROOT kaggle datasets download nvnhat04/ser-model --unzip -p ./model_weight
Chạy lệnh sau để thực thi mô hình:
python main.pypip install git+https://github.com/telcenter/ser.git@mainStill needs to download the weights as shown above.
Example usage:
from ser import SERModel
def main():
model = SERModel(
# Where did you download the weights to? Then specify the
# paths accordingly.
model_path='./model_weight/CNN_model.json',
weights_path='./model_weight/best_model1_weights.h5'
)
audio_path = './test_data/surprise.wav'
emotion = model.predict_emotion_from_wav_file(audio_path)
print(f"Predicted emotion: {emotion}")
if __name__ == "__main__":
main()