sevvaliclal commited on
Commit
4e14327
·
verified ·
1 Parent(s): ab138c8

Update src/app.py

Browse files
Files changed (1) hide show
  1. src/app.py +8 -15
src/app.py CHANGED
@@ -1,25 +1,18 @@
1
- # app.py
2
  import streamlit as st
3
  from tensorflow.keras.models import load_model
4
  from tensorflow.keras.preprocessing import image
5
  import numpy as np
6
- from PIL import Image
7
 
8
- # --- Modeli Yükle ---
9
- model = load_model("src/heads_tails_vgg16.h5")
10
 
11
- st.title("Heads or Tails Predictor")
12
 
13
- # --- Kullanıcıdan Resim Al ---
14
- uploaded_file = st.file_uploader("Upload a coin image", type=["jpg", "png"])
15
  if uploaded_file:
16
- img = Image.open(uploaded_file).resize((224, 224))
17
- st.image(img, caption="Uploaded Image", use_column_width=True)
 
18
 
19
- # --- Tahmin ---
20
- x = np.expand_dims(np.array(img)/255.0, axis=0)
21
  pred = model.predict(x)[0][0]
22
-
23
- # --- Sonuç ---
24
- st.write("Prediction:", "Heads" if pred > 0.5 else "Tails")
25
- st.write("Probability of Heads:", round(float(pred), 3))
 
 
1
  import streamlit as st
2
  from tensorflow.keras.models import load_model
3
  from tensorflow.keras.preprocessing import image
4
  import numpy as np
 
5
 
6
+ # Load model
7
+ model = load_model("cat_dog_model.h5")
8
 
9
+ st.title("🐱🐶 Cat vs Dog Predictor")
10
 
11
+ uploaded_file = st.file_uploader("Upload an image", type=["jpg", "png"])
 
12
  if uploaded_file:
13
+ img = image.load_img(uploaded_file, target_size=(224,224))
14
+ x = image.img_to_array(img) / 255.0
15
+ x = np.expand_dims(x, axis=0)
16
 
 
 
17
  pred = model.predict(x)[0][0]
18
+ st.write("Prediction:", "Dog 🐶" if pred > 0.5 else "Cat 🐱")