Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,25 +1,25 @@
|
|
| 1 |
-
#import libraries
|
| 2 |
-
import streamlit as st
|
| 3 |
-
from tensorflow.keras.models import load_model
|
| 4 |
-
from PIL import Image
|
| 5 |
-
import numpy as np
|
| 6 |
-
import cv2
|
| 7 |
-
model=load_model('date_fruit_colab.keras')
|
| 8 |
-
def process_image(img):
|
| 9 |
-
img=img.resize((150,150))
|
| 10 |
-
img=np.array(img)
|
| 11 |
-
img=img/255.0
|
| 12 |
-
img=np.expand_dims(img,axis=0)
|
| 13 |
-
return img
|
| 14 |
-
st.title("Date Fruit Classification:date_tree:")
|
| 15 |
-
st.write("Pick a picture and let the model predict the type of date")
|
| 16 |
-
file=st.file_uploader('Pick a picture',type=['jpg','jpeg','png','JPG'])
|
| 17 |
-
if file is not None:
|
| 18 |
-
img=Image.open(file)
|
| 19 |
-
st.image(img,caption='loaded picture')
|
| 20 |
-
image= process_image(img)
|
| 21 |
-
prediction=model.predict(image)
|
| 22 |
-
predicted_class=np.argmax(prediction)
|
| 23 |
-
|
| 24 |
-
class_names=['Ajwa', 'Galaxy', 'Medjool', 'Meneifi', 'Nabtat Ali', 'Rutab', 'Shaishe', 'Sokari', 'Sugaey']
|
| 25 |
-
st.write(class_names[predicted_class])
|
|
|
|
| 1 |
+
#import libraries
|
| 2 |
+
import streamlit as st
|
| 3 |
+
from tensorflow.keras.models import load_model
|
| 4 |
+
from PIL import Image
|
| 5 |
+
import numpy as np
|
| 6 |
+
import cv2
|
| 7 |
+
model=load_model('src/date_fruit_colab.keras')
|
| 8 |
+
def process_image(img):
|
| 9 |
+
img=img.resize((150,150))
|
| 10 |
+
img=np.array(img)
|
| 11 |
+
img=img/255.0
|
| 12 |
+
img=np.expand_dims(img,axis=0)
|
| 13 |
+
return img
|
| 14 |
+
st.title("Date Fruit Classification:date_tree:")
|
| 15 |
+
st.write("Pick a picture and let the model predict the type of date")
|
| 16 |
+
file=st.file_uploader('Pick a picture',type=['jpg','jpeg','png','JPG'])
|
| 17 |
+
if file is not None:
|
| 18 |
+
img=Image.open(file)
|
| 19 |
+
st.image(img,caption='loaded picture')
|
| 20 |
+
image= process_image(img)
|
| 21 |
+
prediction=model.predict(image)
|
| 22 |
+
predicted_class=np.argmax(prediction)
|
| 23 |
+
|
| 24 |
+
class_names=['Ajwa', 'Galaxy', 'Medjool', 'Meneifi', 'Nabtat Ali', 'Rutab', 'Shaishe', 'Sokari', 'Sugaey']
|
| 25 |
+
st.write(class_names[predicted_class])
|