Spaces:
Build error
Build error
File size: 792 Bytes
ad38d23 |
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 |
import app as st
from keras.models import load_model
import numpy as np
model=load_model("crop_prediction_model.h5",compile=True)
labels=["Tomato Bacterial Spot","Early Blight","Healthy","Late Blight","Leaf Mold","Tomato Septoria leaf spot", "Tomato___Spider_mites Two spotted spider mite","Tomato___Target_Spot","Tomato___Tomato_mosaic_virus", "Tomato___Tomato_Yellow_Leaf_Curl_Virus"]
def classify_image(img):
img = img.reshape((-1, 256, 256, 3))
type=predict_crop(img)
return type
def predict_crop(img):
crop_class=model.predict(img)
index=np.argmax(crop_class)
label=labels[index]
return label
img = st.camera_input("Take a picture")
if img:
class_of_plant=classify_image(img)
st.write(class_of_plant)
else :
st.write("Image is not clear.")
|