Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -121,43 +121,31 @@ def detect_text(model_name, input_image, confidence_threshold):
|
|
| 121 |
# --- 4. GRADIO INTERFACE ---
|
| 122 |
# (This section remains exactly the same)
|
| 123 |
with gr.Blocks() as demo:
|
| 124 |
-
gr.Markdown("#
|
| 125 |
gr.Markdown(
|
| 126 |
-
"
|
| 127 |
-
"
|
| 128 |
)
|
| 129 |
|
| 130 |
with gr.Row():
|
| 131 |
with gr.Column():
|
| 132 |
-
input_image = gr.Image(type="numpy", label="
|
| 133 |
model_name = gr.Radio(
|
| 134 |
-
["tiny", "small"], label="
|
| 135 |
)
|
| 136 |
confidence_threshold = gr.Slider(
|
| 137 |
-
minimum=0.1, maximum=1.0, value=0.4, step=0.1, label="
|
| 138 |
)
|
| 139 |
-
detect_button = gr.Button("
|
| 140 |
|
| 141 |
with gr.Column():
|
| 142 |
-
output_image = gr.Image(type="numpy", label="
|
| 143 |
|
| 144 |
detect_button.click(
|
| 145 |
fn=detect_text,
|
| 146 |
inputs=[model_name, input_image, confidence_threshold],
|
| 147 |
outputs=output_image
|
| 148 |
)
|
| 149 |
-
|
| 150 |
-
gr.Examples(
|
| 151 |
-
examples=[
|
| 152 |
-
["example_vn.jpg", "small", 0.4],
|
| 153 |
-
["example_manga.jpg", "small", 0.4],
|
| 154 |
-
["example_manga.jpg", "tiny", 0.4]
|
| 155 |
-
],
|
| 156 |
-
inputs=[input_image, model_name, confidence_threshold],
|
| 157 |
-
outputs=output_image,
|
| 158 |
-
fn=detect_text,
|
| 159 |
-
cache_examples=False
|
| 160 |
-
)
|
| 161 |
|
| 162 |
# --- 5. LAUNCH THE APP ---
|
| 163 |
demo.launch()
|
|
|
|
| 121 |
# --- 4. GRADIO INTERFACE ---
|
| 122 |
# (This section remains exactly the same)
|
| 123 |
with gr.Blocks() as demo:
|
| 124 |
+
gr.Markdown("# meiki text detect v0")
|
| 125 |
gr.Markdown(
|
| 126 |
+
"upload an image and choose a model to detect horizontal and vertical text lines. "
|
| 127 |
+
"the **small** model is more accurate, especially for images with many text lines like manga, while the **tiny** model is much faster."
|
| 128 |
)
|
| 129 |
|
| 130 |
with gr.Row():
|
| 131 |
with gr.Column():
|
| 132 |
+
input_image = gr.Image(type="numpy", label="upload image")
|
| 133 |
model_name = gr.Radio(
|
| 134 |
+
["tiny", "small"], label="choose model", value="small"
|
| 135 |
)
|
| 136 |
confidence_threshold = gr.Slider(
|
| 137 |
+
minimum=0.1, maximum=1.0, value=0.4, step=0.1, label="confidence threshold"
|
| 138 |
)
|
| 139 |
+
detect_button = gr.Button("detect text", variant="primary")
|
| 140 |
|
| 141 |
with gr.Column():
|
| 142 |
+
output_image = gr.Image(type="numpy", label="result")
|
| 143 |
|
| 144 |
detect_button.click(
|
| 145 |
fn=detect_text,
|
| 146 |
inputs=[model_name, input_image, confidence_threshold],
|
| 147 |
outputs=output_image
|
| 148 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
# --- 5. LAUNCH THE APP ---
|
| 151 |
demo.launch()
|