File size: 1,716 Bytes
14c5141
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7577f7b
14c5141
 
 
 
 
 
 
 
 
 
 
341927e
d88725b
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
65
66
67
68
from helper.model import fetch_model, preprocess_image, classify_image
from PIL import Image
import streamlit as st
import io

st.set_page_config(
    page_title="VGNet Prototype",
    page_icon="🤖",
)

st.title("Using Deep Learning Techniques on Philippine Corn Leaf Disease Classification")
st.write("This is the prototype of VGNet model trained using different optimizers")
st.write("Thesis Project by Group BDK of Mapua University")

st.image(
    "resources/corn-field.png",
    caption='A corn field',
    width=700
)

st.header("How to use?")
st.markdown("""
1. Select a model.
2. Select an image (Leaf Blight, Gray Leaf Spot, Common Rust).
3. Upload the selected image here.
4. The model will output the classification result if the image is (Leaf Blight, Gray Leaf Spot, Common Rust).
""")

uploaded_image = st.file_uploader(
    "Choose an image...",
    type=["bmp", "png", "jpg", "jpeg"]
)

model_labels = [
    "VGNet + Adam",
    "VGNet + Adan",
    "VGNet + AdamW",
    "VGNet + RMSprop",
    "VGNet + AdaBound"
]
model_option = st.selectbox(
    "Select a Model:",
    list(range(len(model_labels))),
    format_func=lambda ind: model_labels[ind]
)


# Check if an image was uploaded
if uploaded_image is not None:

    # Preprocess the image
    image = preprocess_image(
        Image.open(
            uploaded_image
        )
    )

    # Fetch the model
    model_optimizer_name = ["adam", "adan", "adamw", "rmsprop", "adabound"]
    model = fetch_model(model_optimizer_name[model_option])

    # Perform classification
    predicted_label = classify_image(model, image)

    # Display Prediction Result
    st.image(image, clamp = True)
    st.write(f"Prediction Result: {predicted_label}")