Download src/streamlit_app.py from handex/FruitsVegetablesClassification: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/spaces/handex/FruitsVegetablesClassification/resolve/main/src/streamlit_app.py
- Command line
-
hf download hf://spaces/handex/FruitsVegetablesClassification/src/streamlit_app.py
-
curl -L -o streamlit_app.py https://huggingface.co/spaces/handex/FruitsVegetablesClassification/resolve/main/src/streamlit_app.py
1.13 kB
| import streamlit as st | |
| from tensorflow.keras.models import load_model | |
| from PIL import Image | |
| import numpy as np | |
| model=load_model('src/fruit_vegetable.h5') | |
| def process_image(img): | |
| img=img.resize((240,240)) | |
| img=np.array(img) | |
| img=img/255.0 | |
| img=np.expand_dims(img,axis=0) | |
| return img | |
| st.title("Meyve/Sebze sınıflandırma") | |
| st.write("Resmini yükle ve model meyve/sebze ismini tahmin etsin") | |
| file=st.file_uploader('Bir resim sec',type=['jpg','jpeg','png']) | |
| if file is not None: | |
| img=Image.open(file) | |
| st.image(img,caption='Meyve/Sebze') | |
| image= process_image(img) | |
| prediction=model.predict(image) | |
| predicted_class=np.argmax(prediction) | |
| class_names=['capsicum','sweetcorn','orange','tomato','turnip','ginger','raddish','pomegranate','pineapple', | |
| 'jalepeno','apple','carrot','lettuce','bell pepper','eggplant','beetroot','kiwi','pear', | |
| 'cabbage','cauliflower','paprika','lemon','sweetpotato','grapes','cucumber','corn','banana', | |
| 'garlic','chilli pepper','watermelon','mango','peas','onion','potato','spinach','soy beans'] | |
| st.write(class_names[predicted_class]) | |