WUBIAO commited on
Commit
945a97b
·
verified ·
1 Parent(s): e73817e

Upload cogagent_infer_batch.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. cogagent_infer_batch.py +13 -4
cogagent_infer_batch.py CHANGED
@@ -146,7 +146,7 @@ def main():
146
  img_path,task = x
147
  image = []
148
  for path in img_path:
149
- image = Image.open(path).convert("RGB")
150
  #image = Image.open(img_path).convert("RGB")
151
  #task = x['conversations'][0]['value']
152
  # Verify history lengths match
@@ -204,10 +204,19 @@ def main():
204
  boxes = [[int(x) / 1000 for x in match] for match in matches]
205
 
206
  # Extract base name of the user's input image (without extension)
207
- base_name = os.path.splitext(os.path.basename(img_path))[0]
 
 
 
208
  # Construct the output file name with round number
209
- output_file_name = f"{base_name}_{round_num}.png"
210
- output_path = os.path.join(args.output_image_path, output_file_name)
 
 
 
 
 
 
211
 
212
  draw_boxes_on_image(image, boxes, output_path)
213
  #print(f"Annotated image saved at: {output_path}")
 
146
  img_path,task = x
147
  image = []
148
  for path in img_path:
149
+ image.append(Image.open(path).convert("RGB"))
150
  #image = Image.open(img_path).convert("RGB")
151
  #task = x['conversations'][0]['value']
152
  # Verify history lengths match
 
204
  boxes = [[int(x) / 1000 for x in match] for match in matches]
205
 
206
  # Extract base name of the user's input image (without extension)
207
+ base_name = []
208
+ for path in args.img_path:
209
+ base_name.append(os.path.splitext(os.path.basename(path))[0])
210
+ #base_name = os.path.splitext(os.path.basename(img_path))[0]
211
  # Construct the output file name with round number
212
+ output_file_name = []
213
+ for i in range(len(base_name)):
214
+ output_file_name.append(f"{base_name[i]}_{round_num}_{i}.png")
215
+ #output_file_name = f"{base_name}_{round_num}.png"
216
+ output_path = []
217
+ for x in output_file_name:
218
+ output_path.append(os.path.join(args.output_image_path, x))
219
+ #output_path = os.path.join(args.output_image_path, output_file_name)
220
 
221
  draw_boxes_on_image(image, boxes, output_path)
222
  #print(f"Annotated image saved at: {output_path}")