Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,11 +3,36 @@ import degirum as dg
|
|
| 3 |
import degirum_tools
|
| 4 |
from PIL import Image
|
| 5 |
|
|
|
|
|
|
|
|
|
|
| 6 |
st.set_page_config(
|
| 7 |
page_title="Paddle OCR with DeGirum / Hailo",
|
| 8 |
page_icon="📝",
|
| 9 |
)
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
st.title("Paddle OCR Text Detection and Recognition")
|
| 12 |
st.write(
|
| 13 |
"Upload an image containing text and click **Run OCR** to detect text regions "
|
|
@@ -17,9 +42,9 @@ st.write(
|
|
| 17 |
# -----------------------
|
| 18 |
# Hardcoded configuration
|
| 19 |
# -----------------------
|
| 20 |
-
INFERENCE_HOST_ADDRESS = "@
|
| 21 |
-
ZOO_URL = "degirum/hailo"
|
| 22 |
-
DEVICE_TYPE = ["HAILORT/HAILO8"]
|
| 23 |
|
| 24 |
PADDLE_OCR_DET_MODEL_NAME = "paddle_ocr_detection--544x960_quant_hailort_hailo8_1"
|
| 25 |
PADDLE_OCR_REC_MODEL_NAME = "paddle_ocr_recognition--48x320_quant_hailort_hailo8_1"
|
|
@@ -67,6 +92,9 @@ crop_model = load_crop_model()
|
|
| 67 |
|
| 68 |
st.text("Upload an image. Then click on the Run OCR button.")
|
| 69 |
|
|
|
|
|
|
|
|
|
|
| 70 |
with st.form("ocr_form"):
|
| 71 |
uploaded_file = st.file_uploader(
|
| 72 |
"Input image",
|
|
@@ -92,7 +120,6 @@ with st.form("ocr_form"):
|
|
| 92 |
caption="Image with detected text regions",
|
| 93 |
)
|
| 94 |
|
| 95 |
-
|
| 96 |
# Show structured results
|
| 97 |
st.subheader("OCR Results")
|
| 98 |
try:
|
|
|
|
| 3 |
import degirum_tools
|
| 4 |
from PIL import Image
|
| 5 |
|
| 6 |
+
# -----------------------
|
| 7 |
+
# Page config
|
| 8 |
+
# -----------------------
|
| 9 |
st.set_page_config(
|
| 10 |
page_title="Paddle OCR with DeGirum / Hailo",
|
| 11 |
page_icon="📝",
|
| 12 |
)
|
| 13 |
|
| 14 |
+
# -----------------------
|
| 15 |
+
# Sidebar content
|
| 16 |
+
# -----------------------
|
| 17 |
+
st.sidebar.title("Paddle OCR Demo")
|
| 18 |
+
st.sidebar.markdown(
|
| 19 |
+
"""
|
| 20 |
+
## Instructions
|
| 21 |
+
1. Upload an image containing text
|
| 22 |
+
2. Click **Run OCR**
|
| 23 |
+
3. View detected text boxes and recognized text
|
| 24 |
+
|
| 25 |
+
---
|
| 26 |
+
**Backend:**
|
| 27 |
+
- Inference: `@local` (Hailo)
|
| 28 |
+
- Zoo: `degirum/hailo`
|
| 29 |
+
- Device: `HAILORT/HAILO8`
|
| 30 |
+
"""
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
# -----------------------
|
| 34 |
+
# Main page content
|
| 35 |
+
# -----------------------
|
| 36 |
st.title("Paddle OCR Text Detection and Recognition")
|
| 37 |
st.write(
|
| 38 |
"Upload an image containing text and click **Run OCR** to detect text regions "
|
|
|
|
| 42 |
# -----------------------
|
| 43 |
# Hardcoded configuration
|
| 44 |
# -----------------------
|
| 45 |
+
INFERENCE_HOST_ADDRESS = "@local" # local Hailo server
|
| 46 |
+
ZOO_URL = "degirum/hailo" # Hailo model zoo
|
| 47 |
+
DEVICE_TYPE = ["HAILORT/HAILO8"] # must be a list
|
| 48 |
|
| 49 |
PADDLE_OCR_DET_MODEL_NAME = "paddle_ocr_detection--544x960_quant_hailort_hailo8_1"
|
| 50 |
PADDLE_OCR_REC_MODEL_NAME = "paddle_ocr_recognition--48x320_quant_hailort_hailo8_1"
|
|
|
|
| 92 |
|
| 93 |
st.text("Upload an image. Then click on the Run OCR button.")
|
| 94 |
|
| 95 |
+
# -----------------------
|
| 96 |
+
# Form: upload + run OCR
|
| 97 |
+
# -----------------------
|
| 98 |
with st.form("ocr_form"):
|
| 99 |
uploaded_file = st.file_uploader(
|
| 100 |
"Input image",
|
|
|
|
| 120 |
caption="Image with detected text regions",
|
| 121 |
)
|
| 122 |
|
|
|
|
| 123 |
# Show structured results
|
| 124 |
st.subheader("OCR Results")
|
| 125 |
try:
|