Spaces:
Runtime error
Runtime error
Chris
commited on
Commit
•
2c8cacd
1
Parent(s):
2875be3
Updated comments.
Browse files- app.py +5 -2
- calculate_measures.py +2 -1
- select_body_shape.py +1 -10
app.py
CHANGED
@@ -17,7 +17,7 @@ def generate_output(front_img_path, side_img_path):
|
|
17 |
front_keypoint_result = predict_pose(front_img_path, "front.jpg")
|
18 |
side_keypoint_result = predict_pose(side_img_path, "side.jpg")
|
19 |
|
20 |
-
# Should we create the image separately? Seems weird to get it as a result from this only to use it in something else below.
|
21 |
front_image = front_keypoint_result[0]
|
22 |
side_image = side_keypoint_result[0]
|
23 |
|
@@ -25,7 +25,10 @@ def generate_output(front_img_path, side_img_path):
|
|
25 |
side_keypoint_data = side_keypoint_result[1]
|
26 |
|
27 |
front_seg_mask = calculate_seg_mask(front_img_path)
|
28 |
-
|
|
|
|
|
|
|
29 |
|
30 |
measures_data_frame = calculate_all_measures(front_image, side_image, front_keypoint_data, side_keypoint_data, front_seg_mask, side_rcnn_mask)
|
31 |
|
|
|
17 |
front_keypoint_result = predict_pose(front_img_path, "front.jpg")
|
18 |
side_keypoint_result = predict_pose(side_img_path, "side.jpg")
|
19 |
|
20 |
+
# TODO: LOW PRIORITY: Should we create the image separately? Seems weird to get it as a result from this only to use it in something else below.
|
21 |
front_image = front_keypoint_result[0]
|
22 |
side_image = side_keypoint_result[0]
|
23 |
|
|
|
25 |
side_keypoint_data = side_keypoint_result[1]
|
26 |
|
27 |
front_seg_mask = calculate_seg_mask(front_img_path)
|
28 |
+
# TODO: Is this the correct mask? In the original code there is a function called 'get_rcnn_mask' which is not used anywhere.
|
29 |
+
# The name implies that it should be a rcnn mask, but the code actually requests a seg mask.
|
30 |
+
# If we don't need a rcnn mask, then delete the rcnn code from calculate_masks.py and rename side_rcnn_mask to side_seg_mask.
|
31 |
+
side_rcnn_mask = calculate_seg_mask(side_img_path)
|
32 |
|
33 |
measures_data_frame = calculate_all_measures(front_image, side_image, front_keypoint_data, side_keypoint_data, front_seg_mask, side_rcnn_mask)
|
34 |
|
calculate_measures.py
CHANGED
@@ -131,7 +131,8 @@ def calculate_all_measures(front_image, side_image, front_keypoint_data, side_ke
|
|
131 |
results_dict['upper_torso_to_body_ratio'] = upper_torso_area / full_side_body_area
|
132 |
results_dict['upper_torso_to_body_ratio'] = upper_torso_area / full_side_body_area
|
133 |
|
134 |
-
# TODO:
|
|
|
135 |
results_dict['id'] = "1"
|
136 |
|
137 |
results.append(results_dict)
|
|
|
131 |
results_dict['upper_torso_to_body_ratio'] = upper_torso_area / full_side_body_area
|
132 |
results_dict['upper_torso_to_body_ratio'] = upper_torso_area / full_side_body_area
|
133 |
|
134 |
+
# TODO: LOW PRIORITY: Not sure if we need this, but it was in the original code and select_body_shape uses it and requires an ID in a lot of places.
|
135 |
+
# Could potentially remove it but will need to update select_body_shape too.
|
136 |
results_dict['id'] = "1"
|
137 |
|
138 |
results.append(results_dict)
|
select_body_shape.py
CHANGED
@@ -1,12 +1,10 @@
|
|
1 |
import re
|
2 |
-
import numpy as np
|
3 |
import pandas as pd
|
4 |
from numpy import dot
|
5 |
from numpy.linalg import norm
|
6 |
from body_shape_lookup import body_shape_lookup
|
7 |
|
8 |
BODY_SHAPE_MEASURES = "body_shape_measures_normalised_updated.csv"
|
9 |
-
VOLUNTEERS_MEASURES = "volunteers_measures_normalised_updated.csv"
|
10 |
|
11 |
# selecting specific features
|
12 |
RATIOS_TO_USE = ['shoulder_to_hip_distance',
|
@@ -34,20 +32,13 @@ def is_match(row):
|
|
34 |
def select_body_shape(normalised_body_shape_measures):
|
35 |
# load the body shape measures
|
36 |
body_shape_df = pd.read_csv(BODY_SHAPE_MEASURES)
|
37 |
-
# body_shape_df = normalised_body_shape_measures
|
38 |
|
39 |
-
# load the
|
40 |
-
# volunteers_df = pd.read_csv(VOLUNTEERS_MEASURES)
|
41 |
volunteers_df = normalised_body_shape_measures
|
42 |
|
43 |
# select only the columns corresponding to the ratios
|
44 |
body_shape_ratios = body_shape_df[RATIOS_TO_USE]
|
45 |
|
46 |
-
# Create a DataFrame to store the results
|
47 |
-
results_df = pd.DataFrame(columns=["Volunteer_ID", "Rank_1_Body_Shape", "Score_1",
|
48 |
-
"Rank_2_Body_Shape", "Score_2",
|
49 |
-
"Rank_3_Body_Shape", "Score_3"])
|
50 |
-
|
51 |
# calculate euclidean distance for each volunteer
|
52 |
for index, volunteer_row in volunteers_df.iterrows():
|
53 |
print(f"\nProcessing volunteer {volunteer_row['id']}")
|
|
|
1 |
import re
|
|
|
2 |
import pandas as pd
|
3 |
from numpy import dot
|
4 |
from numpy.linalg import norm
|
5 |
from body_shape_lookup import body_shape_lookup
|
6 |
|
7 |
BODY_SHAPE_MEASURES = "body_shape_measures_normalised_updated.csv"
|
|
|
8 |
|
9 |
# selecting specific features
|
10 |
RATIOS_TO_USE = ['shoulder_to_hip_distance',
|
|
|
32 |
def select_body_shape(normalised_body_shape_measures):
|
33 |
# load the body shape measures
|
34 |
body_shape_df = pd.read_csv(BODY_SHAPE_MEASURES)
|
|
|
35 |
|
36 |
+
# load the calculated measures.
|
|
|
37 |
volunteers_df = normalised_body_shape_measures
|
38 |
|
39 |
# select only the columns corresponding to the ratios
|
40 |
body_shape_ratios = body_shape_df[RATIOS_TO_USE]
|
41 |
|
|
|
|
|
|
|
|
|
|
|
42 |
# calculate euclidean distance for each volunteer
|
43 |
for index, volunteer_row in volunteers_df.iterrows():
|
44 |
print(f"\nProcessing volunteer {volunteer_row['id']}")
|