Upload infer_qwen2_vl.py with huggingface_hub
Browse files- infer_qwen2_vl.py +5 -1
infer_qwen2_vl.py
CHANGED
|
@@ -42,6 +42,7 @@ for img_path in glob.glob(f"{folder}/*.jpe"):
|
|
| 42 |
images.append(img)
|
| 43 |
|
| 44 |
num_image = len(images)
|
|
|
|
| 45 |
begin, end, batch_size= 0, 10, args.batch_size
|
| 46 |
messages = [
|
| 47 |
{
|
|
@@ -61,15 +62,18 @@ messages = [
|
|
| 61 |
],
|
| 62 |
}
|
| 63 |
]
|
|
|
|
| 64 |
from tqdm import tqdm
|
| 65 |
# Preparation for inference
|
| 66 |
ans = []
|
| 67 |
counter = 0
|
| 68 |
for batch_idx in tqdm(range(begin, end, batch_size)):
|
| 69 |
batch = data[batch_idx: min(batch_idx + batch_size, end)]
|
|
|
|
| 70 |
image_inputs_batch, video_inputs_batch = [], []
|
| 71 |
for idx,i in enumerate(batch):
|
| 72 |
img = images[i]
|
|
|
|
| 73 |
messages[1]["content"][0]["image"] = img
|
| 74 |
text = processor.apply_chat_template(
|
| 75 |
messages, tokenize=False, add_generation_prompt=True
|
|
@@ -97,7 +101,7 @@ for batch_idx in tqdm(range(begin, end, batch_size)):
|
|
| 97 |
#ans.append(output_text)
|
| 98 |
save_path = "output.json"
|
| 99 |
counter = counter + 1
|
| 100 |
-
if counter %
|
| 101 |
print(f"Saving data at iteration {idx + 1}")
|
| 102 |
write_json(save_path, data)
|
| 103 |
|
|
|
|
| 42 |
images.append(img)
|
| 43 |
|
| 44 |
num_image = len(images)
|
| 45 |
+
print(f"beigin : {begin}, end : {end}, batch_size : {batch_size}"}")
|
| 46 |
begin, end, batch_size= 0, 10, args.batch_size
|
| 47 |
messages = [
|
| 48 |
{
|
|
|
|
| 62 |
],
|
| 63 |
}
|
| 64 |
]
|
| 65 |
+
|
| 66 |
from tqdm import tqdm
|
| 67 |
# Preparation for inference
|
| 68 |
ans = []
|
| 69 |
counter = 0
|
| 70 |
for batch_idx in tqdm(range(begin, end, batch_size)):
|
| 71 |
batch = data[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 = [], []
|
| 74 |
for idx,i in enumerate(batch):
|
| 75 |
img = images[i]
|
| 76 |
+
print('gain image successfully !')
|
| 77 |
messages[1]["content"][0]["image"] = img
|
| 78 |
text = processor.apply_chat_template(
|
| 79 |
messages, tokenize=False, add_generation_prompt=True
|
|
|
|
| 101 |
#ans.append(output_text)
|
| 102 |
save_path = "output.json"
|
| 103 |
counter = counter + 1
|
| 104 |
+
if counter % 1 == 0:
|
| 105 |
print(f"Saving data at iteration {idx + 1}")
|
| 106 |
write_json(save_path, data)
|
| 107 |
|