Spaces:
Running
on
Zero
Running
on
Zero
Upload folder using huggingface_hub
Browse files- app.py +5 -5
- requirements.txt +1 -1
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import io
|
2 |
import os
|
3 |
-
from typing import Any
|
4 |
|
5 |
# NOTE: This is a fix to run the demo on the HuggingFace Zero GPU or CPU spaces
|
6 |
if os.environ.get("SPACES_ZERO_GPU") is not None:
|
@@ -28,7 +28,7 @@ from onnxtr.models import EngineConfig, from_hub, ocr_predictor
|
|
28 |
from onnxtr.models.predictor import OCRPredictor
|
29 |
from onnxtr.utils.visualization import visualize_page
|
30 |
|
31 |
-
DET_ARCHS:
|
32 |
"fast_base",
|
33 |
"fast_small",
|
34 |
"fast_tiny",
|
@@ -39,7 +39,7 @@ DET_ARCHS: List[str] = [
|
|
39 |
"linknet_resnet34",
|
40 |
"linknet_resnet50",
|
41 |
]
|
42 |
-
RECO_ARCHS:
|
43 |
"crnn_vgg16_bn",
|
44 |
"crnn_mobilenet_v3_small",
|
45 |
"crnn_mobilenet_v3_large",
|
@@ -50,7 +50,7 @@ RECO_ARCHS: List[str] = [
|
|
50 |
"parseq",
|
51 |
]
|
52 |
|
53 |
-
CUSTOM_RECO_ARCHS:
|
54 |
"Felix92/onnxtr-parseq-multilingual-v1",
|
55 |
]
|
56 |
|
@@ -134,7 +134,7 @@ def forward_image(predictor: OCRPredictor, image: np.ndarray) -> np.ndarray:
|
|
134 |
return seg_map
|
135 |
|
136 |
|
137 |
-
def matplotlib_to_pil(fig:
|
138 |
"""Convert a matplotlib figure to a PIL image
|
139 |
|
140 |
Args:
|
|
|
1 |
import io
|
2 |
import os
|
3 |
+
from typing import Any
|
4 |
|
5 |
# NOTE: This is a fix to run the demo on the HuggingFace Zero GPU or CPU spaces
|
6 |
if os.environ.get("SPACES_ZERO_GPU") is not None:
|
|
|
28 |
from onnxtr.models.predictor import OCRPredictor
|
29 |
from onnxtr.utils.visualization import visualize_page
|
30 |
|
31 |
+
DET_ARCHS: list[str] = [
|
32 |
"fast_base",
|
33 |
"fast_small",
|
34 |
"fast_tiny",
|
|
|
39 |
"linknet_resnet34",
|
40 |
"linknet_resnet50",
|
41 |
]
|
42 |
+
RECO_ARCHS: list[str] = [
|
43 |
"crnn_vgg16_bn",
|
44 |
"crnn_mobilenet_v3_small",
|
45 |
"crnn_mobilenet_v3_large",
|
|
|
50 |
"parseq",
|
51 |
]
|
52 |
|
53 |
+
CUSTOM_RECO_ARCHS: list[str] = [
|
54 |
"Felix92/onnxtr-parseq-multilingual-v1",
|
55 |
]
|
56 |
|
|
|
134 |
return seg_map
|
135 |
|
136 |
|
137 |
+
def matplotlib_to_pil(fig: Figure | np.ndarray) -> Image.Image:
|
138 |
"""Convert a matplotlib figure to a PIL image
|
139 |
|
140 |
Args:
|
requirements.txt
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
-e git+https://github.com/felixdittrich92/OnnxTR.git#egg=onnxtr[gpu-headless,viz]
|
2 |
-
gradio>=
|
3 |
spaces>=0.30.4
|
|
|
1 |
-e git+https://github.com/felixdittrich92/OnnxTR.git#egg=onnxtr[gpu-headless,viz]
|
2 |
+
gradio>=5.6.0,<6.0.0
|
3 |
spaces>=0.30.4
|