Image classification app, i have two model knn and svm and the class is cloudy, sunrise and rainy make outstanding userinterface
To upload files, please first save the app
import streamlit as st
from PIL import Image
import numpy as np
# Mock model predictions for demonstration
def predict(image, model_type):
# In actual implementation, load and use your models here
if model_type == 'KNN':
return np.random.choice(['cloudy', 'sunrise', 'rainy'])
elif model_type == 'SVM':
return np.random.choice(['cloudy', 'sunrise', 'rainy'])
st.title('Image Classification App')
st.write('Upload an image to classify it into one of the following categories: cloudy, sunrise, or rainy.')
model_type = st.selectbox('Select Model', ['KNN', 'SVM'])
upload_image = st.file_uploader('Choose an image...', type=['jpg', 'jpeg', 'png'])
if upload_image is not None:
image = Image.open(upload_image)
st.image(image, caption='Uploaded Image.', use_column_width=True)
st.write('Classifying...')
label = predict(image, model_type)
st.write(f'Predicted Class: **{label}**')
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?