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).to("
|
171 |
processor = AutoProcessor.from_pretrained(ckpt, trust_remote_code=True)
|
172 |
|
173 |
def generate_predictions(image_input, text_input):
|
@@ -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"].to("
|
193 |
-
input_ids=inputs["input_ids"][:, :-1].to("
|
194 |
-
attention_mask=inputs["attention_mask"][:, :-1].to("
|
195 |
img_features=None,
|
196 |
-
img_attn_mask=inputs["img_attn_mask"][:, :-1].to("
|
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("cpu")
|
171 |
processor = AutoProcessor.from_pretrained(ckpt, trust_remote_code=True)
|
172 |
|
173 |
def generate_predictions(image_input, text_input):
|
|
|
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("cpu"),
|
193 |
+
input_ids=inputs["input_ids"][:, :-1].to("cpu"),
|
194 |
+
attention_mask=inputs["attention_mask"][:, :-1].to("cpu"),
|
195 |
img_features=None,
|
196 |
+
img_attn_mask=inputs["img_attn_mask"][:, :-1].to("cpu"),
|
197 |
use_cache=True,
|
198 |
max_new_tokens=128,
|
199 |
)
|