AdithyaSNair commited on
Commit
3c40c7c
1 Parent(s): b3f3b11

Upload 3 files

Browse files
Files changed (3) hide show
  1. dog_breed.h5 +3 -0
  2. main_app.py +42 -0
  3. requirements.txt +4 -0
dog_breed.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5978d94fb5b9380b71e8c60f28b62187f1e2750048c73bdf2ef465287e90c47d
3
+ size 2022552
main_app.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Library imports
2
+ import numpy as np
3
+ import streamlit as st
4
+ import cv2
5
+ from keras.models import load_model
6
+
7
+
8
+ #Loading the Model
9
+ model = load_model('dog_breed.h5')
10
+
11
+ #Name of Classes
12
+ CLASS_NAMES = ['Scottish Deerhound','Maltese Dog','Bernese Mountain Dog']
13
+
14
+ #Setting Title of App
15
+ st.title("Dog Breed Prediction")
16
+ st.markdown("Upload an image of the dog")
17
+
18
+ #Uploading the dog image
19
+ dog_image = st.file_uploader("Choose an image...", type="png")
20
+ submit = st.button('Predict')
21
+ #On predict button click
22
+ if submit:
23
+
24
+
25
+ if dog_image is not None:
26
+
27
+ # Convert the file to an opencv image.
28
+ file_bytes = np.asarray(bytearray(dog_image.read()), dtype=np.uint8)
29
+ opencv_image = cv2.imdecode(file_bytes, 1)
30
+
31
+
32
+
33
+ # Displaying the image
34
+ st.image(opencv_image, channels="BGR")
35
+ #Resizing the image
36
+ opencv_image = cv2.resize(opencv_image, (224,224))
37
+ #Convert image to 4 Dimension
38
+ opencv_image.shape = (1,224,224,3)
39
+ #Make Prediction
40
+ Y_pred = model.predict(opencv_image)
41
+
42
+ st.title(str("The Dog Breed is "+CLASS_NAMES[np.argmax(Y_pred)]))
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ Keras==2.4.3
2
+ opencv_python==4.4.0.46
3
+ numpy==1.18.5
4
+ streamlit==0.71.0