Skip to content

skeleton-based HAR demo bug fixed #260

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 5 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -529,10 +529,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