Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -159,29 +159,41 @@ def extract_fields(image):
|
|
159 |
|
160 |
|
161 |
# -------------------- Gradio Interface --------------------
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
gr.
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
|
185 |
if __name__ == "__main__":
|
186 |
-
|
|
|
187 |
|
|
|
159 |
|
160 |
|
161 |
# -------------------- Gradio Interface --------------------
|
162 |
+
def extract_fields(image):
|
163 |
+
# Your full function definition goes here
|
164 |
+
return ["Name", "Email", "Phone", "DOB", "Postcode", "Prem", "Rate", "Functions"]
|
165 |
+
|
166 |
+
with gr.Blocks() as demo:
|
167 |
+
gr.Markdown("## π Image OCR Field Extractor")
|
168 |
+
gr.Markdown("Upload a document image to extract structured data fields.")
|
169 |
+
|
170 |
+
with gr.Row():
|
171 |
+
with gr.Column():
|
172 |
+
image_input = gr.Image(type="pil", label="π€ Upload Your Document")
|
173 |
+
submit_btn = gr.Button("π Run Detection")
|
174 |
+
|
175 |
+
# β
One Example Image that auto-fills input when clicked
|
176 |
+
gr.Examples(
|
177 |
+
examples=["example_doc.jpeg"], # Just one image
|
178 |
+
inputs=[image_input],
|
179 |
+
label="π Example Image (Click to load)"
|
180 |
+
)
|
181 |
+
|
182 |
+
with gr.Column():
|
183 |
+
name = gr.Text(label="Name")
|
184 |
+
email = gr.Text(label="Email")
|
185 |
+
phone = gr.Text(label="Phone")
|
186 |
+
dob = gr.Text(label="DOB")
|
187 |
+
postcode = gr.Text(label="Postcode")
|
188 |
+
prem = gr.Text(label="Prem (CurBase)")
|
189 |
+
rate = gr.Text(label="Temp (Hourly Rate)")
|
190 |
+
functions = gr.Textbox(label="Functions", lines=4)
|
191 |
+
|
192 |
+
# π Link button to function
|
193 |
+
submit_btn.click(fn=extract_fields, inputs=image_input,
|
194 |
+
outputs=[name, email, phone, dob, postcode, prem, rate, functions])
|
195 |
|
196 |
if __name__ == "__main__":
|
197 |
+
demo.launch()
|
198 |
+
|
199 |
|