Wendy-Fly commited on
Commit
9015d93
·
verified ·
1 Parent(s): 0c40137

Upload infer_qwen2_vl.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. infer_qwen2_vl.py +5 -4
infer_qwen2_vl.py CHANGED
@@ -42,7 +42,7 @@ file_names = os.listdir(folder)
42
 
43
  num_image = len(file_names)
44
 
45
- begin, end, batch_size= 0, num_image, 16
46
  print(f"beigin : {begin}, end : {end}, batch_size : {batch_size}")
47
  messages = [
48
  {
@@ -68,8 +68,9 @@ from tqdm import tqdm
68
  ans = []
69
  counter = 0
70
  for batch_idx in tqdm(range(begin, end, batch_size)):
71
- batch = file_names[batch_idx: min(batch_idx + batch_size, end)]
72
- print(f"data index range : {batch_idx} ~ {min(batch_idx + batch_size, end)}")
 
73
  image_inputs_batch, video_inputs_batch,text_batch = [], [], []
74
  for idx,i in enumerate(batch):
75
  #img = batch[i]
@@ -119,7 +120,7 @@ for batch_idx in tqdm(range(begin, end, batch_size)):
119
  ans.append(output_text)
120
  save_path = "output_final.json"
121
  counter = counter + 1
122
- if counter % 1 == 0:
123
  print(f"Saving data at iteration {idx + 1}")
124
  write_json(save_path, ans)
125
 
 
42
 
43
  num_image = len(file_names)
44
 
45
+ begin, end, batch_size= 0, num_image, 12
46
  print(f"beigin : {begin}, end : {end}, batch_size : {batch_size}")
47
  messages = [
48
  {
 
68
  ans = []
69
  counter = 0
70
  for batch_idx in tqdm(range(begin, end, batch_size)):
71
+ up = min(batch_idx + batch_size, end)
72
+ batch = file_names[batch_idx: up]
73
+ print(f"data index range : {batch_idx} ~ {up}")
74
  image_inputs_batch, video_inputs_batch,text_batch = [], [], []
75
  for idx,i in enumerate(batch):
76
  #img = batch[i]
 
120
  ans.append(output_text)
121
  save_path = "output_final.json"
122
  counter = counter + 1
123
+ if counter % 10 == 0 or up + 10 >= end:
124
  print(f"Saving data at iteration {idx + 1}")
125
  write_json(save_path, ans)
126