Update app.py
Browse files
app.py
CHANGED
@@ -167,7 +167,7 @@ def main():
|
|
167 |
|
168 |
ckpt = "ydshieh/kosmos-2-patch14-224"
|
169 |
|
170 |
-
model = AutoModelForVision2Seq.from_pretrained(ckpt, trust_remote_code=True)
|
171 |
processor = AutoProcessor.from_pretrained(ckpt, trust_remote_code=True)
|
172 |
|
173 |
def generate_predictions(image_input, text_input, do_sample, sampling_topp, sampling_temperature):
|
@@ -189,11 +189,11 @@ def main():
|
|
189 |
inputs = processor(text=text_input, images=image_input, return_tensors="pt")
|
190 |
|
191 |
generated_ids = model.generate(
|
192 |
-
pixel_values=inputs["pixel_values"],
|
193 |
-
input_ids=inputs["input_ids"][:, :-1],
|
194 |
-
attention_mask=inputs["attention_mask"][:, :-1],
|
195 |
img_features=None,
|
196 |
-
img_attn_mask=inputs["img_attn_mask"][:, :-1],
|
197 |
use_cache=True,
|
198 |
max_new_tokens=128,
|
199 |
)
|
|
|
167 |
|
168 |
ckpt = "ydshieh/kosmos-2-patch14-224"
|
169 |
|
170 |
+
model = AutoModelForVision2Seq.from_pretrained(ckpt, trust_remote_code=True).to("cuda")
|
171 |
processor = AutoProcessor.from_pretrained(ckpt, trust_remote_code=True)
|
172 |
|
173 |
def generate_predictions(image_input, text_input, do_sample, sampling_topp, sampling_temperature):
|
|
|
189 |
inputs = processor(text=text_input, images=image_input, return_tensors="pt")
|
190 |
|
191 |
generated_ids = model.generate(
|
192 |
+
pixel_values=inputs["pixel_values"].to("cuda"),
|
193 |
+
input_ids=inputs["input_ids"][:, :-1].to("cuda"),
|
194 |
+
attention_mask=inputs["attention_mask"][:, :-1].to("cuda"),
|
195 |
img_features=None,
|
196 |
+
img_attn_mask=inputs["img_attn_mask"][:, :-1].to("cuda"),
|
197 |
use_cache=True,
|
198 |
max_new_tokens=128,
|
199 |
)
|