Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -1,8 +1,20 @@
|
|
| 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
import numpy as np
|
| 4 |
import requests
|
| 5 |
-
import pydicom
|
| 6 |
import cv2
|
| 7 |
import tempfile
|
| 8 |
|
|
@@ -49,7 +61,9 @@ def preprocess_image(img):
|
|
| 49 |
|
| 50 |
# Normalize
|
| 51 |
img = img.astype("float32")
|
| 52 |
-
|
|
|
|
|
|
|
| 53 |
|
| 54 |
return img
|
| 55 |
|
|
@@ -117,7 +131,6 @@ if st.button("Predict Pneumonia"):
|
|
| 117 |
|
| 118 |
if predicted_class == "Pneumonia":
|
| 119 |
st.error("⚠️ Pneumonia Detected")
|
| 120 |
-
|
| 121 |
else:
|
| 122 |
st.success("✅ Normal Lungs")
|
| 123 |
|
|
|
|
| 1 |
|
| 2 |
+
# -----------------------------
|
| 3 |
+
# Install pydicom if not present
|
| 4 |
+
# -----------------------------
|
| 5 |
+
import subprocess
|
| 6 |
+
import sys
|
| 7 |
+
|
| 8 |
+
try:
|
| 9 |
+
import pydicom
|
| 10 |
+
except ImportError:
|
| 11 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", "pydicom"])
|
| 12 |
+
import pydicom
|
| 13 |
+
|
| 14 |
+
|
| 15 |
import streamlit as st
|
| 16 |
import numpy as np
|
| 17 |
import requests
|
|
|
|
| 18 |
import cv2
|
| 19 |
import tempfile
|
| 20 |
|
|
|
|
| 61 |
|
| 62 |
# Normalize
|
| 63 |
img = img.astype("float32")
|
| 64 |
+
|
| 65 |
+
if img.max() > 0:
|
| 66 |
+
img = img / img.max()
|
| 67 |
|
| 68 |
return img
|
| 69 |
|
|
|
|
| 131 |
|
| 132 |
if predicted_class == "Pneumonia":
|
| 133 |
st.error("⚠️ Pneumonia Detected")
|
|
|
|
| 134 |
else:
|
| 135 |
st.success("✅ Normal Lungs")
|
| 136 |
|