File size: 1,607 Bytes
4c8cb0b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# 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)