WatermelonPapaya commited on
Commit
14c5141
·
verified ·
1 Parent(s): 94e239a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +70 -61
app.py CHANGED
@@ -1,61 +1,70 @@
1
- from helper.model import fetch_model, preprocess_image, classify_image
2
- import streamlit as st
3
-
4
- st.set_page_config(
5
- page_title="VGNet Prototype",
6
- page_icon="🤖",
7
- )
8
-
9
- st.title("Using Deep Learning Techniques on Philippine Corn Leaf Disease Classification")
10
- st.write("This is the prototype of VGNet model trained using different optimizers")
11
- st.write("Thesis Project by Group BDK of Mapua University")
12
-
13
- st.image(
14
- "resources/corn-field.png",
15
- caption='A corn field',
16
- width=700
17
- )
18
-
19
- st.header("How to use?")
20
- st.markdown("""
21
- 1. Select a model.
22
- 2. Select an image (Leaf Blight, Gray Leaf Spot, Common Rust).
23
- 3. Upload the selected image here.
24
- 4. The model will output the classification result if the image is (Leaf Blight, Gray Leaf Spot, Common Rust).
25
- """)
26
-
27
- uploaded_image = st.file_uploader(
28
- "Choose an image...",
29
- type=["bmp", "png", "jpg", "jpeg"]
30
- )
31
-
32
- model_labels = [
33
- "VGNet + Adam",
34
- "VGNet + Adan",
35
- "VGNet + AdamW",
36
- "VGNet + RMSprop",
37
- "VGNet + AdaBound"
38
- ]
39
- model_option = st.selectbox(
40
- "Select a Model:",
41
- list(range(len(model_labels))),
42
- format_func=lambda ind: model_labels[ind]
43
- )
44
-
45
-
46
- # Check if an image was uploaded
47
- if uploaded_image is not None:
48
-
49
- # Preprocess the image
50
- image = preprocess_image(uploaded_image)
51
-
52
- # Fetch the model
53
- model_optimizer_name = ["adam", "adan", "adamw", "rmsprop", "adabound"]
54
- model = fetch_model(model_optimizer_name[model_option])
55
-
56
- # Perform classification
57
- predicted_label = classify_image(model, image)
58
-
59
- # Display Prediction Result
60
- st.image(image)
61
- st.write(f"Prediction Results: {predicted_label}")
 
 
 
 
 
 
 
 
 
 
1
+ from helper.model import fetch_model, preprocess_image, classify_image
2
+ from PIL import Image
3
+ import streamlit as st
4
+ import io
5
+
6
+ st.set_page_config(
7
+ page_title="VGNet Prototype",
8
+ page_icon="🤖",
9
+ )
10
+
11
+ st.title("Using Deep Learning Techniques on Philippine Corn Leaf Disease Classification")
12
+ st.write("This is the prototype of VGNet model trained using different optimizers")
13
+ st.write("Thesis Project by Group BDK of Mapua University")
14
+
15
+ st.image(
16
+ "resources/corn-field.png",
17
+ caption='A corn field',
18
+ width=700
19
+ )
20
+
21
+ st.header("How to use?")
22
+ st.markdown("""
23
+ 1. Select a model.
24
+ 2. Select an image (Leaf Blight, Gray Leaf Spot, Common Rust).
25
+ 3. Upload the selected image here.
26
+ 4. The model will output the classification result if the image is (Leaf Blight, Gray Leaf Spot, Common Rust).
27
+ """)
28
+
29
+ uploaded_image = st.file_uploader(
30
+ "Choose an image...",
31
+ type=["bmp", "png", "jpg", "jpeg"]
32
+ )
33
+
34
+ model_labels = [
35
+ "VGNet + Adam",
36
+ "VGNet + Adan",
37
+ "VGNet + AdamW",
38
+ "VGNet + RMSprop",
39
+ "VGNet + AdaBound"
40
+ ]
41
+ model_option = st.selectbox(
42
+ "Select a Model:",
43
+ list(range(len(model_labels))),
44
+ format_func=lambda ind: model_labels[ind]
45
+ )
46
+
47
+
48
+ # Check if an image was uploaded
49
+ if uploaded_image is not None:
50
+
51
+ # Preprocess the image
52
+ image = preprocess_image(
53
+ Image.open(
54
+ io.BytesIO(
55
+ uploaded_image
56
+ )
57
+ )
58
+
59
+ )
60
+
61
+ # Fetch the model
62
+ model_optimizer_name = ["adam", "adan", "adamw", "rmsprop", "adabound"]
63
+ model = fetch_model(model_optimizer_name[model_option])
64
+
65
+ # Perform classification
66
+ predicted_label = classify_image(model, image)
67
+
68
+ # Display Prediction Result
69
+ st.image(image)
70
+ st.write(f"Prediction Results: {predicted_label}")