SalehAhmad commited on
Commit
318f7bc
1 Parent(s): c75761c
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. appbasic.py +32 -0
  2. calculations.py +45 -0
  3. input/person1.png +0 -0
  4. input1/.DS_Store +0 -0
  5. input1/Body_Measurements_Dataset.pdf +0 -0
  6. input1/body.csv +22 -0
  7. input1/files/.DS_Store +0 -0
  8. input1/files/0/front_img.jpg +0 -0
  9. input1/files/0/measurements.json +20 -0
  10. input1/files/0/selfie_img.jpg +0 -0
  11. input1/files/0/side_img.jpg +0 -0
  12. input1/files/1/front_img.jpg +0 -0
  13. input1/files/1/measurements.json +20 -0
  14. input1/files/1/selfie_img.jpg +0 -0
  15. input1/files/1/side_img.jpg +0 -0
  16. input1/files/10/front_img.jpg +0 -0
  17. input1/files/10/measurements.json +20 -0
  18. input1/files/10/selfie_img.jpg +0 -0
  19. input1/files/10/side_img.jpg +0 -0
  20. input1/files/11/front_img.jpg +0 -0
  21. input1/files/11/measurements.json +20 -0
  22. input1/files/11/selfie_img.jpg +0 -0
  23. input1/files/11/side_img.jpg +0 -0
  24. input1/files/12/front_img.jpg +0 -0
  25. input1/files/12/measurements.json +20 -0
  26. input1/files/12/selfie_img.jpg +0 -0
  27. input1/files/12/side_img.jpg +0 -0
  28. input1/files/13/front_img.jpg +0 -0
  29. input1/files/13/measurements.json +20 -0
  30. input1/files/13/selfie_img.jpg +0 -0
  31. input1/files/13/side_img.jpg +0 -0
  32. input1/files/14/front_img.jpg +0 -0
  33. input1/files/14/measurements.json +20 -0
  34. input1/files/14/selfie_img.jpg +0 -0
  35. input1/files/14/side_img.jpg +0 -0
  36. input1/files/15/front_img.jpg +0 -0
  37. input1/files/15/measurements.json +20 -0
  38. input1/files/15/selfie_img.jpg +0 -0
  39. input1/files/15/side_img.jpg +0 -0
  40. input1/files/16/front_img.jpg +0 -0
  41. input1/files/16/measurements.json +20 -0
  42. input1/files/16/selfie_img.jpg +0 -0
  43. input1/files/16/side_img.jpg +0 -0
  44. input1/files/17/front_img.jpg +0 -0
  45. input1/files/17/measurements.json +20 -0
  46. input1/files/17/selfie_img.jpg +0 -0
  47. input1/files/17/side_img.jpg +0 -0
  48. input1/files/18/front_img.jpg +0 -0
  49. input1/files/18/measurements.json +20 -0
  50. input1/files/18/selfie_img.jpg +0 -0
