Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -12,8 +12,6 @@ import json
|
|
12 |
try:
|
13 |
model = load_model('wound_classifier_model_googlenet.h5')
|
14 |
print("✅ Model loaded successfully")
|
15 |
-
print(f"ℹ️ Input shape: {model.input_shape}")
|
16 |
-
print(f"ℹ️ Output shape: {model.output_shape}")
|
17 |
except Exception as e:
|
18 |
raise RuntimeError(f"❌ Model loading failed: {str(e)}")
|
19 |
|
@@ -116,21 +114,51 @@ def predict(image):
|
|
116 |
return {f"🚨 Error": str(e)}, ""
|
117 |
|
118 |
# ================== GRADIO INTERFACE ==================
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
gr.
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
if __name__ == "__main__":
|
136 |
-
iface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
try:
|
13 |
model = load_model('wound_classifier_model_googlenet.h5')
|
14 |
print("✅ Model loaded successfully")
|
|
|
|
|
15 |
except Exception as e:
|
16 |
raise RuntimeError(f"❌ Model loading failed: {str(e)}")
|
17 |
|
|
|
114 |
return {f"🚨 Error": str(e)}, ""
|
115 |
|
116 |
# ================== GRADIO INTERFACE ==================
|
117 |
+
def create_interface():
|
118 |
+
with gr.Blocks(title="AI Wound Classifier") as demo:
|
119 |
+
gr.Markdown("# 🩹 AI-Powered Wound Classification System")
|
120 |
+
gr.Markdown("Upload a wound image or take a photo using your camera")
|
121 |
+
|
122 |
+
with gr.Tabs():
|
123 |
+
with gr.TabItem("📤 Upload Image"):
|
124 |
+
file_input = gr.Image(type="pil", label="Upload Wound Image")
|
125 |
+
|
126 |
+
with gr.TabItem("📷 Use Camera"):
|
127 |
+
webcam_input = gr.Image(
|
128 |
+
source="webcam",
|
129 |
+
streaming=False,
|
130 |
+
mirror_webcam=False,
|
131 |
+
label="Take Wound Photo",
|
132 |
+
type="pil"
|
133 |
+
)
|
134 |
+
|
135 |
+
with gr.Row():
|
136 |
+
submit_btn = gr.Button("Analyze Now", variant="primary")
|
137 |
+
|
138 |
+
with gr.Row():
|
139 |
+
output_label = gr.Label(label="Top Predictions", num_top_classes=3)
|
140 |
+
output_guidelines = gr.Textbox(label="Treatment Guidelines", lines=8)
|
141 |
+
|
142 |
+
# Connect both input methods to same processing
|
143 |
+
submit_btn.click(
|
144 |
+
fn=predict,
|
145 |
+
inputs=[file_input],
|
146 |
+
outputs=[output_label, output_guidelines]
|
147 |
+
)
|
148 |
+
|
149 |
+
webcam_input.change(
|
150 |
+
fn=predict,
|
151 |
+
inputs=[webcam_input],
|
152 |
+
outputs=[output_label, output_guidelines]
|
153 |
+
)
|
154 |
+
|
155 |
+
return demo
|
156 |
|
157 |
if __name__ == "__main__":
|
158 |
+
iface = create_interface()
|
159 |
+
iface.launch(
|
160 |
+
server_name="0.0.0.0",
|
161 |
+
server_port=7860,
|
162 |
+
enable_queue=True,
|
163 |
+
share=False # Set to True if you want a public link
|
164 |
+
)
|