Spaces:
Build error
Build error
Download app.py from hakandeniz47/DateFruit_Classification_CNN: direct link, hf CLI and curl.
- Browser
- Download file 878 Bytes
-
https://huggingface.co/spaces/hakandeniz47/DateFruit_Classification_CNN/resolve/main/app.py
- Command line
-
hf download hf://spaces/hakandeniz47/DateFruit_Classification_CNN/app.py
-
curl -L -o app.py https://huggingface.co/spaces/hakandeniz47/DateFruit_Classification_CNN/resolve/main/app.py
878 Bytes
| #import libraries | |
| import streamlit as st | |
| from tensorflow.keras.models import load_model | |
| from PIL import Image | |
| import numpy as np | |
| import cv2 | |
| model=load_model('src/date_fruit_colab.keras') | |
| def process_image(img): | |
| img=img.resize((150,150)) | |
| img=np.array(img) | |
| img=img/255.0 | |
| img=np.expand_dims(img,axis=0) | |
| return img | |
| st.title("Date Fruit Classification:date_tree:") | |
| st.write("Pick a picture and let the model predict the type of date") | |
| file=st.file_uploader('Pick a picture',type=['jpg','jpeg','png','JPG']) | |
| if file is not None: | |
| img=Image.open(file) | |
| st.image(img,caption='loaded picture') | |
| image= process_image(img) | |
| prediction=model.predict(image) | |
| predicted_class=np.argmax(prediction) | |
| class_names=['Ajwa', 'Galaxy', 'Medjool', 'Meneifi', 'Nabtat Ali', 'Rutab', 'Shaishe', 'Sokari', 'Sugaey'] | |
| st.write(class_names[predicted_class]) | |