appbasic.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+
4
+ # Sample data for the table
5
+ data = {
6
+ "Column 1": ["A", "B", "C"],
7
+ "Column 2": [1, 2, 3],
8
+ "Column 3": [4.5, 5.5, 6.5]
9
+ }
10
+ df = pd.DataFrame(data)
11
+
12
+ def display_images(img1, img2):
13
+ # Function to display images and return them as outputs
14
+ return img1, img2, df
15
+
16
+ # Create the Gradio interface
17
+ interface = gr.Interface(
18
+ fn=display_images,
19
+ inputs=[
20
+ gr.Image(label="Upload Front Pose"),
21
+ gr.Image(label="Upload Side Pose"),
22
+ gr.Number(label="Enter Height (cm)")
23
+ ],
24
+ outputs=[
25
+ gr.DataFrame(label="Tabular Data"),
26
+ ],
27
+ title="Body Sizing System Demo",
28
+ description="Upload two images. Front View and Side View"
29
+ )
30
+
31
+ # Launch the app
32
+ interface.launch(share=False)
calculations.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import math
2
+
3
+ def euclidean_distance(point1, point2):
4
+ return math.sqrt((point2[0] - point1[0]) ** 2 + (point2[1] - point1[1]) ** 2)
5
+
6
+ def convert_to_real_measurements(pixel_measurement, pixel_height, real_height_cm):
7
+ height_ratio = real_height_cm / pixel_height
8
+ return pixel_measurement * height_ratio
9
+
10
+ def measure_body_sizes(poses, real_height_cm):
11
+ """Measure various body sizes based on detected poses."""
12
+ measurements = []
13
+ for pose in poses:
14
+ keypoints = pose[0] # This should directly give us the dictionary
15
+
16
+ # Extract positions directly from keypoints
17
+ left_shoulder = keypoints[5].position
18
+ right_shoulder = keypoints[6].position
19
+ left_hip = keypoints[11].position
20
+ right_hip = keypoints[12].position
21
+ left_ankle = keypoints[15].position
22
+ right_ankle = keypoints[16].position
23
+ left_wrist = keypoints[9].position
24
+ right_wrist = keypoints[10].position
25
+ left_eye = keypoints[1].position
26
+ right_eye = keypoints[2].position
27
+
28
+ # Calculate pixel height (from the top of the head to the bottom of the ankle)
29
+ pixel_height = euclidean_distance((left_eye.x, left_eye.y), (left_ankle.x, left_ankle.y))
30
+
31
+ # Calculate other pixel measurements
32
+ shoulder_width_pixels = euclidean_distance((left_shoulder.x, left_shoulder.y), (right_shoulder.x, right_shoulder.y))
33
+ leg_length_pixels = euclidean_distance((left_hip.x, left_hip.y), (left_ankle.x, left_ankle.y))
34
+ arm_length_pixels = euclidean_distance((left_shoulder.x, left_shoulder.y), (left_wrist.x, left_wrist.y))
35
+ shoulder_to_waist_pixels = euclidean_distance((left_shoulder.x, left_shoulder.y), (left_hip.x, left_hip.y))
36
+
37
+ # Convert pixel measurements to real measurements using the height ratio
38
+ measurements.append({
39
+ "shoulder_width_cm": convert_to_real_measurements(shoulder_width_pixels, pixel_height, real_height_cm),
40
+ "leg_length_cm": convert_to_real_measurements(leg_length_pixels, pixel_height, real_height_cm),
41
+ "arm_length_cm": convert_to_real_measurements(arm_length_pixels, pixel_height, real_height_cm),
42
+ "shoulder_to_waist_cm": convert_to_real_measurements(shoulder_to_waist_pixels, pixel_height, real_height_cm)
43
+ })
44
+
45
+ return measurements
input/person1.png ADDED
input1/.DS_Store ADDED
Binary file (6.15 kB). View file
 
input1/Body_Measurements_Dataset.pdf ADDED
Binary file (449 kB). View file
 
input1/body.csv ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ selfie,front,side,measurements
2
+ files/0/selfie_img.jpg,files/0/front_img.jpg,files/0/side_img.jpg,files/0/measurements.json
3
+ files/1/selfie_img.jpg,files/1/front_img.jpg,files/1/side_img.jpg,files/1/measurements.json
4
+ files/2/selfie_img.jpg,files/2/front_img.jpg,files/2/side_img.jpg,files/2/measurements.json
5
+ files/3/selfie_img.jpg,files/3/front_img.jpg,files/3/side_img.jpg,files/3/measurements.json
6
+ files/4/selfie_img.jpg,files/4/front_img.jpg,files/4/side_img.jpg,files/4/measurements.json
7
+ files/5/selfie_img.jpg,files/5/front_img.jpg,files/5/side_img.jpg,files/5/measurements.json
8
+ files/6/selfie_img.jpg,files/6/front_img.jpg,files/6/side_img.jpg,files/6/measurements.json
9
+ files/7/selfie_img.jpg,files/7/front_img.jpg,files/7/side_img.jpg,files/7/measurements.json
10
+ files/8/selfie_img.jpg,files/8/front_img.jpg,files/8/side_img.jpg,files/8/measurements.json
11
+ files/9/selfie_img.jpg,files/9/front_img.jpg,files/9/side_img.jpg,files/9/measurements.json
12
+ files/10/selfie_img.jpg,files/10/front_img.jpg,files/10/side_img.jpg,files/10/measurements.json
13
+ files/11/selfie_img.jpg,files/11/front_img.jpg,files/11/side_img.jpg,files/11/measurements.json
14
+ files/12/selfie_img.jpg,files/12/front_img.jpg,files/12/side_img.jpg,files/12/measurements.json
15
+ files/13/selfie_img.jpg,files/13/front_img.jpg,files/13/side_img.jpg,files/13/measurements.json
16
+ files/14/selfie_img.jpg,files/14/front_img.jpg,files/14/side_img.jpg,files/14/measurements.json
17
+ files/15/selfie_img.jpg,files/15/front_img.jpg,files/15/side_img.jpg,files/15/measurements.json
18
+ files/16/selfie_img.jpg,files/16/front_img.jpg,files/16/side_img.jpg,files/16/measurements.json
19
+ files/17/selfie_img.jpg,files/17/front_img.jpg,files/17/side_img.jpg,files/17/measurements.json
20
+ files/18/selfie_img.jpg,files/18/front_img.jpg,files/18/side_img.jpg,files/18/measurements.json
21
+ files/19/selfie_img.jpg,files/19/front_img.jpg,files/19/side_img.jpg,files/19/measurements.json
22
+ files/20/selfie_img.jpg,files/20/front_img.jpg,files/20/side_img.jpg,files/20/measurements.json
input1/files/.DS_Store ADDED
Binary file (6.15 kB). View file
 
