Update src/streamlit_app.py
Browse files- src/streamlit_app.py +17 -12
src/streamlit_app.py
CHANGED
|
@@ -2,7 +2,6 @@ import streamlit as st
|
|
| 2 |
import pickle
|
| 3 |
import numpy as np
|
| 4 |
from PIL import Image
|
| 5 |
-
import os
|
| 6 |
|
| 7 |
# =========================
|
| 8 |
# Load PCA, SVC model & scaler
|
|
@@ -34,17 +33,23 @@ label_map = {
|
|
| 34 |
st.title("π Fruit Image Classification")
|
| 35 |
|
| 36 |
# ---- Example images ----
|
| 37 |
-
st.subheader("
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
# ---- Show classes ----
|
| 50 |
st.markdown("**Classes:** freshapples, freshbanana, freshoranges, rottenapples, rottenbanana, rottenoranges")
|
|
|
|
| 2 |
import pickle
|
| 3 |
import numpy as np
|
| 4 |
from PIL import Image
|
|
|
|
| 5 |
|
| 6 |
# =========================
|
| 7 |
# Load PCA, SVC model & scaler
|
|
|
|
| 33 |
st.title("π Fruit Image Classification")
|
| 34 |
|
| 35 |
# ---- Example images ----
|
| 36 |
+
st.subheader("Example Images")
|
| 37 |
+
example_image_files = {
|
| 38 |
+
"Fresh Apple": "fresh Apple.jpg",
|
| 39 |
+
"Fresh Banana": "fresh Banana.jpg",
|
| 40 |
+
"Fresh Oranges": "fresh Oranges.jpg",
|
| 41 |
+
"Rotten Apple": "rotten Apple.jpg",
|
| 42 |
+
"Rotten Banana": "rotten Banana.jpg",
|
| 43 |
+
"Rotten Oranges": "rotten Oranges.jpg"
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
cols = st.columns(3)
|
| 47 |
+
for i, (label, file) in enumerate(example_image_files.items()):
|
| 48 |
+
try:
|
| 49 |
+
img = Image.open(file).convert("RGB")
|
| 50 |
+
cols[i % 3].image(img, caption=label, use_container_width=True)
|
| 51 |
+
except:
|
| 52 |
+
cols[i % 3].info(f"Add image '{file}' in the folder.")
|
| 53 |
|
| 54 |
# ---- Show classes ----
|
| 55 |
st.markdown("**Classes:** freshapples, freshbanana, freshoranges, rottenapples, rottenbanana, rottenoranges")
|