Metinhsimi commited on
Commit
a4ebc5d
Β·
verified Β·
1 Parent(s): 05fbfd0

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +43 -0
  2. catdogmodel.h5 +3 -0
  3. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from tensorflow.keras.preprocessing import image
3
+ import numpy as np
4
+ from PIL import Image
5
+ import tensorflow as tf
6
+
7
+ # Load the model
8
+ @st.cache_resource
9
+ def load_model():
10
+ model = tf.keras.models.load_model('catdogmodel.h5') # Path to your model
11
+ return model
12
+
13
+ model = load_model()
14
+
15
+ # Title
16
+ st.title("🐱🐢 Cat vs. Dog Classifier")
17
+
18
+ # Image Upload
19
+ st.header("Upload an Image")
20
+ uploaded_file = st.file_uploader("Please upload a cat or dog image...", type=["jpg", "jpeg", "png"])
21
+
22
+ if uploaded_file is not None:
23
+ # Open and display the image
24
+ img = Image.open(uploaded_file)
25
+ st.image(img, caption='Uploaded Image', use_column_width=True)
26
+ st.write("πŸ” **Analyzing the image...**")
27
+
28
+ # Preprocess the image
29
+ img = img.resize((128, 128))
30
+ img_array = image.img_to_array(img)
31
+ img_array = np.expand_dims(img_array, axis=0)
32
+ img_array /= 255.0
33
+
34
+ # Predict
35
+ prediction = model.predict(img_array)
36
+
37
+ # Display the result
38
+ if prediction < 0.5:
39
+ st.write("🐢 **It's a Dog!**")
40
+ else:
41
+ st.write("🐱 **It's a Cat!**")
42
+ else:
43
+ st.write("πŸ‘ˆ Upload an image to get started!")
catdogmodel.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e18cf37afdcd0bd4fe20ae2f5f861e9cf1dd7152f97256f68b0e121a890b904f
3
+ size 155322664
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ tensorflow
2
+ streamlit