MCPcopy Create free account
hub / github.com/JIA-Lab-research/VisionReasoner / process_batch

Function process_batch

evaluation/evaluation_count.py:75–105  ·  view source on GitHub ↗

Process a batch of images and questions

(model, batch_images, batch_questions, id_list, all_outputs)

Source from the content-addressed store, hash-verified

73 json.dump(all_outputs, f, indent=2, ensure_ascii=False)
74
75def process_batch(model, batch_images, batch_questions, id_list, all_outputs):
76 """Process a batch of images and questions"""
77 batch_results = model.count_objects_batch(batch_images, batch_questions)
78
79 for i, result in enumerate(batch_results):
80 try:
81 thinking = result["thinking"]
82 bboxes = result["bboxes"]
83 pred_count = result["count"]
84
85 all_outputs.append({
86 "image_id": id_list[i]["image_id"],
87 "ann_id": id_list[i]["ann_id"],
88 "think": thinking,
89 "pred_count": pred_count,
90 "gt_count": id_list[i]["gt_count"]
91 })
92
93 except Exception as e:
94 # raise
95 print(f"Error processing result: {e}")
96 # Add penalty in this situation
97 all_outputs.append({
98 "image_id": id_list[i]["image_id"],
99 "ann_id": id_list[i]["ann_id"],
100 "think": "",
101 "pred_count": 1,
102 "gt_count": id_list[i]["gt_count"]
103 })
104
105 print(f"Processed batch of {len(batch_images)} images")
106
107
108if __name__ == "__main__":

Callers 1

mainFunction · 0.70

Calls 1

count_objects_batchMethod · 0.45

Tested by

no test coverage detected