Spaces:
Running
on
Zero
Running
on
Zero
Liam Dyer
commited on
temp
Browse files
app.py
CHANGED
@@ -2,10 +2,27 @@ import spaces
|
|
2 |
import gradio as gr
|
3 |
from marker.convert import convert_single_pdf
|
4 |
from marker.models import load_all_models
|
|
|
5 |
|
6 |
model_lst = load_all_models()
|
7 |
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
@spaces.GPU
|
10 |
def convert(file_path):
|
11 |
print(file_path)
|
|
|
2 |
import gradio as gr
|
3 |
from marker.convert import convert_single_pdf
|
4 |
from marker.models import load_all_models
|
5 |
+
import surya.detection as detection
|
6 |
|
7 |
model_lst = load_all_models()
|
8 |
|
9 |
|
10 |
+
# Monkey patch to prevent spawning processes
|
11 |
+
def batch_text_detection(images, model, processor, batch_size=None):
|
12 |
+
preds, orig_sizes = detection.batch_detection(
|
13 |
+
images, model, processor, batch_size=batch_size
|
14 |
+
)
|
15 |
+
results = []
|
16 |
+
for i in range(len(images)):
|
17 |
+
result = detection.parallel_get_lines(preds[i], orig_sizes[i])
|
18 |
+
results.append(result)
|
19 |
+
|
20 |
+
return results
|
21 |
+
|
22 |
+
|
23 |
+
detection.batch_text_detection = batch_text_detection
|
24 |
+
|
25 |
+
|
26 |
@spaces.GPU
|
27 |
def convert(file_path):
|
28 |
print(file_path)
|