Spaces:
Running
on
L40S
Running
on
L40S
Update create_graph.py
Browse files- create_graph.py +7 -7
create_graph.py
CHANGED
@@ -181,7 +181,7 @@ def create_graph(json_path, smplx_model):
|
|
181 |
global_i += 1
|
182 |
return graph
|
183 |
|
184 |
-
def create_edges(graph):
|
185 |
adaptive_length = [-4, -3, -2, -1, 1, 2, 3, 4]
|
186 |
# print()
|
187 |
for i, node in enumerate(graph.vs):
|
@@ -231,7 +231,7 @@ def create_edges(graph):
|
|
231 |
velocity_similarity = np.linalg.norm(current_velocity - other_velocity, axis=1)
|
232 |
trans_similarity = np.linalg.norm(current_trans - other_trans, axis=0)
|
233 |
if trans_similarity < threshold_trans:
|
234 |
-
if np.sum(position_similarity < threshold_position) >= 45 and np.sum(velocity_similarity < threshold_velocity) >= 45:
|
235 |
graph.add_edge(i, j, is_continue=0)
|
236 |
|
237 |
print(f"nodes: {len(graph.vs)}, edges: {len(graph.es)}")
|
@@ -456,6 +456,7 @@ if __name__ == '__main__':
|
|
456 |
parser = argparse.ArgumentParser()
|
457 |
parser.add_argument("--json_save_path", type=str, default="")
|
458 |
parser.add_argument("--graph_save_path", type=str, default="")
|
|
|
459 |
args = parser.parse_args()
|
460 |
json_path = args.json_save_path
|
461 |
graph_path = args.graph_save_path
|
@@ -475,16 +476,15 @@ if __name__ == '__main__':
|
|
475 |
# single_test
|
476 |
# graph = create_graph('/content/drive/MyDrive/003_Codes/TANGO/datasets/data_json/show_oliver_test/Abortion_Laws_-_Last_Week_Tonight_with_John_Oliver_HBO-DRauXXz6t0Y.webm.json')
|
477 |
graph = create_graph(json_path, smplx_model)
|
478 |
-
graph = create_edges(graph)
|
479 |
# pool_path = "/content/drive/MyDrive/003_Codes/TANGO-JointEmbedding/datasets/oliver_test/show-oliver-test.pkl"
|
480 |
# graph = igraph.Graph.Read_Pickle(fname=pool_path)
|
481 |
# graph = igraph.Graph.Read_Pickle(fname="/content/drive/MyDrive/003_Codes/TANGO-JointEmbedding/datasets/oliver_test/test.pkl")
|
482 |
-
|
483 |
-
walk, is_continue =
|
484 |
-
motion = path_visualization(graph, walk, is_continue, "./test.mp4", audio_path=None, verbose_continue=True, return_motion=True)
|
485 |
# print(motion.shape)
|
486 |
save_graph = graph.write_pickle(fname=graph_path)
|
487 |
-
graph = graph_pruning(graph)
|
488 |
|
489 |
# show-oliver
|
490 |
# json_path = "/content/drive/MyDrive/003_Codes/TANGO/datasets/data_json/show_oliver_test/"
|
|
|
181 |
global_i += 1
|
182 |
return graph
|
183 |
|
184 |
+
def create_edges(graph, threshold_edges):
|
185 |
adaptive_length = [-4, -3, -2, -1, 1, 2, 3, 4]
|
186 |
# print()
|
187 |
for i, node in enumerate(graph.vs):
|
|
|
231 |
velocity_similarity = np.linalg.norm(current_velocity - other_velocity, axis=1)
|
232 |
trans_similarity = np.linalg.norm(current_trans - other_trans, axis=0)
|
233 |
if trans_similarity < threshold_trans:
|
234 |
+
if np.sum(position_similarity < threshold_edges*threshold_position) >= 45 and np.sum(velocity_similarity < threshold_edges*threshold_velocity) >= 45:
|
235 |
graph.add_edge(i, j, is_continue=0)
|
236 |
|
237 |
print(f"nodes: {len(graph.vs)}, edges: {len(graph.es)}")
|
|
|
456 |
parser = argparse.ArgumentParser()
|
457 |
parser.add_argument("--json_save_path", type=str, default="")
|
458 |
parser.add_argument("--graph_save_path", type=str, default="")
|
459 |
+
parser.add_argument("--threshold", type=float, default=1.0)
|
460 |
args = parser.parse_args()
|
461 |
json_path = args.json_save_path
|
462 |
graph_path = args.graph_save_path
|
|
|
476 |
# single_test
|
477 |
# graph = create_graph('/content/drive/MyDrive/003_Codes/TANGO/datasets/data_json/show_oliver_test/Abortion_Laws_-_Last_Week_Tonight_with_John_Oliver_HBO-DRauXXz6t0Y.webm.json')
|
478 |
graph = create_graph(json_path, smplx_model)
|
479 |
+
graph = create_edges(graph, args.threshold)
|
480 |
# pool_path = "/content/drive/MyDrive/003_Codes/TANGO-JointEmbedding/datasets/oliver_test/show-oliver-test.pkl"
|
481 |
# graph = igraph.Graph.Read_Pickle(fname=pool_path)
|
482 |
# graph = igraph.Graph.Read_Pickle(fname="/content/drive/MyDrive/003_Codes/TANGO-JointEmbedding/datasets/oliver_test/test.pkl")
|
483 |
+
# walk, is_continue = random_walk(graph, 100)
|
484 |
+
# motion = path_visualization(graph, walk, is_continue, "./test.mp4", audio_path=None, verbose_continue=True, return_motion=True)
|
|
|
485 |
# print(motion.shape)
|
486 |
save_graph = graph.write_pickle(fname=graph_path)
|
487 |
+
# graph = graph_pruning(graph)
|
488 |
|
489 |
# show-oliver
|
490 |
# json_path = "/content/drive/MyDrive/003_Codes/TANGO/datasets/data_json/show_oliver_test/"
|