Spaces:
Running
on
Zero
Running
on
Zero
Upload folder using huggingface_hub
Browse files- README.md +8 -0
- app.py +5 -4
- requirements.txt +1 -1
README.md
CHANGED
@@ -11,3 +11,11 @@ license: apache-2.0
|
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
14 |
+
|
15 |
+
## Run locally
|
16 |
+
|
17 |
+
```bash
|
18 |
+
cd demo
|
19 |
+
pip install -r requirements.txt
|
20 |
+
python3 app.py
|
21 |
+
```
|
app.py
CHANGED
@@ -6,11 +6,12 @@ import gradio as gr
|
|
6 |
import matplotlib.pyplot as plt
|
7 |
import numpy as np
|
8 |
from matplotlib.figure import Figure
|
|
|
|
|
9 |
from onnxtr.io import DocumentFile
|
10 |
from onnxtr.models import ocr_predictor
|
11 |
from onnxtr.models.predictor import OCRPredictor
|
12 |
from onnxtr.utils.visualization import visualize_page
|
13 |
-
from PIL import Image
|
14 |
|
15 |
DET_ARCHS: List[str] = [
|
16 |
"fast_base",
|
@@ -103,7 +104,7 @@ def forward_image(predictor: OCRPredictor, image: np.ndarray) -> np.ndarray:
|
|
103 |
|
104 |
|
105 |
def matplotlib_to_pil(fig: Union[Figure, np.ndarray]) -> Image.Image:
|
106 |
-
"""
|
107 |
|
108 |
Args:
|
109 |
----
|
@@ -136,7 +137,7 @@ def analyze_page(
|
|
136 |
bin_thresh: float,
|
137 |
box_thresh: float,
|
138 |
):
|
139 |
-
"""
|
140 |
|
141 |
Args:
|
142 |
----
|
@@ -267,4 +268,4 @@ with gr.Blocks(fill_height=True) as demo:
|
|
267 |
outputs=[input_image, segmentation_heatmap, output_image, ocr_output],
|
268 |
)
|
269 |
|
270 |
-
demo.launch(inbrowser=True, allowed_paths=[
|
|
|
6 |
import matplotlib.pyplot as plt
|
7 |
import numpy as np
|
8 |
from matplotlib.figure import Figure
|
9 |
+
from PIL import Image
|
10 |
+
|
11 |
from onnxtr.io import DocumentFile
|
12 |
from onnxtr.models import ocr_predictor
|
13 |
from onnxtr.models.predictor import OCRPredictor
|
14 |
from onnxtr.utils.visualization import visualize_page
|
|
|
15 |
|
16 |
DET_ARCHS: List[str] = [
|
17 |
"fast_base",
|
|
|
104 |
|
105 |
|
106 |
def matplotlib_to_pil(fig: Union[Figure, np.ndarray]) -> Image.Image:
|
107 |
+
"""Convert a matplotlib figure to a PIL image
|
108 |
|
109 |
Args:
|
110 |
----
|
|
|
137 |
bin_thresh: float,
|
138 |
box_thresh: float,
|
139 |
):
|
140 |
+
"""Analyze a page
|
141 |
|
142 |
Args:
|
143 |
----
|
|
|
268 |
outputs=[input_image, segmentation_heatmap, output_image, ocr_output],
|
269 |
)
|
270 |
|
271 |
+
demo.launch(inbrowser=True, allowed_paths=["./data/logo.jpg"])
|
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-e git+https://github.com/felixdittrich92/OnnxTR.git#egg=onnxtr[cpu-headless,viz]
|
2 |
-
gradio>=4.37.1,<
|
|
|
1 |
-e git+https://github.com/felixdittrich92/OnnxTR.git#egg=onnxtr[cpu-headless,viz]
|
2 |
+
gradio>=4.37.1,<6.0.0
|