# app.py import streamlit as st from PIL import Image from prediction import predict_image from eda import show_eda st.set_page_config(page_title="Fruit CNN", layout="centered") st.title("Fruit Classification App (CNN)") # ====================== # SIDEBAR MENU # ====================== menu = st.sidebar.selectbox( "Menu", ["Prediction", "EDA"] ) # ====================== # PREDICTION PAGE # ====================== if menu == "Prediction": st.subheader("Upload Image") uploaded_files = st.file_uploader( "Upload one or more images", type=["jpg", "png"], accept_multiple_files=True ) if uploaded_files: for file in uploaded_files: try: img = Image.open(file) st.image(img, caption="Uploaded Image", use_column_width=True) label, confidence = predict_image(img) st.success(f"Prediction: {label}") st.info(f"Confidence: {confidence:.2f}") st.markdown("---") except Exception as e: st.error(f"Error processing image: {e}") # ====================== # EDA PAGE # ====================== elif menu == "EDA": st.subheader("Exploratory Data Analysis") # GANTI PATH INI SESUAI PUNYA KAMU train_dir = r"C:\Users\ferna\.cache\kagglehub\datasets\moltean\fruits\versions\87\fruits-360_100x100\fruits-360\Training" try: show_eda(train_dir) except Exception as e: st.error("EDA gagal dijalankan") st.write(e)