Atualli commited on
Commit
fbf8c84
1 Parent(s): dfad4b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
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("cuda")
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("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
  )
 
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
  )