Ramzan0553 commited on
Commit
c6b3050
·
verified ·
1 Parent(s): 3200fc7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +64 -27
app.py CHANGED
@@ -91,32 +91,69 @@ def infer(image):
91
  return Image.fromarray(annotated_img), result_text
92
 
93
  # ========== Gradio UI ==========
94
- custom_css = """
95
- body {
96
- background-color: #e6f2ff;
97
- }
98
- .gradio-container {
99
- border-radius: 12px;
100
- padding: 20px;
101
- border: 2px solid #007acc;
102
- }
103
- .gr-input, .gr-output {
104
- border: 1px solid #007acc;
105
- border-radius: 10px;
106
- }
107
- """
108
-
109
- demo = gr.Interface(
110
- fn=infer,
111
- inputs=gr.Image(type="pil", label="Upload Image"),
112
- outputs=[
113
- gr.Image(type="pil", label="Annotated Image"),
114
- gr.Textbox(label="Detected Text and Classification")
115
- ],
116
- title="Text Detection and Classification",
117
- description="Application detects text from images and classify into Handwritten/Computerized Text",
118
- theme="soft",
119
- css=custom_css
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()