awacke1 commited on
Commit
81afc2a
·
verified ·
1 Parent(s): d0e6378

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -1,7 +1,7 @@
1
  #!/usr/bin/env python3
2
  import os
3
  import glob
4
- import time # Added missing import
5
  import streamlit as st
6
  from PIL import Image
7
  import torch
@@ -172,9 +172,8 @@ with tab2:
172
  if st.button("Run OCR 🚀", key="ocr_run"):
173
  if ocr_model == "Qwen2-VL-OCR-2B":
174
  processor, model = load_ocr_qwen2vl()
175
- # Prepare inputs correctly for Qwen2-VL
176
- messages = [{"role": "user", "content": [{"type": "image", "image": image}, {"type": "text", "text": prompt}]}]
177
- inputs = processor(messages, return_tensors="pt").to("cpu")
178
  outputs = model.generate(**inputs, max_new_tokens=1024)
179
  text = processor.batch_decode(outputs, skip_special_tokens=True)[0]
180
  else: # GOT-OCR2_0
 
1
  #!/usr/bin/env python3
2
  import os
3
  import glob
4
+ import time
5
  import streamlit as st
6
  from PIL import Image
7
  import torch
 
172
  if st.button("Run OCR 🚀", key="ocr_run"):
173
  if ocr_model == "Qwen2-VL-OCR-2B":
174
  processor, model = load_ocr_qwen2vl()
175
+ # Simplified input: pass image and text directly
176
+ inputs = processor(text=prompt, images=image, return_tensors="pt").to("cpu")
 
177
  outputs = model.generate(**inputs, max_new_tokens=1024)
178
  text = processor.batch_decode(outputs, skip_special_tokens=True)[0]
179
  else: # GOT-OCR2_0