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

Function process_batch

evaluation/evaluation_math.py:81–107  ·  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

79 json.dump(all_outputs, f, indent=2, ensure_ascii=False)
80
81def process_batch(model, batch_images, batch_questions, id_list, all_outputs):
82 """Process a batch of images and questions"""
83 batch_results = model.answer_questions_batch_math(batch_images, batch_questions)
84
85 for i, result in enumerate(batch_results):
86 try:
87 thinking = result["thinking"]
88 answer = result["answer"]
89
90 all_outputs.append({
91 "text": id_list[i]["text"],
92 "think": thinking,
93 "prediction": id_list[i]['choices'][ord(answer.strip().lower()[0]) - ord('a')] if id_list[i]['choices'] is not None else answer,
94 "ground_truth": id_list[i]['answer'],
95 "choices": id_list[i]['choices'] if 'choices' in id_list[i] else None
96 })
97
98 except Exception as e:
99 print(f"Error processing result: {e}, Raw answer is {answer}")
100 # Add penalty in this situation
101 all_outputs.append({
102 "text": id_list[i]["text"],
103 "think": "",
104 "prediction": "",
105 "ground_truth": id_list[i]['answer'],
106 "choices": id_list[i]['choices'] if 'choices' in id_list[i] else None
107 })
108
109if __name__ == "__main__":
110 main()

Callers 1

mainFunction · 0.70

Calls 1

Tested by

no test coverage detected