Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -55,11 +55,17 @@ def get_medical_guidelines(wound_type):
|
|
55 |
"HTTP-Referer": "https://huggingface.co/spaces/MahatirTusher/Wound_Treatment"
|
56 |
}
|
57 |
|
58 |
-
prompt = f"""
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
try:
|
65 |
print(f"📡 Sending API request for {wound_type}...")
|
@@ -113,16 +119,137 @@ def predict(image):
|
|
113 |
except Exception as e:
|
114 |
return {f"🚨 Error": str(e)}, ""
|
115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
# ================== GRADIO INTERFACE ==================
|
117 |
def create_interface():
|
118 |
-
with gr.Blocks(title="AI
|
119 |
-
|
120 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
|
127 |
# Connect input to processing
|
128 |
submit_btn.click(
|
@@ -138,5 +265,5 @@ if __name__ == "__main__":
|
|
138 |
iface.launch(
|
139 |
server_name="0.0.0.0",
|
140 |
server_port=7860,
|
141 |
-
share=True
|
142 |
-
)
|
|
|
55 |
"HTTP-Referer": "https://huggingface.co/spaces/MahatirTusher/Wound_Treatment"
|
56 |
}
|
57 |
|
58 |
+
prompt = f"""You are a medical expert providing guidance for a patient with {wound_type}.
|
59 |
+
First, briefly introduce what {wound_type} are and their typical characteristics.
|
60 |
+
Then, provide a comprehensive care guide including:
|
61 |
+
|
62 |
+
1. Immediate First Aid Steps
|
63 |
+
2. Home Care Instructions
|
64 |
+
3. Prevention Tips
|
65 |
+
4. Warning Signs (when to seek emergency care)
|
66 |
+
|
67 |
+
Format your response in clear sections with proper spacing. Use simple,
|
68 |
+
non-technical language that a general audience can understand."""
|
69 |
|
70 |
try:
|
71 |
print(f"📡 Sending API request for {wound_type}...")
|
|
|
119 |
except Exception as e:
|
120 |
return {f"🚨 Error": str(e)}, ""
|
121 |
|
122 |
+
# ================== CSS STYLES ==================
|
123 |
+
custom_css = """
|
124 |
+
.gradio-container {
|
125 |
+
font-family: 'Times New Roman', Times, serif;
|
126 |
+
}
|
127 |
+
|
128 |
+
.container {
|
129 |
+
background: rgba(255, 255, 255, 0.9);
|
130 |
+
border-radius: 20px;
|
131 |
+
padding: 2rem;
|
132 |
+
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
|
133 |
+
backdrop-filter: blur(4px);
|
134 |
+
border: 1px solid rgba(255, 255, 255, 0.18);
|
135 |
+
margin: 1rem 0;
|
136 |
+
}
|
137 |
+
|
138 |
+
.title {
|
139 |
+
color: #2D3748;
|
140 |
+
text-align: center;
|
141 |
+
font-size: 2.5rem;
|
142 |
+
margin-bottom: 1rem;
|
143 |
+
}
|
144 |
+
|
145 |
+
.subtitle {
|
146 |
+
color: #4A5568;
|
147 |
+
text-align: center;
|
148 |
+
font-size: 1.2rem;
|
149 |
+
margin-bottom: 2rem;
|
150 |
+
}
|
151 |
+
|
152 |
+
.warning {
|
153 |
+
background-color: #FED7D7;
|
154 |
+
border-left: 4px solid #F56565;
|
155 |
+
padding: 1rem;
|
156 |
+
margin: 1rem 0;
|
157 |
+
border-radius: 8px;
|
158 |
+
}
|
159 |
+
|
160 |
+
.info-section {
|
161 |
+
background-color: #E6F6FF;
|
162 |
+
border-radius: 12px;
|
163 |
+
padding: 1.5rem;
|
164 |
+
margin: 1rem 0;
|
165 |
+
}
|
166 |
+
"""
|
167 |
+
|
168 |
# ================== GRADIO INTERFACE ==================
|
169 |
def create_interface():
|
170 |
+
with gr.Blocks(css=custom_css, title="WoundWise AI") as demo:
|
171 |
+
# Logo and Introduction
|
172 |
+
gr.Image("logo.png", show_label=False, container=False)
|
173 |
+
gr.Markdown("# Welcome to WoundWise AI")
|
174 |
+
|
175 |
+
with gr.Box(class_name="container"):
|
176 |
+
gr.Markdown("""
|
177 |
+
In today's fast-paced world, early detection of medical conditions can be a game-changer.
|
178 |
+
WoundWise AI is a cutting-edge AI-powered wound classification system developed as part
|
179 |
+
of EarlyMed, an initiative by students of Vellore Institute of Technology. Our mission
|
180 |
+
is simple yet impactful: "Early Detection, Smarter Decision."
|
181 |
+
|
182 |
+
By leveraging deep learning, this system analyzes wound images to provide accurate
|
183 |
+
classifications and essential treatment guidelines. Whether it's a minor cut or a
|
184 |
+
serious skin condition, our AI assists in identifying potential risks, helping users
|
185 |
+
make informed health decisions at an early stage.
|
186 |
+
""")
|
187 |
+
|
188 |
+
# Main Interface
|
189 |
+
with gr.Box(class_name="container"):
|
190 |
+
gr.Markdown("## 📸 Upload or Capture Wound Image")
|
191 |
+
gr.Markdown("Use your device's camera or upload an existing image")
|
192 |
+
|
193 |
+
file_input = gr.Image(type="pil", label="Upload Wound Image")
|
194 |
+
submit_btn = gr.Button("Analyze Now", variant="primary")
|
195 |
+
|
196 |
+
# Example Images
|
197 |
+
gr.Examples(
|
198 |
+
examples=["abrasion.jpg", "burn.png", "bruise.png", "chicken-pox.png", "cut.png"],
|
199 |
+
inputs=file_input,
|
200 |
+
label="Example Images"
|
201 |
+
)
|
202 |
+
|
203 |
+
output_label = gr.Label(label="Analysis Results", num_top_classes=3)
|
204 |
+
output_guidelines = gr.Textbox(
|
205 |
+
label="Medical Guidelines",
|
206 |
+
lines=12,
|
207 |
+
elem_classes="guidelines-box"
|
208 |
+
)
|
209 |
+
|
210 |
+
# Why Care About Wounds
|
211 |
+
with gr.Box(class_name="info-section"):
|
212 |
+
gr.Markdown("""
|
213 |
+
## ⚠️ Why Wound Care Matters
|
214 |
+
|
215 |
+
Ignoring wounds can lead to serious complications:
|
216 |
+
- Risk of bacterial infection
|
217 |
+
- Delayed healing and scarring
|
218 |
+
- Chronic wound development
|
219 |
+
- Systemic health issues
|
220 |
+
- Increased medical costs
|
221 |
+
|
222 |
+
Early intervention and proper care are crucial for optimal healing and preventing complications.
|
223 |
+
""")
|
224 |
+
|
225 |
+
# How Our Model Works
|
226 |
+
with gr.Box(class_name="info-section"):
|
227 |
+
gr.Markdown("""
|
228 |
+
## 🔬 Our Technology
|
229 |
+
|
230 |
+
WoundWise AI uses a state-of-the-art deep learning model based on the GoogLeNet
|
231 |
+
architecture, trained on thousands of medical images. The system:
|
232 |
+
|
233 |
+
1. Analyzes wound images using advanced computer vision
|
234 |
+
2. Identifies 18 different types of wounds and skin conditions
|
235 |
+
3. Provides real-time classification with confidence scores
|
236 |
+
4. Generates medical guidelines using advanced AI
|
237 |
+
|
238 |
+
Our model achieves high accuracy through extensive training and validation by
|
239 |
+
medical professionals.
|
240 |
+
""")
|
241 |
|
242 |
+
# Disclaimer
|
243 |
+
with gr.Box(class_name="warning"):
|
244 |
+
gr.Markdown("""
|
245 |
+
## ⚕️ Medical Disclaimer
|
246 |
+
|
247 |
+
This AI system is designed to assist in preliminary wound assessment only. It is not
|
248 |
+
a substitute for professional medical advice, diagnosis, or treatment. Always seek
|
249 |
+
the advice of qualified healthcare providers with any questions regarding your
|
250 |
+
medical condition. If you believe your wound is serious or life-threatening,
|
251 |
+
please seek immediate medical attention.
|
252 |
+
""")
|
253 |
|
254 |
# Connect input to processing
|
255 |
submit_btn.click(
|
|
|
265 |
iface.launch(
|
266 |
server_name="0.0.0.0",
|
267 |
server_port=7860,
|
268 |
+
share=True
|
269 |
+
)
|