Spaces:
Sleeping
Sleeping
Rename app (1).py to app.py
Browse files- app (1).py → app.py +7 -12
app (1).py → app.py
RENAMED
|
@@ -35,20 +35,15 @@ def make_gradcam_heatmap(img_array, model, last_conv_layer_name, pred_index=None
|
|
| 35 |
# Streamlit UI
|
| 36 |
st.title("🧠 Image Classifier + Grad-CAM Visualizer")
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
image_ = Image.open(uploaded_file).convert('RGB')
|
| 44 |
else:
|
| 45 |
-
|
| 46 |
-
default_path = "dog.jpg" # Make sure this file exists in your project folder
|
| 47 |
-
if os.path.exists(default_path):
|
| 48 |
-
image_ = Image.open(default_path).convert('RGB')
|
| 49 |
-
else:
|
| 50 |
-
st.error("Default image not found. Please upload an image.")
|
| 51 |
-
st.stop()
|
| 52 |
|
| 53 |
# Preprocess image
|
| 54 |
image_resized = image_.resize((224, 224))
|
|
|
|
| 35 |
# Streamlit UI
|
| 36 |
st.title("🧠 Image Classifier + Grad-CAM Visualizer")
|
| 37 |
|
| 38 |
+
choice = st.selectbox(
|
| 39 |
+
"Select Option:",
|
| 40 |
+
("Upload Image", "Use Sample Image")
|
| 41 |
+
)
|
| 42 |
|
| 43 |
+
if choice == "Upload Image":
|
| 44 |
+
image_= st.file_uploader("📤 Upload an image (JPG, JPEG, PNG)", type=["jpg", "jpeg", "png"])
|
|
|
|
| 45 |
else:
|
| 46 |
+
image_= Image.open(r"dog.jpg").convert('RGB')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
# Preprocess image
|
| 49 |
image_resized = image_.resize((224, 224))
|