stshanks commited on
Commit
ffedde7
·
verified ·
1 Parent(s): 0318ae9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -9
app.py CHANGED
@@ -1,6 +1,4 @@
1
  import os
2
- #os.environ["CUDA_VISIBLE_DEVICES"] = "-1" # Force TensorFlow to use CPU
3
-
4
  import gradio as gr
5
  import tensorflow as tf
6
  import numpy as np
@@ -63,13 +61,43 @@ def predict_text(image):
63
 
64
 
65
  # Gradio UI
66
- interface = gr.Interface(
67
- fn=predict_text,
68
- inputs=gr.Image(type="pil"),
69
- outputs="text",
70
- title="Handwritten Prescription OCR",
71
- description="Upload a prescription image, and the model will return the recognized text."
72
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
  if __name__ == "__main__":
75
  interface.launch()
 
1
  import os
 
 
2
  import gradio as gr
3
  import tensorflow as tf
4
  import numpy as np
 
61
 
62
 
63
  # Gradio UI
64
+ with gr.Blocks(theme=gr.themes.Soft()) as demo:
65
+
66
+ # Header
67
+ gr.Markdown(
68
+ """
69
+ <h1 style="text-align: center; color: #2F4F4F;">🏥 Prescription Recognition AI</h1>
70
+ <p style="text-align: center; font-size: 18px;">Upload or take a picture of a handwritten prescription. The AI will identify the drug name.</p>
71
+ <hr>
72
+ """,
73
+ elem_id="header"
74
+ )
75
+
76
+ with gr.Row():
77
+ with gr.Column():
78
+ gr.Markdown("### 📸 Upload or Capture an Image")
79
+ image_input = gr.Image(type="pil", tool="editor", label="Upload or Capture Prescription")
80
+
81
+ with gr.Column():
82
+ gr.Markdown("### 💊 Recognized Drug Name")
83
+ output_text = gr.Textbox(label="Predicted Drug Name", interactive=False)
84
+
85
+ # Process button
86
+ with gr.Row():
87
+ submit_button = gr.Button("🔍 Identify Prescription", variant="primary")
88
+
89
+ # On button click, predict the drug name
90
+ submit_button.click(fn=predict_text, inputs=image_input, outputs=output_text)
91
+
92
+ # Footer
93
+ gr.Markdown(
94
+ """
95
+ <hr>
96
+ <p style="text-align: center;">Developed by <strong>Your Name</strong> | Powered by AI & Gradio</p>
97
+ """,
98
+ elem_id="footer"
99
+ )
100
+
101
 
102
  if __name__ == "__main__":
103
  interface.launch()