Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
edd2900
1
Parent(s):
d9ed702
app.py
CHANGED
|
@@ -9,6 +9,7 @@ import tempfile
|
|
| 9 |
import shutil
|
| 10 |
import json
|
| 11 |
from datetime import datetime
|
|
|
|
| 12 |
|
| 13 |
# List of available models with their IDs and prompts
|
| 14 |
MODELS = {
|
|
@@ -175,8 +176,17 @@ def process_image(model_name, image, progress=gr.Progress()):
|
|
| 175 |
if model_name != current_model_name:
|
| 176 |
progress(0, desc="Loading model...")
|
| 177 |
load_model(model_name)
|
| 178 |
-
|
| 179 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
|
| 181 |
@spaces.GPU
|
| 182 |
def process_pdf(pdf_path, model_name, progress=gr.Progress()):
|
|
|
|
| 9 |
import shutil
|
| 10 |
import json
|
| 11 |
from datetime import datetime
|
| 12 |
+
import numpy as np
|
| 13 |
|
| 14 |
# List of available models with their IDs and prompts
|
| 15 |
MODELS = {
|
|
|
|
| 176 |
if model_name != current_model_name:
|
| 177 |
progress(0, desc="Loading model...")
|
| 178 |
load_model(model_name)
|
| 179 |
+
|
| 180 |
+
if isinstance(image, np.ndarray):
|
| 181 |
+
image = Image.fromarray(image)
|
| 182 |
+
|
| 183 |
+
width, height = image.size
|
| 184 |
+
print(f"Image dimensions: {width}x{height}")
|
| 185 |
+
|
| 186 |
+
if height > 50:
|
| 187 |
+
return process_multi_line(image, model_name, progress)
|
| 188 |
+
else:
|
| 189 |
+
return process_single_line(image, model_name), [image]
|
| 190 |
|
| 191 |
@spaces.GPU
|
| 192 |
def process_pdf(pdf_path, model_name, progress=gr.Progress()):
|