import streamlit as st from tensorflow.keras.models import load_model from utils import predict_label from PIL import Image st.title("Sports Image Classification") st.write("Predict the sport that is being represented in the image.") model = load_model("best_model.h5") with st.form("my_form"): uploaded_file = st.file_uploader( "Upload an image of a sport being played:", type="jpg" ) if uploaded_file is not None: image = Image.open(uploaded_file) label = predict_label(image, model) submitted = st.form_submit_button("Submit") if submitted: if uploaded_file is not None: image = Image.open(uploaded_file) st.image(image, caption="Uploaded Image", use_column_width=True) st.markdown( f"