File size: 913 Bytes
d0729a3 d68a72b d0729a3 d68a72b d0729a3 d68a72b b408e8e d0729a3 | 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 | import streamlit as st
import pandas as pd
import numpy as np
import joblib
import cv2
from PIL import Image
import sklearn
import joblib
try:
model = joblib.load("knn_cls.pkl")
st.success("Model Loaded Successfully")
except Exception as e:
st.error(e)
st.title("Apple and Tomato Classification")
image=st.file_uploader(label="upload only tomato and apple ",type='image/*')
if image is not None:
st.image(image)
# file_bytes = np.asarray(bytearray(image.read()), dtype=np.uint8)
# image = cv2.imdecode(file_bytes, cv2.IMREAD_COLOR)
image=Image.open(image)
image=np.array(image)
image=cv2.resize(src=image,dsize=(100,100),interpolation=cv2.INTER_LINEAR)
image=image.flatten()
df=pd.DataFrame(image)
df=df.T
if st.button("Predict"):
y_pred=model.predict(df)
st.info(f"The predicted value is {y_pred[0]}") |