1616
1717GPT_MODEL = "gpt-4o-2024-08-06"
1818
19+ prices = {
20+ "gpt-4o-2024-08-06" : {"input" : 2.5 / 10 ** 6 , "output" : 10 / 10 ** 6 },
21+ }
1922
2023class GT_Agnostic_Response (BaseModel ):
2124 """
@@ -46,7 +49,7 @@ def split_indices(indices, num_chunks):
4649 return chunks
4750
4851class GPTAnnotator :
49- def __init__ (self , ann_file , data_root , clip_length = 32 ):
52+ def __init__ (self , ann_file , data_root , clip_length = 4 ):
5053 self .ann_file = ann_file
5154 self .data_root = data_root
5255 self .clip_length = clip_length
@@ -92,6 +95,9 @@ def prepare_multiple_images(self, images):
9295
9396
9497 def extract_frames (self , data_root , vid_path , start_second , end_second ):
98+
99+
100+
95101 frames , time_meta = avion_video_loader (data_root ,
96102 vid_path ,
97103 'MP4' ,
@@ -184,6 +190,13 @@ def predict_images(self, images, data_item):
184190 temperature = temperature
185191 )
186192
193+ input_consumed = response .usage .prompt_tokens
194+ output_consumed = response .usage .completion_tokens
195+ input_cost = input_consumed * prices [GPT_MODEL ]["input" ]
196+ output_cost = output_consumed * prices [GPT_MODEL ]["output" ]
197+ total_cost = input_cost + output_cost
198+ print ('cost of the inference' , total_cost )
199+
187200 return response .choices [0 ].message .parsed
188201
189202
@@ -296,11 +309,7 @@ def explore_wrong_examples(train_file_path, root, prediction_save_folder):
296309 print ('gt_name not in avion_predictions' )
297310 continue
298311 else :
299- count += 1
300- if count <= 2 :
301- continue
302- if count > 6 :
303- break
312+ count += 1
304313 print ('gt_name in avion_predictions' )
305314
306315 vid_path = v ['vid_path' ][0 ]
@@ -327,7 +336,7 @@ def explore_wrong_examples(train_file_path, root, prediction_save_folder):
327336 print ('llava_pred' , v ['llava_pred' ])
328337 print ('chatgpt answer' , predicted_answer )
329338 print ('explanation' , explanation )
330-
339+ break
331340
332341
333342
0 commit comments