Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -46,6 +46,17 @@ model_2 = Qwen2_5_VLForConditionalGeneration.from_pretrained(
|
|
| 46 |
).to(device).eval()
|
| 47 |
logger.info(f"Model '{MODEL_ID_2}' loaded successfully.")
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
@spaces.GPU
|
| 50 |
def parse_page(image: Image.Image, model_name: str) -> str:
|
| 51 |
"""
|
|
@@ -55,6 +66,8 @@ def parse_page(image: Image.Image, model_name: str) -> str:
|
|
| 55 |
current_processor, current_model = processor_1, model_1
|
| 56 |
elif model_name == "Gliese-OCR-7B-Post1.0":
|
| 57 |
current_processor, current_model = processor_2, model_2
|
|
|
|
|
|
|
| 58 |
else:
|
| 59 |
raise ValueError(f"Unknown model choice: {model_name}")
|
| 60 |
|
|
@@ -246,7 +259,7 @@ def main():
|
|
| 246 |
|
| 247 |
with gr.Row(elem_classes=["main-container"]):
|
| 248 |
with gr.Column(scale=1):
|
| 249 |
-
model_choice = gr.Dropdown(choices=["Logics-Parsing", "Gliese-OCR-7B-Post1.0"], label="Select Model⚡️", value="Logics-Parsing")
|
| 250 |
file_input = gr.File(label="Upload PDF or Image", file_types=[".pdf", ".jpg", ".jpeg", ".png"], type="filepath")
|
| 251 |
image_preview = gr.Image(label="Preview", type="pil", interactive=False, height=280)
|
| 252 |
|
|
|
|
| 46 |
).to(device).eval()
|
| 47 |
logger.info(f"Model '{MODEL_ID_2}' loaded successfully.")
|
| 48 |
|
| 49 |
+
# Model 3: ERGO-7B
|
| 50 |
+
MODEL_ID_3 = "nota-ai/ERGO-7B"
|
| 51 |
+
logger.info(f"Loading model 3: {MODEL_ID_3}")
|
| 52 |
+
processor_3 = AutoProcessor.from_pretrained(MODEL_ID_3, trust_remote_code=True)
|
| 53 |
+
model_3 = Qwen2_5_VLForConditionalGeneration.from_pretrained(
|
| 54 |
+
MODEL_ID_3,
|
| 55 |
+
trust_remote_code=True,
|
| 56 |
+
torch_dtype=torch.float16 if device == "cuda" else torch.float32
|
| 57 |
+
).to(device).eval()
|
| 58 |
+
logger.info(f"Model '{MODEL_ID_3}' loaded successfully.")
|
| 59 |
+
|
| 60 |
@spaces.GPU
|
| 61 |
def parse_page(image: Image.Image, model_name: str) -> str:
|
| 62 |
"""
|
|
|
|
| 66 |
current_processor, current_model = processor_1, model_1
|
| 67 |
elif model_name == "Gliese-OCR-7B-Post1.0":
|
| 68 |
current_processor, current_model = processor_2, model_2
|
| 69 |
+
elif model_name == "ERGO-7B":
|
| 70 |
+
current_processor, current_model = processor_3, model_3
|
| 71 |
else:
|
| 72 |
raise ValueError(f"Unknown model choice: {model_name}")
|
| 73 |
|
|
|
|
| 259 |
|
| 260 |
with gr.Row(elem_classes=["main-container"]):
|
| 261 |
with gr.Column(scale=1):
|
| 262 |
+
model_choice = gr.Dropdown(choices=["Logics-Parsing", "Gliese-OCR-7B-Post1.0", "ERGO-7B"], label="Select Model⚡️", value="Logics-Parsing")
|
| 263 |
file_input = gr.File(label="Upload PDF or Image", file_types=[".pdf", ".jpg", ".jpeg", ".png"], type="filepath")
|
| 264 |
image_preview = gr.Image(label="Preview", type="pil", interactive=False, height=280)
|
| 265 |
|