michaelryoo
commited on
Commit
•
0fdfc65
1
Parent(s):
03eedfb
Update xgen-mm-vid-inference-script.py
Browse files
xgen-mm-vid-inference-script.py
CHANGED
@@ -50,23 +50,11 @@ def generate(messages, images):
|
|
50 |
image_sizes = [image.size for image in images]
|
51 |
# Similar operation in model_worker.py
|
52 |
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
for img in images
|
59 |
-
]
|
60 |
-
|
61 |
-
inputs = {"pixel_values": [image_list]}
|
62 |
-
else:
|
63 |
-
image_tensor = [image_processor([img])["pixel_values"].to(model.device, dtype=torch.float16) for img in images]
|
64 |
-
|
65 |
-
for i in range(0, 8):
|
66 |
-
image_tensor[i] = torch.zeros([1, 1, 1, 3, 384, 384], device=model.device, dtype=torch.float16)
|
67 |
-
image_tensor = torch.stack(image_tensor, dim=1)
|
68 |
-
image_tensor = image_tensor.squeeze(2)
|
69 |
-
inputs = {"pixel_values": image_tensor}
|
70 |
|
71 |
full_conv = "<|system|>\nA chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.<|end|>\n"
|
72 |
for msg in messages:
|
@@ -123,12 +111,6 @@ import torch
|
|
123 |
|
124 |
your_checkpoint_path = ""
|
125 |
sd = torch.load(your_checkpoint_path)
|
126 |
-
|
127 |
-
sd = sd["model_state_dict"]
|
128 |
-
for k, v in list(sd.items()):
|
129 |
-
sd["vlm." + k] = v
|
130 |
-
del sd[k]
|
131 |
-
|
132 |
model.load_state_dict(sd)
|
133 |
|
134 |
# %%
|
|
|
50 |
image_sizes = [image.size for image in images]
|
51 |
# Similar operation in model_worker.py
|
52 |
|
53 |
+
image_tensor = [image_processor([img])["pixel_values"].to(model.device, dtype=torch.float16) for img in images]
|
54 |
+
|
55 |
+
image_tensor = torch.stack(image_tensor, dim=1)
|
56 |
+
image_tensor = image_tensor.squeeze(2)
|
57 |
+
inputs = {"pixel_values": image_tensor}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
full_conv = "<|system|>\nA chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.<|end|>\n"
|
60 |
for msg in messages:
|
|
|
111 |
|
112 |
your_checkpoint_path = ""
|
113 |
sd = torch.load(your_checkpoint_path)
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
model.load_state_dict(sd)
|
115 |
|
116 |
# %%
|