Update app.py
Browse files
app.py
CHANGED
|
@@ -194,22 +194,8 @@ def recognize_single_line(image):
|
|
| 194 |
return f"Error: {str(e)}", ""
|
| 195 |
|
| 196 |
|
| 197 |
-
# Custom CSS
|
| 198 |
-
css = """
|
| 199 |
-
.gradio-container {
|
| 200 |
-
font-family: 'Inter', sans-serif;
|
| 201 |
-
}
|
| 202 |
-
.output-text {
|
| 203 |
-
font-size: 16px;
|
| 204 |
-
line-height: 1.6;
|
| 205 |
-
}
|
| 206 |
-
footer {
|
| 207 |
-
visibility: hidden;
|
| 208 |
-
}
|
| 209 |
-
"""
|
| 210 |
-
|
| 211 |
# Create Gradio interface
|
| 212 |
-
with gr.Blocks(
|
| 213 |
gr.Markdown(
|
| 214 |
"""
|
| 215 |
# 🔤 Kiri OCR
|
|
@@ -250,8 +236,7 @@ with gr.Blocks(css=css, title="Kiri OCR - Khmer & English OCR") as demo:
|
|
| 250 |
doc_output_img = gr.Image(label="Detected Regions")
|
| 251 |
doc_output_text = gr.Textbox(
|
| 252 |
label="Extracted Text",
|
| 253 |
-
lines=10
|
| 254 |
-
show_copy_button=True
|
| 255 |
)
|
| 256 |
|
| 257 |
with gr.Accordion("Detailed Results", open=False):
|
|
@@ -262,18 +247,6 @@ with gr.Blocks(css=css, title="Kiri OCR - Khmer & English OCR") as demo:
|
|
| 262 |
inputs=[doc_input, mode_select, show_boxes],
|
| 263 |
outputs=[doc_output_img, doc_output_text, doc_details]
|
| 264 |
)
|
| 265 |
-
|
| 266 |
-
# Examples
|
| 267 |
-
gr.Examples(
|
| 268 |
-
examples=[
|
| 269 |
-
["assets/sample_khmer.png"],
|
| 270 |
-
["assets/sample_english.png"],
|
| 271 |
-
],
|
| 272 |
-
inputs=doc_input,
|
| 273 |
-
outputs=[doc_output_img, doc_output_text, doc_details],
|
| 274 |
-
fn=process_image,
|
| 275 |
-
cache_examples=False
|
| 276 |
-
) if False else None # Disabled - add your own example images
|
| 277 |
|
| 278 |
# Single Line OCR Tab
|
| 279 |
with gr.TabItem("✏️ Single Line OCR"):
|
|
@@ -291,8 +264,7 @@ with gr.Blocks(css=css, title="Kiri OCR - Khmer & English OCR") as demo:
|
|
| 291 |
with gr.Column(scale=1):
|
| 292 |
line_output_text = gr.Textbox(
|
| 293 |
label="Recognized Text",
|
| 294 |
-
lines=3
|
| 295 |
-
show_copy_button=True
|
| 296 |
)
|
| 297 |
line_confidence = gr.Textbox(label="Confidence")
|
| 298 |
|
|
|
|
| 194 |
return f"Error: {str(e)}", ""
|
| 195 |
|
| 196 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
# Create Gradio interface
|
| 198 |
+
with gr.Blocks(title="Kiri OCR - Khmer & English OCR") as demo:
|
| 199 |
gr.Markdown(
|
| 200 |
"""
|
| 201 |
# 🔤 Kiri OCR
|
|
|
|
| 236 |
doc_output_img = gr.Image(label="Detected Regions")
|
| 237 |
doc_output_text = gr.Textbox(
|
| 238 |
label="Extracted Text",
|
| 239 |
+
lines=10
|
|
|
|
| 240 |
)
|
| 241 |
|
| 242 |
with gr.Accordion("Detailed Results", open=False):
|
|
|
|
| 247 |
inputs=[doc_input, mode_select, show_boxes],
|
| 248 |
outputs=[doc_output_img, doc_output_text, doc_details]
|
| 249 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 250 |
|
| 251 |
# Single Line OCR Tab
|
| 252 |
with gr.TabItem("✏️ Single Line OCR"):
|
|
|
|
| 264 |
with gr.Column(scale=1):
|
| 265 |
line_output_text = gr.Textbox(
|
| 266 |
label="Recognized Text",
|
| 267 |
+
lines=3
|
|
|
|
| 268 |
)
|
| 269 |
line_confidence = gr.Textbox(label="Confidence")
|
| 270 |
|