-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_top_keypoint_cnt.py
39 lines (33 loc) · 1.29 KB
/
check_top_keypoint_cnt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import json
# import os
# # Set the working directory
# os.chdir('/Users/dahye/PycharmProjects/CLIP-pose-estimation')
#
# # Verify the current working directory
# print("Current working directory:", os.getcwd())
# Load the JSON data from the file
with open('datasets/MARS/MARS_keypoints_top.json') as f:
input_data = json.load(f)
print(input_data[0])
print(input_data[0]['coords']['black'])
print(input_data[0]['coords']['white'])
# Function to compute average coordinates for a single set of keypoint
# Initialize accumulators for black and white datasets
total_black_coords_len, black_count = 0, 0
total_white_coords_len, white_count = 0, 0
# Iterate over the entire dataset
for entry in input_data:
# For black coordinates
if 'black' in entry['coords']:
total_black_coords_len += len(entry['coords']['black']['x'])
black_count += 1
# For white coordinates
if 'white' in entry['coords']:
total_white_coords_len += len(entry['coords']['white']['x'])
white_count += 1
# Calculate overall averages
avg_black_coords_cnt = total_black_coords_len / black_count
avg_white_coords_cnt = total_white_coords_len / white_count
# Print results
print(f"Average black keypoints count: {avg_black_coords_cnt}")
print(f"Average white keypoints count: {avg_white_coords_cnt}")