Wendy
commited on
Upload cogagent_infer.py with huggingface_hub
Browse files- cogagent_infer.py +4 -2
cogagent_infer.py
CHANGED
@@ -6,6 +6,7 @@ from PIL import Image, ImageDraw
|
|
6 |
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
|
7 |
from typing import List
|
8 |
import json
|
|
|
9 |
|
10 |
def draw_boxes_on_image(image: Image.Image, boxes: List[List[float]], save_path: str):
|
11 |
"""
|
@@ -122,7 +123,8 @@ def main():
|
|
122 |
with open(args.input_json, "r") as f:
|
123 |
data = json.load(f)
|
124 |
res = []
|
125 |
-
for
|
|
|
126 |
img_path = x['image']
|
127 |
image = Image.open(img_path).convert("RGB")
|
128 |
task = x['conversations'][0]['value']
|
@@ -189,7 +191,7 @@ def main():
|
|
189 |
draw_boxes_on_image(image, boxes, output_path)
|
190 |
#print(f"Annotated image saved at: {output_path}")
|
191 |
ans = {
|
192 |
-
'query': query,
|
193 |
'response': response,
|
194 |
'output_path': output_path
|
195 |
}
|
|
|
6 |
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
|
7 |
from typing import List
|
8 |
import json
|
9 |
+
form tqdm import tqdm
|
10 |
|
11 |
def draw_boxes_on_image(image: Image.Image, boxes: List[List[float]], save_path: str):
|
12 |
"""
|
|
|
123 |
with open(args.input_json, "r") as f:
|
124 |
data = json.load(f)
|
125 |
res = []
|
126 |
+
for i in tqdm(range(len(data))):
|
127 |
+
x = data[i]
|
128 |
img_path = x['image']
|
129 |
image = Image.open(img_path).convert("RGB")
|
130 |
task = x['conversations'][0]['value']
|
|
|
191 |
draw_boxes_on_image(image, boxes, output_path)
|
192 |
#print(f"Annotated image saved at: {output_path}")
|
193 |
ans = {
|
194 |
+
'query': f"Round {round_num} query:\n{query}",
|
195 |
'response': response,
|
196 |
'output_path': output_path
|
197 |
}
|