Spaces:
Running
on
Zero
Running
on
Zero
update app (#11)
Browse files- update app (2fb3741535b46a9c3b4bb28c9a506c0a2fa21656)
app.py
CHANGED
@@ -144,6 +144,12 @@ model_v = Qwen2_5_VLForConditionalGeneration.from_pretrained(
|
|
144 |
MODEL_ID_V, trust_remote_code=True, torch_dtype=torch.float16
|
145 |
).to(device).eval()
|
146 |
|
|
|
|
|
|
|
|
|
|
|
|
|
147 |
# --- PDF Generation and Preview Utility Function ---
|
148 |
def generate_and_preview_pdf(image: Image.Image, text_content: str, font_size: int, line_spacing: float, alignment: str, image_size: str):
|
149 |
"""
|
@@ -255,7 +261,8 @@ def process_document_stream(
|
|
255 |
elif model_name == "Qwen2.5-VL-3B-Abliterated-Caption-it(caption)": processor, model = processor_n, model_n
|
256 |
elif model_name == "LMM-R1-MGT-PerceReason(reason)": processor, model = processor_f, model_f
|
257 |
elif model_name == "TBAC-VLR1-3B(open-r1)": processor, model = processor_g, model_g
|
258 |
-
elif model_name == "OCRFlux-3B(ocr)": processor, model = processor_v,
|
|
|
259 |
else:
|
260 |
yield "Invalid model selected.", ""
|
261 |
return
|
@@ -314,7 +321,7 @@ def create_gradio_interface():
|
|
314 |
model_choice = gr.Dropdown(
|
315 |
choices=["LFM2-VL-450M(fast)", "LFM2-VL-1.6B(fast)", "SmolVLM-Instruct-250M(smol)", "Moondream2(vision)", "ShotVL-3B(cinematic)", "Megalodon-OCR-Sync-0713(ocr)",
|
316 |
"VLAA-Thinker-Qwen2VL-2B(reason)", "MonkeyOCR-pro-1.2B(ocr)", "Qwen2.5-VL-3B-Abliterated-Caption-it(caption)", "Nanonets-OCR-s(ocr)",
|
317 |
-
"LMM-R1-MGT-PerceReason(reason)", "OCRFlux-3B(ocr)", "TBAC-VLR1-3B(open-r1)"],
|
318 |
label="Select Model", value= "LFM2-VL-450M(fast)"
|
319 |
)
|
320 |
prompt_input = gr.Textbox(label="Query Input", placeholder="✦︎ Enter your query", value="Describe the image!")
|
|
|
144 |
MODEL_ID_V, trust_remote_code=True, torch_dtype=torch.float16
|
145 |
).to(device).eval()
|
146 |
|
147 |
+
MODEL_ID_O = "HuggingFaceTB/SmolVLM-500M-Instruct"
|
148 |
+
processor_o = AutoProcessor.from_pretrained(MODEL_ID_O, trust_remote_code=True)
|
149 |
+
model_o = AutoModelForVision2Seq.from_pretrained(
|
150 |
+
MODEL_ID_O, trust_remote_code=True, torch_dtype=torch.float16, _attn_implementation="flash_attention_2"
|
151 |
+
).to(device).eval()
|
152 |
+
|
153 |
# --- PDF Generation and Preview Utility Function ---
|
154 |
def generate_and_preview_pdf(image: Image.Image, text_content: str, font_size: int, line_spacing: float, alignment: str, image_size: str):
|
155 |
"""
|
|
|
261 |
elif model_name == "Qwen2.5-VL-3B-Abliterated-Caption-it(caption)": processor, model = processor_n, model_n
|
262 |
elif model_name == "LMM-R1-MGT-PerceReason(reason)": processor, model = processor_f, model_f
|
263 |
elif model_name == "TBAC-VLR1-3B(open-r1)": processor, model = processor_g, model_g
|
264 |
+
elif model_name == "OCRFlux-3B(ocr)": processor, model = processor_v, model_v
|
265 |
+
elif model_name == "SmolVLM-500M-Instruct(smol)": processor, model = processor_o, model_o
|
266 |
else:
|
267 |
yield "Invalid model selected.", ""
|
268 |
return
|
|
|
321 |
model_choice = gr.Dropdown(
|
322 |
choices=["LFM2-VL-450M(fast)", "LFM2-VL-1.6B(fast)", "SmolVLM-Instruct-250M(smol)", "Moondream2(vision)", "ShotVL-3B(cinematic)", "Megalodon-OCR-Sync-0713(ocr)",
|
323 |
"VLAA-Thinker-Qwen2VL-2B(reason)", "MonkeyOCR-pro-1.2B(ocr)", "Qwen2.5-VL-3B-Abliterated-Caption-it(caption)", "Nanonets-OCR-s(ocr)",
|
324 |
+
"LMM-R1-MGT-PerceReason(reason)", "OCRFlux-3B(ocr)", "TBAC-VLR1-3B(open-r1)", "SmolVLM-500M-Instruct(smol)"],
|
325 |
label="Select Model", value= "LFM2-VL-450M(fast)"
|
326 |
)
|
327 |
prompt_input = gr.Textbox(label="Query Input", placeholder="✦︎ Enter your query", value="Describe the image!")
|