input1/files/0/front_img.jpg ADDED
input1/files/0/measurements.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "arm_length_cm": "55.0",
3
+ "chest_circumference_cm": "79.0",
4
+ "front_build_cm": "31.0",
5
+ "hips_circumference_cm": "70.0_tbr",
6
+ "leg_length_cm": "95.0",
7
+ "neck_circumference_cm": "33.0",
8
+ "neck_waist_length_front_cm": "44.0",
9
+ "pelvis_circumference_cm": "88.0",
10
+ "shoulder_width_cm": "40.0",
11
+ "thigh_circumference_cm": "49.0",
12
+ "under_chest_circumference_cm": "71.0",
13
+ "waist_circumference_cm": "68.0",
14
+ "height": "159.0",
15
+ "weight": "49.0",
16
+ "age": "34",
17
+ "gender": "female",
18
+ "race": "latino",
19
+ "profession": "Employees"
20
+ }
input1/files/0/selfie_img.jpg ADDED
input1/files/0/side_img.jpg ADDED
input1/files/1/front_img.jpg ADDED
input1/files/1/measurements.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "arm_length_cm": "55.0",
3
+ "chest_circumference_cm": "93.0",
4
+ "front_build_cm": "30.0_tbr",
5
+ "hips_circumference_cm": "100.0",
6
+ "leg_length_cm": "90.0_tbr",
7
+ "neck_circumference_cm": "34.0",
8
+ "neck_waist_length_front_cm": "46.0_tbr",
9
+ "pelvis_circumference_cm": "106.0",
10
+ "shoulder_width_cm": "44.0_tbr",
11
+ "thigh_circumference_cm": "61.0",
12
+ "under_chest_circumference_cm": "79.0",
13
+ "waist_circumference_cm": "79.0",
14
+ "height": "157.0",
15
+ "weight": "64.0",
16
+ "age": "33",
17
+ "gender": "female",
18
+ "race": "latino",
19
+ "profession": "Executives"
20
+ }
input1/files/1/selfie_img.jpg ADDED
input1/files/1/side_img.jpg ADDED
input1/files/10/front_img.jpg ADDED
input1/files/10/measurements.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "arm_length_cm": "64.0_tbr",
3
+ "chest_circumference_cm": "112.0_tbr",
4
+ "front_build_cm": "32.0_tbr",
5
+ "hips_circumference_cm": "98.0_tbr",
6
+ "leg_length_cm": "103.0_tbr",
7
+ "neck_circumference_cm": "36.0_tbr",
8
+ "neck_waist_length_front_cm": "43.0_tbr",
9
+ "pelvis_circumference_cm": "113.0_tbr",
10
+ "shoulder_width_cm": "42.0_tbr",
11
+ "thigh_circumference_cm": "48.0_tbr",
12
+ "under_chest_circumference_cm": "87.0_tbr",
13
+ "waist_circumference_cm": "88.0_tbr",
14
+ "height": "163.0",
15
+ "weight": "78.0",
16
+ "age": "16",
17
+ "gender": "male",
18
+ "race": "caucasian",
19
+ "profession": "Others"
20
+ }
input1/files/10/selfie_img.jpg ADDED
input1/files/10/side_img.jpg ADDED
input1/files/11/front_img.jpg ADDED
input1/files/11/measurements.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "arm_length_cm": "55.0",
3
+ "chest_circumference_cm": "86.0",
4
+ "front_build_cm": "27.0",
5
+ "hips_circumference_cm": "84.0",
6
+ "leg_length_cm": "88.0",
7
+ "neck_circumference_cm": "35.0",
8
+ "neck_waist_length_front_cm": "42.0",
9
+ "pelvis_circumference_cm": "88.0_tbr",
10
+ "shoulder_width_cm": "15.0_tbr",
11
+ "thigh_circumference_cm": "55.0",
12
+ "under_chest_circumference_cm": "75.0",
13
+ "waist_circumference_cm": "65.0",
14
+ "height": "163.0",
15
+ "weight": "53.0",
16
+ "age": "23",
17
+ "gender": "female",
18
+ "race": "caucasian",
19
+ "profession": "Others"
20
+ }
input1/files/11/selfie_img.jpg ADDED
input1/files/11/side_img.jpg ADDED
input1/files/12/front_img.jpg ADDED
input1/files/12/measurements.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "arm_length_cm": "55.0",
3
+ "chest_circumference_cm": "90.0",
4
+ "front_build_cm": "32.0_tbr",
5
+ "hips_circumference_cm": "76.0",
6
+ "leg_length_cm": "102.0",
7
+ "neck_circumference_cm": "36.0",
8
+ "neck_waist_length_front_cm": "46.0_tbr",
9
+ "pelvis_circumference_cm": "101.0",
10
+ "shoulder_width_cm": "38.0",
11
+ "thigh_circumference_cm": "56.0",
12
+ "under_chest_circumference_cm": "79.0",
13
+ "waist_circumference_cm": "73.0",
14
+ "height": "165.0",
15
+ "weight": "60.0",
16
+ "age": "37",
17
+ "gender": "female",
18
+ "race": "caucasian",
19
+ "profession": "Executives"
20
+ }
input1/files/12/selfie_img.jpg ADDED
input1/files/12/side_img.jpg ADDED
input1/files/13/front_img.jpg ADDED
input1/files/13/measurements.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "arm_length_cm": "60.0_tbr",
3
+ "chest_circumference_cm": "105.0_tbr",
4
+ "front_build_cm": "33.0_tbr",
5
+ "hips_circumference_cm": "102.0_tbr",
6
+ "leg_length_cm": "86.0_tbr",
7
+ "neck_circumference_cm": "38.0_tbr",
8
+ "neck_waist_length_front_cm": "55.0_tbr",
9
+ "pelvis_circumference_cm": "103.0_tbr",
10
+ "shoulder_width_cm": "41.0_tbr",
11
+ "thigh_circumference_cm": "52.0_tbr",
12
+ "under_chest_circumference_cm": "94.0_tbr",
13
+ "waist_circumference_cm": "102.0_tbr",
14
+ "height": "155.0",
15
+ "weight": "99.0",
16
+ "age": "34",
17
+ "gender": "male",
18
+ "race": "caucasian",
19
+ "profession": "Others"
20
+ }
input1/files/13/selfie_img.jpg ADDED
input1/files/13/side_img.jpg ADDED
input1/files/14/front_img.jpg ADDED
input1/files/14/measurements.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "arm_length_cm": "58.0",
3
+ "chest_circumference_cm": "86.0_tbr",
4
+ "front_build_cm": "34.0_tbr",
5
+ "hips_circumference_cm": "80.0",
6
+ "leg_length_cm": "96.0_tbr",
7
+ "neck_circumference_cm": "31.0",
8
+ "neck_waist_length_front_cm": "41.0_tbr",
9
+ "pelvis_circumference_cm": "96.0",
10
+ "shoulder_width_cm": "42.0_tbr",
11
+ "thigh_circumference_cm": "55.0",
12
+ "under_chest_circumference_cm": "72.0",
13
+ "waist_circumference_cm": "77.0",
14
+ "height": "172.0",
15
+ "weight": "58.0",
16
+ "age": "36",
17
+ "gender": "female",
18
+ "race": "black",
19
+ "profession": "Employees"
20
+ }
input1/files/14/selfie_img.jpg ADDED
input1/files/14/side_img.jpg ADDED
input1/files/15/front_img.jpg ADDED
input1/files/15/measurements.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "arm_length_cm": "60.0_tbr",
3
+ "chest_circumference_cm": "103.0_tbr",
4
+ "front_build_cm": "38.0_tbr",
5
+ "hips_circumference_cm": "99.0_tbr",
6
+ "leg_length_cm": "95.0_tbr",
7
+ "neck_circumference_cm": "43.0_tbr",
8
+ "neck_waist_length_front_cm": "55.0_tbr",
9
+ "pelvis_circumference_cm": "101.0_tbr",
10
+ "shoulder_width_cm": "40.0_tbr",
11
+ "thigh_circumference_cm": "54.0_tbr",
12
+ "under_chest_circumference_cm": "95.0_tbr",
13
+ "waist_circumference_cm": "101.0_tbr",
14
+ "height": "168.0",
15
+ "weight": "76.0",
16
+ "age": "39",
17
+ "gender": "male",
18
+ "race": "indian",
19
+ "profession": "Intermediate_prof"
20
+ }
input1/files/15/selfie_img.jpg ADDED
input1/files/15/side_img.jpg ADDED
input1/files/16/front_img.jpg ADDED
input1/files/16/measurements.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "arm_length_cm": "58.0_tbr",
3
+ "chest_circumference_cm": "107.0",
4
+ "front_build_cm": "42.0",
5
+ "hips_circumference_cm": "93.0",
6
+ "leg_length_cm": "90.0_tbr",
7
+ "neck_circumference_cm": "41.0",
8
+ "neck_waist_length_front_cm": "48.0_tbr",
9
+ "pelvis_circumference_cm": "103.0",
10
+ "shoulder_width_cm": "46.0_tbr",
11
+ "thigh_circumference_cm": "56.0",
12
+ "under_chest_circumference_cm": "99.0",
13
+ "waist_circumference_cm": "92.0",
14
+ "height": "175.0",
15
+ "weight": "80.0",
16
+ "age": "28",
17
+ "gender": "male",
18
+ "race": "caucasian",
19
+ "profession": "Others"
20
+ }
input1/files/16/selfie_img.jpg ADDED
input1/files/16/side_img.jpg ADDED
input1/files/17/front_img.jpg ADDED
input1/files/17/measurements.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "arm_length_cm": "59.0",
3
+ "chest_circumference_cm": "90.0",
4
+ "front_build_cm": "31.0_tbr",
5
+ "hips_circumference_cm": "90.0",
6
+ "leg_length_cm": "91.0_tbr",
7
+ "neck_circumference_cm": "30.0",
8
+ "neck_waist_length_front_cm": "53.0_tbr",
9
+ "pelvis_circumference_cm": "102.0",
10
+ "shoulder_width_cm": "44.0_tbr",
11
+ "thigh_circumference_cm": "56.0",
12
+ "under_chest_circumference_cm": "85.0",
13
+ "waist_circumference_cm": "73.0_tbr",
14
+ "height": "170.0",
15
+ "weight": "61.0",
16
+ "age": "29",
17
+ "gender": "female",
18
+ "race": "caucasian",
19
+ "profession": "Manual"
20
+ }
input1/files/17/selfie_img.jpg ADDED
input1/files/17/side_img.jpg ADDED
input1/files/18/front_img.jpg ADDED
input1/files/18/measurements.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "arm_length_cm": "64.0",
3
+ "chest_circumference_cm": "110.0",
4
+ "front_build_cm": "48.0_tbr",
5
+ "hips_circumference_cm": "50.0_tbr",
6
+ "leg_length_cm": "110.0",
7
+ "neck_circumference_cm": "43.0",
8
+ "neck_waist_length_front_cm": "54.0_tbr",
9
+ "pelvis_circumference_cm": "111.0",
10
+ "shoulder_width_cm": "39.0",
11
+ "thigh_circumference_cm": "61.0",
12
+ "under_chest_circumference_cm": "102.0",
13
+ "waist_circumference_cm": "99.0",
14
+ "height": "190.0",
15
+ "weight": "100.0",
16
+ "age": "42",
17
+ "gender": "male",
18
+ "race": "caucasian",
19
+ "profession": "Executives"
20
+ }
input1/files/18/selfie_img.jpg ADDED