Skip to content

Merge masterinto develop #261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jun 9, 2022
Merged
9 changes: 5 additions & 4 deletions .github/workflows/tests_suite_develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ jobs:
- perception/object_tracking_2d
- perception/object_detection_3d
- perception/pose_estimation
- perception/fall_detection
- perception/speech_recognition
- perception/skeleton_based_action_recognition
- perception/semantic_segmentation
Expand Down Expand Up @@ -150,9 +151,6 @@ jobs:
with:
submodules: true
ref: develop
- name: Build image
run: |
docker build --tag opendr/opendr-toolkit:cpu_test --file Dockerfile .
- name: Get branch name
id: branch-name
uses: tj-actions/[email protected]
Expand Down Expand Up @@ -182,6 +180,7 @@ jobs:
- perception/multimodal_human_centric
- perception/object_tracking_2d
- perception/pose_estimation
- perception/fall_detection
- perception/speech_recognition
- perception/skeleton_based_action_recognition
- perception/semantic_segmentation
Expand Down Expand Up @@ -253,6 +252,7 @@ jobs:
- perception/multimodal_human_centric
- perception/object_tracking_2d
- perception/pose_estimation
- perception/fall_detection
- perception/speech_recognition
- perception/skeleton_based_action_recognition
- perception/semantic_segmentation
Expand Down Expand Up @@ -330,6 +330,7 @@ jobs:
- perception/multimodal_human_centric
- perception/object_tracking_2d
- perception/pose_estimation
- perception/fall_detection
- perception/speech_recognition
- perception/skeleton_based_action_recognition
- perception/semantic_segmentation
Expand Down Expand Up @@ -372,7 +373,7 @@ jobs:
with:
name: docker-artifact
delete-wheel-artifacts:
needs: [build-wheel, test-wheel]
needs: [build-wheel, test-wheel, test-wheel-separate]
if: ${{ always() }}
strategy:
matrix:
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile-cuda
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ ARG branch
ENV APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1
RUN apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu$(cat /etc/os-release | grep VERSION_ID | awk '{print substr($0,13,5)}' | awk -F'.' '{print $1$2}')/x86_64/3bf863cc.pub

ARG branch

# Install dependencies
RUN apt-get update && \
apt-get --yes install git sudo apt-utils
Expand Down
1 change: 1 addition & 0 deletions docs/reference/face-recognition.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ recognizer.save('./temp/saved_models')
* **Inference example - backbone_only mode**
```python
from opendr.perception.face_recognition import FaceRecognitionLearner
from opendr.engine.data import Image
recognizer = FaceRecognitionLearner(backbone='ir_50', mode='backbone_only', device='cuda')
recognizer.load('./temp/saved_models')
recognizer.fit_reference(path='./data/imgs', save_path='./temp/demo')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,11 @@ def draw_preds(frame, preds: Dict):
if counter > 0:
skeleton_seq = pose2numpy(args, counter, poses_list)

prediction = action_classifier.infer(skeleton_seq)
category_labels = preds2label(prediction.confidence)
print(category_labels)
draw_preds(img, category_labels)
prediction = action_classifier.infer(skeleton_seq)
category_labels = preds2label(prediction.confidence)
print(category_labels)
draw_preds(img, category_labels)

# Calculate a running average on FPS
end_time = time.perf_counter()
fps = 1.0 / (end_time - start_time)
Expand Down
24 changes: 12 additions & 12 deletions src/c_api/face_recognition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,20 +289,20 @@ void build_database_face_recognition(const char *database_folder, const char *ou
// Write number of persons
int n = person_names.size();

fout.write((char *)(&n), sizeof(int));
fout.write(static_cast<char *>(&n), sizeof(int));
for (int i = 0; i < n; i++) {
// Write the name of the person (along with its size)
int name_length = person_names[i].size() + 1;
fout.write((char *)(&name_length), sizeof(int));
fout.write(static_cast<char *>(&name_length), sizeof(int));
fout.write(person_names[i].c_str(), name_length);
}

cv::Size s = database_out.size();

fout.write((char *)(&s.height), sizeof(int));
fout.write((char *)(&s.width), sizeof(int));
fout.write((char *)database_out.data, sizeof(float) * s.height * s.width);
fout.write((char *)(&database_ids[0]), sizeof(int) * s.height);
fout.write(static_cast<char *>(&s.height), sizeof(int));
fout.write(static_cast<char *>(&s.width), sizeof(int));
fout.write(static_cast<char *>(database_out.data), sizeof(float) * s.height * s.width);
fout.write(static_cast<char *>(&database_ids[0]), sizeof(int) * s.height);
fout.flush();
fout.close();
}
Expand All @@ -318,14 +318,14 @@ void load_database_face_recognition(const char *database_path, face_recognition_
return;
}
int n;
fin.read((char *)(&n), sizeof(int));
fin.read(static_cast<char *>(&n), sizeof(int));
char **person_names = new char *[n];

for (int i = 0; i < n; i++) {
person_names[i] = new char[512];
// Read person name
int name_length;
fin.read((char *)(&name_length), sizeof(int));
fin.read(static_cast<char *>(&name_length), sizeof(int));
if (name_length > 512) {
std::cerr << "Person name exceeds max number of characters (512)" << std::endl;
return;
Expand All @@ -334,13 +334,13 @@ void load_database_face_recognition(const char *database_path, face_recognition_
}

int height, width;
fin.read((char *)(&height), sizeof(int));
fin.read((char *)(&width), sizeof(int));
fin.read(static_cast<char *>(&height), sizeof(int));
fin.read(static_cast<char *>(&width), sizeof(int));

float *database_buff = new float[height * width];
int *features_ids = new int[height];
fin.read((char *)(database_buff), sizeof(float) * height * width);
fin.read((char *)(features_ids), sizeof(int) * height);
fin.read(static_cast<char *>(database_buff), sizeof(float) * height * width);
fin.read(static_cast<char *>(features_ids), sizeof(int) * height);

fin.close();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,10 +566,9 @@ def infer(self, skeletonseq_batch):

m = nn.Softmax(dim=0)
softmax_predictions = m(output.data[0])
class_confidence = float(torch.max(softmax_predictions))
class_ind = int(torch.argmax(softmax_predictions))
class_description = self.classes_dict[class_ind]
category = Category(prediction=class_ind, confidence=class_confidence, description=class_description)
category = Category(prediction=class_ind, confidence=softmax_predictions, description=class_description)

return category

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,9 @@ def infer(self, SkeletonSeq_batch):

m = nn.Softmax(dim=0)
softmax_predictions = m(output.data[0])
class_confidence = float(torch.max(softmax_predictions))
class_ind = int(torch.argmax(softmax_predictions))
class_description = self.classes_dict[class_ind]
category = Category(prediction=class_ind, confidence=class_confidence, description=class_description)
category = Category(prediction=class_ind, confidence=softmax_predictions, description=class_description)

return category

Expand Down