Skip to content

Commit

Permalink
Preparing to use cloud, upgrade device agnostic code
Browse files Browse the repository at this point in the history
  • Loading branch information
raik199x committed Mar 20, 2024
1 parent dad8967 commit f2bc5ad
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
.mypy_cache/
__pycache__/

dataset/
emotion_recognition_data/
test_result/
git_file_ignore*

Expand Down
4 changes: 2 additions & 2 deletions DeepLearning/model.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import torch
import os
from pathlib import Path
from DeepLearning.settings import learning_rate
from DeepLearning.settings import learning_rate, pytorch_device


class EmotionClassificationModel(torch.nn.Module):
Expand Down Expand Up @@ -70,7 +70,7 @@ def BackupModel(self, folder_path: str, file_name: str) -> None:
torch.save(self.state_dict(), os.path.join(folder_path, file_name))

def LoadModel(self, path_to_model: str) -> None:
self.load_state_dict(torch.load(path_to_model))
self.load_state_dict(torch.load(path_to_model, map_location=torch.device(pytorch_device)))
self.eval()
self.optimizer = self.CreateOptimizer() # optimizer must be recreated after load

Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,20 @@ if ~~crossed~~ means left undone
- [x] Camera capture
- [ ] Create chat tab
- [x] Real time camera
- [ ] Create cloud storage sync tab
- [ ] Poe.api (chatting with bots)
- [x] ~~Camera module (using cv2)~~
(reason: currently camera function are not shared between modules, so they are written directly in gui module)
- [x] Base of pre-trained ML models module
- [x] Downloaded face detection and landmark detection models
- [ ] Web server learning module (?)
- [ ] Backup dataset and pre-trained modules on mega.nz
- [x] Dlib, set up for using cuda

## Requirements

### Cuda

This project uses cuda 11.8. You should install it on your own, but you might want to visit [cuda 11.8 toolkit download page](https://developer.nvidia.com/cuda-11-8-0-download-archive) and [cudann archive page](https://developer.nvidia.com/rdp/cudnn-archive).
This project uses cuda 11.8 (but you can try using newer version). You should install it on your own, but you might want to visit [cuda 11.8 toolkit download page](https://developer.nvidia.com/cuda-11-8-0-download-archive) and [cudann archive page](https://developer.nvidia.com/rdp/cudnn-archive).

If your os is ubuntu, you can use [this guide](https://medium.com/@gokul.a.krishnan/how-to-install-cuda-cudnn-and-tensorflow-on-ubuntu-22-04-2023-20fdfdb96907) to install cuda + cudann.

Expand Down Expand Up @@ -90,9 +91,15 @@ Invalid handle. Cannot load symbol cublasLtCreate

If you also encounter this error, you need to install [libcublasLt.so.12](https://packages.debian.org/trixie/amd64/libcublaslt12/download).

### opencv
### Required python packages

```pip3 install cv2```
Just run the following command:

```pip3
pip3 install -r requirements.txt
```

***IMPORTANT:*** ```requirements.txt``` does not include **dlib** and **pytorch** package

### Dataset

Expand Down
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
numpy
cv2
pyqtgraph
PySide6
megapy
11 changes: 6 additions & 5 deletions shared.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from sys import argv
from os import path

data_folder = "data/"
dataset_folder = "dataset/"
pretrained_face_landmarks_predictor_model = data_folder + "shape_predictor_68_face_landmarks.dat"
pretrained_face_detector = data_folder + "mmod_human_face_detector.dat"
pretrained_emotion_recognition_model = data_folder + "emotion_recognition_model.pt"

data_folder_path = "emotion_recognition_data/"
dataset_folder_path = data_folder_path + "dataset/"
pretrained_face_landmarks_predictor_model = data_folder_path + "shape_predictor_68_face_landmarks.dat"
pretrained_face_detector = data_folder_path + "mmod_human_face_detector.dat"
pretrained_emotion_recognition_model = data_folder_path + "emotion_recognition_model.pt"


def GetRelativePath(var):
Expand Down
1 change: 0 additions & 1 deletion tests/dataset

This file was deleted.

0 comments on commit f2bc5ad

Please sign in to comment.