Update app.py
Browse files
app.py
CHANGED
|
@@ -91,32 +91,69 @@ def infer(image):
|
|
| 91 |
return Image.fromarray(annotated_img), result_text
|
| 92 |
|
| 93 |
# ========== Gradio UI ==========
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
gr
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
|
| 122 |
demo.launch()
|
|
|
|
| 91 |
return Image.fromarray(annotated_img), result_text
|
| 92 |
|
| 93 |
# ========== Gradio UI ==========
|
| 94 |
+
with gr.Blocks(
|
| 95 |
+
title="Text Type Classifier",
|
| 96 |
+
css="""
|
| 97 |
+
body {
|
| 98 |
+
background-color: #C0C0C0 !important;
|
| 99 |
+
}
|
| 100 |
+
.outer-box {
|
| 101 |
+
border: 8px solid black;
|
| 102 |
+
border-radius: 16px;
|
| 103 |
+
padding: 24px;
|
| 104 |
+
background-color: white;
|
| 105 |
+
}
|
| 106 |
+
.gr-box {
|
| 107 |
+
border: 6px solid #0288d1 !important;
|
| 108 |
+
border-radius: 12px;
|
| 109 |
+
padding: 16px;
|
| 110 |
+
background-color: white;
|
| 111 |
+
box-shadow: 0px 2px 10px rgba(0,0,0,0.1);
|
| 112 |
+
}
|
| 113 |
+
.gr-button {
|
| 114 |
+
background-color: #0288d1 !important;
|
| 115 |
+
color: white !important;
|
| 116 |
+
font-weight: bold;
|
| 117 |
+
border-radius: 8px;
|
| 118 |
+
margin-top: 10px;
|
| 119 |
+
}
|
| 120 |
+
.gr-button:hover {
|
| 121 |
+
background-color: #01579b !important;
|
| 122 |
+
}
|
| 123 |
+
"""
|
| 124 |
+
) as demo:
|
| 125 |
+
|
| 126 |
+
with gr.Column(elem_classes=["outer-box"]):
|
| 127 |
+
|
| 128 |
+
gr.Markdown(
|
| 129 |
+
"""
|
| 130 |
+
<div style="text-align: center;">
|
| 131 |
+
<h1><strong>Handwritten vs Computerized Text Classifier</strong></h1>
|
| 132 |
+
</div>
|
| 133 |
+
""",
|
| 134 |
+
elem_classes=["gr-box"]
|
| 135 |
+
)
|
| 136 |
+
|
| 137 |
+
with gr.Row():
|
| 138 |
+
with gr.Column():
|
| 139 |
+
image_input = gr.Image(label="Upload Image", type="numpy", elem_classes=["gr-box"])
|
| 140 |
+
submit_btn = gr.Button("Process Image", elem_classes=["gr-box", "gr-button"])
|
| 141 |
+
clear_btn = gr.Button("Clear", elem_classes=["gr-box", "gr-button"])
|
| 142 |
+
|
| 143 |
+
with gr.Column():
|
| 144 |
+
image_output = gr.Image(label="Annotated Output", type="numpy", elem_classes=["gr-box"])
|
| 145 |
+
text_output = gr.Textbox(label="Detected Results", lines=10, elem_classes=["gr-box"])
|
| 146 |
+
|
| 147 |
+
submit_btn.click(
|
| 148 |
+
fn=infer,
|
| 149 |
+
inputs=image_input,
|
| 150 |
+
outputs=[image_output, text_output]
|
| 151 |
+
)
|
| 152 |
+
|
| 153 |
+
clear_btn.click(
|
| 154 |
+
fn=lambda: (None, None, ""),
|
| 155 |
+
inputs=[],
|
| 156 |
+
outputs=[image_input, image_output, text_output]
|
| 157 |
+
)
|
| 158 |
|
| 159 |
demo.launch()
|