Update app.py
Browse files
app.py
CHANGED
|
@@ -10,9 +10,9 @@ from transformers import (
|
|
| 10 |
BlipForConditionalGeneration
|
| 11 |
)
|
| 12 |
|
| 13 |
-
st.set_page_config(page_title="
|
| 14 |
|
| 15 |
-
st.title("
|
| 16 |
st.write("BiomedCLIP + RemoteCLIP + CLIP + BLIP")
|
| 17 |
|
| 18 |
device = "cpu"
|
|
@@ -243,6 +243,151 @@ templates = {
|
|
| 243 |
|
| 244 |
}
|
| 245 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
|
| 247 |
# --------------------------------------------------
|
| 248 |
# SIDEBAR
|
|
|
|
| 10 |
BlipForConditionalGeneration
|
| 11 |
)
|
| 12 |
|
| 13 |
+
st.set_page_config(page_title="Zero Shot Image Classification", layout="wide")
|
| 14 |
|
| 15 |
+
st.title("Zero Shot Image Classification")
|
| 16 |
st.write("BiomedCLIP + RemoteCLIP + CLIP + BLIP")
|
| 17 |
|
| 18 |
device = "cpu"
|
|
|
|
| 243 |
|
| 244 |
}
|
| 245 |
|
| 246 |
+
# --------------------------------------------------
|
| 247 |
+
# EXPLANATION BLOCK
|
| 248 |
+
# --------------------------------------------------
|
| 249 |
+
|
| 250 |
+
explanations = {
|
| 251 |
+
|
| 252 |
+
"medical": {
|
| 253 |
+
"pneumonia":
|
| 254 |
+
"""
|
| 255 |
+
The uploaded chest X-ray image appears to indicate pneumonia.
|
| 256 |
+
Pneumonia is a lung infection that causes inflammation in the air sacs, which may fill with fluid or pus.
|
| 257 |
+
Common visual indicators in X-rays include cloudy regions or opacities in the lung fields.
|
| 258 |
+
Early detection is important because pneumonia can affect breathing and oxygen exchange.
|
| 259 |
+
Medical professionals typically confirm the diagnosis using radiological evaluation and clinical symptoms.
|
| 260 |
+
""",
|
| 261 |
+
|
| 262 |
+
"Normal":
|
| 263 |
+
"""
|
| 264 |
+
The chest X-ray image appears to show healthy lungs with no visible infection.
|
| 265 |
+
Normal lungs in radiographs usually show clear lung fields without abnormal opacities.
|
| 266 |
+
The diaphragm and lung boundaries appear well defined in healthy scans.
|
| 267 |
+
This suggests that the lungs are functioning normally without signs of pneumonia or infection.
|
| 268 |
+
A medical professional would still review the image alongside patient symptoms for confirmation.
|
| 269 |
+
"""
|
| 270 |
+
},
|
| 271 |
+
|
| 272 |
+
"skin_disease": {
|
| 273 |
+
|
| 274 |
+
"eczema":
|
| 275 |
+
"""
|
| 276 |
+
The image appears to show signs consistent with eczema.
|
| 277 |
+
Eczema is a skin condition that causes redness, inflammation, dryness, and itching.
|
| 278 |
+
It often appears as irritated patches of skin with uneven texture.
|
| 279 |
+
Environmental triggers, allergies, or immune responses may cause flare-ups.
|
| 280 |
+
Dermatologists typically diagnose eczema through visual inspection and medical history.
|
| 281 |
+
""",
|
| 282 |
+
|
| 283 |
+
"Melanoma":
|
| 284 |
+
"""
|
| 285 |
+
The image may contain characteristics associated with melanoma.
|
| 286 |
+
Melanoma is a serious form of skin cancer that develops in pigment-producing cells.
|
| 287 |
+
Visual indicators can include dark, irregularly shaped lesions with uneven borders.
|
| 288 |
+
Early detection is critical because melanoma can spread to other organs.
|
| 289 |
+
A dermatologist should examine suspicious lesions and may perform a biopsy.
|
| 290 |
+
""",
|
| 291 |
+
|
| 292 |
+
"psoriasis":
|
| 293 |
+
"""
|
| 294 |
+
The image appears to show features consistent with psoriasis.
|
| 295 |
+
Psoriasis is a chronic autoimmune condition that causes rapid skin cell buildup.
|
| 296 |
+
This results in thick, red patches with silvery scales on the skin.
|
| 297 |
+
The condition may cause itching or discomfort depending on severity.
|
| 298 |
+
Medical treatment usually focuses on reducing inflammation and slowing skin cell growth.
|
| 299 |
+
""",
|
| 300 |
+
|
| 301 |
+
"Normal Skin":
|
| 302 |
+
"""
|
| 303 |
+
The image appears to show healthy skin without visible dermatological abnormalities.
|
| 304 |
+
Normal skin typically has an even tone and smooth surface texture.
|
| 305 |
+
There are no visible lesions, scales, or inflammatory patches in the image.
|
| 306 |
+
This suggests that the skin does not currently show signs of common dermatological diseases.
|
| 307 |
+
However, regular skin monitoring is still recommended for early detection of conditions.
|
| 308 |
+
"""
|
| 309 |
+
},
|
| 310 |
+
|
| 311 |
+
"satellite": {
|
| 312 |
+
|
| 313 |
+
"HIGHWAY":
|
| 314 |
+
"""
|
| 315 |
+
The satellite image appears to contain a highway or major roadway.
|
| 316 |
+
Highways are large transportation corridors designed for high-speed vehicle movement.
|
| 317 |
+
From satellite imagery, they appear as long linear structures crossing landscapes.
|
| 318 |
+
They connect cities, industrial zones, and transportation hubs.
|
| 319 |
+
Remote sensing is commonly used to monitor infrastructure development and urban planning.
|
| 320 |
+
""",
|
| 321 |
+
|
| 322 |
+
"RIVER":
|
| 323 |
+
"""
|
| 324 |
+
The satellite image likely shows a river or flowing water body.
|
| 325 |
+
Rivers appear as long winding structures that transport water across landscapes.
|
| 326 |
+
They are important for agriculture, ecosystems, and human settlements.
|
| 327 |
+
Satellite imagery is often used to monitor river flow, flooding, and environmental changes.
|
| 328 |
+
Remote sensing helps researchers track water resources over time.
|
| 329 |
+
""",
|
| 330 |
+
|
| 331 |
+
"FOREST":
|
| 332 |
+
"""
|
| 333 |
+
The satellite image appears to contain dense forest vegetation.
|
| 334 |
+
Forests typically appear as large green areas with textured canopy patterns in aerial imagery.
|
| 335 |
+
They play a critical role in maintaining biodiversity and regulating climate.
|
| 336 |
+
Satellite monitoring is widely used to detect deforestation and vegetation changes.
|
| 337 |
+
Remote sensing helps scientists study environmental conservation.
|
| 338 |
+
"""
|
| 339 |
+
},
|
| 340 |
+
|
| 341 |
+
"agriculture": {
|
| 342 |
+
|
| 343 |
+
"POWDERY_MILDEW":
|
| 344 |
+
"""
|
| 345 |
+
The plant leaf in the image appears to show powdery mildew infection.
|
| 346 |
+
Powdery mildew is a fungal disease that creates white powder-like patches on leaves.
|
| 347 |
+
It can reduce photosynthesis and weaken plant health if untreated.
|
| 348 |
+
This disease spreads quickly in humid environments with limited airflow.
|
| 349 |
+
Farmers usually manage it using fungicides and improved crop management practices.
|
| 350 |
+
""",
|
| 351 |
+
|
| 352 |
+
"RUST":
|
| 353 |
+
"""
|
| 354 |
+
The plant leaf shows symptoms consistent with rust disease.
|
| 355 |
+
Rust infections create orange or brown spots on the leaf surface.
|
| 356 |
+
This fungal disease spreads through airborne spores.
|
| 357 |
+
Severe infections can reduce crop yield and plant health.
|
| 358 |
+
Agricultural monitoring helps detect plant diseases early for better crop protection.
|
| 359 |
+
""",
|
| 360 |
+
|
| 361 |
+
"EARLY BLIGHT":
|
| 362 |
+
"""
|
| 363 |
+
The leaf may show symptoms of early blight disease.
|
| 364 |
+
Early blight is a fungal infection commonly affecting tomato and potato plants.
|
| 365 |
+
It often produces circular brown spots with concentric rings on leaves.
|
| 366 |
+
If left untreated, the disease may spread across the plant.
|
| 367 |
+
Proper crop rotation and fungicide treatment help control early blight.
|
| 368 |
+
""",
|
| 369 |
+
|
| 370 |
+
"LATE BLIGHT":
|
| 371 |
+
"""
|
| 372 |
+
The leaf may be affected by late blight disease.
|
| 373 |
+
Late blight is a severe plant disease that affects crops such as potatoes and tomatoes.
|
| 374 |
+
Symptoms often include dark lesions and rapid leaf decay.
|
| 375 |
+
The disease spreads quickly in cool and humid conditions.
|
| 376 |
+
Early detection helps farmers take preventive measures to protect crops.
|
| 377 |
+
""",
|
| 378 |
+
|
| 379 |
+
"HEALTHY":
|
| 380 |
+
"""
|
| 381 |
+
The plant leaf appears healthy with no visible disease symptoms.
|
| 382 |
+
Healthy leaves typically have a uniform green color and smooth surface.
|
| 383 |
+
There are no visible fungal spots, discoloration, or lesions.
|
| 384 |
+
This indicates that the plant is likely growing under good conditions.
|
| 385 |
+
Regular monitoring helps maintain crop health and productivity.
|
| 386 |
+
"""
|
| 387 |
+
}
|
| 388 |
+
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
|
| 392 |
# --------------------------------------------------
|
| 393 |
# SIDEBAR
|