Fruits and Vegetables Image Detection
Browse files- app.py +32 -0
- requierements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from tensorflow.keras.models import load_model
|
| 3 |
+
from PIL import Image
|
| 4 |
+
import numpy as np
|
| 5 |
+
|
| 6 |
+
model=load_model('my_fv_model.h5')
|
| 7 |
+
|
| 8 |
+
def process_image(img):
|
| 9 |
+
img=img.resize((170,170)) #boyutunu 170*170 pixel yaptık
|
| 10 |
+
img=np.array(img)
|
| 11 |
+
img=img/255.0 #Normalize ettik
|
| 12 |
+
img=np.expand_dims(img,axis=0)
|
| 13 |
+
return img
|
| 14 |
+
|
| 15 |
+
st.title('Meyze Sebze Siniflandirmasi :tomato:')
|
| 16 |
+
st.write('Resim seç ve hangi meyve/sebze olduğunu tahmin etsin')
|
| 17 |
+
|
| 18 |
+
file=st.file_uploader('Bir Resim Sec', type=['jpg','jpeg','png'])
|
| 19 |
+
|
| 20 |
+
if file is not None:
|
| 21 |
+
img=Image.open(file)
|
| 22 |
+
st.image(img,caption='yuklenen resim')
|
| 23 |
+
image=process_image(img)
|
| 24 |
+
prediction=model.predict(image)
|
| 25 |
+
predicted_class=np.argmax(prediction)
|
| 26 |
+
|
| 27 |
+
class_names=['apple','banana','beetroot','bell pepper','cabbage','capsicum','carrot',
|
| 28 |
+
'cauliflower','chilli pepper','corn','cucumber','eggplant','garlic','ginger','grapes',
|
| 29 |
+
'jalepeno','kiwi','lemon','lettuce','mango','onion','orange','paprika','pear','peas',
|
| 30 |
+
'pineapple','pomegranate','potato','raddish','soy beans','spinach','sweetcorn','sweetpotato',
|
| 31 |
+
'tomato','turnip','watermelon']
|
| 32 |
+
st.write(class_names[predicted_class])
|
requierements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
tensorflow
|