frrnnda7 commited on
Commit
c4840bb
1 Parent(s): 7db1789

Upload 3 files

Browse files
Files changed (4) hide show
  1. .gitattributes +1 -0
  2. app.py +44 -0
  3. model_best2.hdf5 +3 -0
  4. requirements.txt +4 -0
.gitattributes CHANGED
@@ -32,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
32
  *.zip filter=lfs diff=lfs merge=lfs -text
33
  *.zst filter=lfs diff=lfs merge=lfs -text
34
  *tfevents* filter=lfs diff=lfs merge=lfs -text
35
+ model_best2.hdf5 filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ from tensorflow.keras.models import load_model
4
+ from PIL import Image
5
+
6
+ st.title('Dog Classification')
7
+
8
+ # import the model
9
+
10
+ model = load_model('model_best2.hdf5')
11
+
12
+ # define the preprocessing function
13
+
14
+ def preprocess_image(image):
15
+ image = image.resize((240, 240)) # resize the image to the desired dimensions
16
+ image = image.convert("RGB") # convert the image to RGB mode if needed
17
+ image = np.array(image) # convert the image to a NumPy array
18
+ image = image / 255.0 # normalize the pixel values to the range of 0 to 1
19
+ image = np.expand_dims(image, axis=0) # add an extra dimension for batch size
20
+ return image
21
+
22
+ # define the prediction function
23
+
24
+ def prediction(image):
25
+ preprocessed_image = preprocess_image(image)
26
+ classes = model.predict(preprocessed_image)
27
+ predicted_class_index = np.argmax(classes)
28
+ class_labels = ['Afghan', 'Bulldog', 'Chow']
29
+ predicted_class = class_labels[predicted_class_index]
30
+ return predicted_class
31
+
32
+ # file uploader
33
+
34
+ uploaded_file = st.file_uploader("Upload your Dog Picture.")
35
+
36
+ # result
37
+
38
+ if st.button('Predict'):
39
+ if uploaded_file is None:
40
+ st.write('Please upload your favorite dog to purchase picture first.')
41
+ else:
42
+ image = Image.open(uploaded_file)
43
+ result = prediction(image)
44
+ st.write('This Dog belongs to the {} class.'.format(result))
model_best2.hdf5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9ce0f72cdaa4afeb9c783092a95e34c5a1cd5df7157498b575af29b4b167c09b
3
+ size 86876584
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit
2
+ numpy
3
+ tensorflow
4
+ Pillow