File size: 1,310 Bytes
d3b11cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from PIL import Image, ImageOps
import io
from img_classification import teachable_machine_classification, load_model

from tensorflow import keras


st.set_option("deprecation.showfileUploaderEncoding", False)

st.title("Detecting presence of Poison Oak")
st.header("Poison Oak Classification Example")
st.text("Upload an image for classification as poison oak or no poison oak")


# Load trained model
model = load_model("./best_model.h5")

print("Starting Streamlit app")
uploaded_file = st.file_uploader("Select an image ...", type=["jpg", "png", "jpeg"])

if uploaded_file is not None:
    image = Image.open(uploaded_file)
    st.image(image, caption="Uploaded image", use_column_width=True)
    st.write("")
    st.write("Classifying...")
    label = teachable_machine_classification(img=image, model=model)
    if label <= 0.2:
        st.write("Very unlikely that this is poison oak.")
    elif (label > 0.2) & (label <= 0.6):
        st.write(
            "Unsure from this picture. You may need to retake a closer/clearer picture."
        )
    elif (label > 0.6) & (label <= 0.7):
        st.write("Decent chance that this is poison oak.")
    else:
        st.write("{:.1f}% chance that this might be poison oak".format(label * 100))
else:
    st.write("No file uploaded")