prithivMLmods commited on
Commit
a902eab
·
verified ·
1 Parent(s): 9677799

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -4
app.py CHANGED
@@ -155,9 +155,7 @@ def process_document_stream(model_name: str, image: Image.Image, max_new_tokens:
155
  if image is None:
156
  yield "Please upload an image.", "Please upload an image."
157
  return
158
-
159
- text_prompt = prompt_input
160
-
161
  if model_name == "Camel-Doc-OCR-080125":
162
  processor, model = processor_m, model_m
163
  elif model_name == "Megalodon-OCR-Sync-0713":
@@ -172,7 +170,7 @@ def process_document_stream(model_name: str, image: Image.Image, max_new_tokens:
172
  yield "Invalid model selected.", "Invalid model selected."
173
  return
174
 
175
- messages = [{"role": "user", "content": [{"type": "image", "image": image}, {"type": "text", "text": text_prompt}]}]
176
  prompt_full = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
177
  inputs = processor(text=[prompt_full], images=[image], return_tensors="pt", padding=True, truncation=True, max_length=MAX_INPUT_TOKEN_LENGTH).to(device)
178
  streamer = TextIteratorStreamer(processor, skip_prompt=True, skip_special_tokens=True)
 
155
  if image is None:
156
  yield "Please upload an image.", "Please upload an image."
157
  return
158
+
 
 
159
  if model_name == "Camel-Doc-OCR-080125":
160
  processor, model = processor_m, model_m
161
  elif model_name == "Megalodon-OCR-Sync-0713":
 
170
  yield "Invalid model selected.", "Invalid model selected."
171
  return
172
 
173
+ messages = [{"role": "user", "content": [{"type": "image", "image": image}, {"type": "text", "text": prompt_input}]}]
174
  prompt_full = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
175
  inputs = processor(text=[prompt_full], images=[image], return_tensors="pt", padding=True, truncation=True, max_length=MAX_INPUT_TOKEN_LENGTH).to(device)
176
  streamer = TextIteratorStreamer(processor, skip_prompt=True, skip_special_tokens=True)