ESMATUGBA commited on
Commit
fd72370
·
verified ·
1 Parent(s): 2cca04a

Upload 3 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ bird_weights.weights.keras filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import tensorflow as tf
3
+ from tensorflow.keras.applications import VGG16
4
+ from tensorflow.keras.models import Sequential
5
+ from tensorflow.keras.layers import Dense, GlobalAveragePooling2D, Dropout
6
+ from PIL import Image
7
+ import numpy as np
8
+
9
+ # --- SAYFA AYARLARI ---
10
+ st.set_page_config(page_title="Bird Identifier / Kuş Tanımlayıcı", layout="wide", page_icon="🐦")
11
+
12
+ # --- MODEL YÜKLEME (TİTREMEYİ ÖNLEYEN ÖNBELLEK) ---
13
+ @st.cache_resource
14
+ def load_bird_model():
15
+ # Model mimarisini kur
16
+ base_model = VGG16(weights=None, include_top=False, input_shape=(128, 128, 3))
17
+ model = Sequential([
18
+ base_model,
19
+ GlobalAveragePooling2D(),
20
+ Dense(256, activation='relu'),
21
+ Dropout(0.6),
22
+ Dense(25, activation='softmax')
23
+ ])
24
+ # Ağırlıkları yükle (Dosya adının aynı olduğundan emin ol)
25
+ model.load_weights("bird_weights.weights.h5")
26
+ return model
27
+
28
+ # Uygulama başladığında modeli bir kez yükle ve hafızada tut
29
+ model = load_bird_model()
30
+
31
+ # --- KUŞ TÜRLERİ LİSTESİ ---
32
+ class_names = [
33
+ 'Alexandrine Parakeet', 'Asian Green Bee-Eater', 'Baya Weaver', 'Black Drongo',
34
+ 'Black-Crowned Night Heron', 'Blue-Throated Barbet', 'Brown-Headed Barbet',
35
+ 'Cattle Egret', 'Common Kingfisher', 'Common Myna', 'Common Rosefinch',
36
+ 'Common Tailorbird', 'Coppersmith Barbet', 'Grey Heron', 'Hoopoe',
37
+ 'Indian Peafowl', 'Indian Roller', 'Indian Silverbill', 'Jungle Babbler',
38
+ 'Little Egret', 'Pied Kingfisher', 'Purple Sunbird', 'Red-Wattled Lapwing',
39
+ 'Slaty-Headed Parakeet', 'White-Throated Kingfisher'
40
+ ]
41
+
42
+ # --- YAN PANEL (SIDEBAR) ---
43
+ with st.sidebar:
44
+ st.title("Settings / Ayarlar ⚙️")
45
+ st.divider()
46
+ st.subheader("Recognized Species / Tanınan Türler 🐦")
47
+ # Türleri alfabetik listele
48
+ for name in sorted(class_names):
49
+ st.write(f"• {name}")
50
+
51
+ # --- ANA EKRAN ---
52
+ st.title("Bird Species Classifier / Kuş Türü Sınıflandırıcı 🐦")
53
+ st.write("Identify 25 types of Indian birds / 25 farklı Hint kuş türünü tanımlayın.")
54
+ st.divider()
55
+
56
+ # Ekranı ikiye böl
57
+ col1, col2 = st.columns([1, 1])
58
+
59
+ with col1:
60
+ st.subheader("Upload Image / Resim Yükle 📤")
61
+ uploaded_file = st.file_uploader("Choose a file / Dosya seçin...", type=["jpg", "jpeg", "png"])
62
+
63
+ if uploaded_file is not None:
64
+ image = Image.open(uploaded_file)
65
+ st.image(image, caption="Uploaded Image / Yüklenen Resim", use_container_width=True)
66
+
67
+ with col2:
68
+ st.subheader("Analysis Results / Analiz Sonuçları 🔍")
69
+
70
+ if uploaded_file is not None:
71
+ if st.button("Predict / Tahmin Et"):
72
+ with st.spinner("Analyzing... / Analiz ediliyor..."):
73
+ # Görüntü hazırlama
74
+ img = image.resize((128, 128))
75
+ img_array = np.array(img).astype('float32') / 255.0
76
+ img_array = np.expand_dims(img_array, axis=0)
77
+
78
+ # Tahmin yap
79
+ preds = model.predict(img_array)
80
+ class_idx = np.argmax(preds[0])
81
+ confidence = np.max(preds[0]) * 100
82
+
83
+ # Sonuç gösterimi
84
+ st.success(f"**Result / Sonuç:** {class_names[class_idx]}")
85
+ st.write(f"**Confidence / Güven:** %{confidence:.2f}")
86
+ st.progress(int(confidence))
87
+
88
+ # Başarı kutlaması
89
+ st.balloons()
90
+ else:
91
+ st.info("Please upload a bird photo to start. / Başlamak için lütfen bir kuş fotoğrafı yükleyin.")
92
+
93
+ st.divider()
94
+ st.caption("Deep Learning Project / Derin Öğrenme Projesi - 2024")
bird_weights.weights.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7fb5754c8ac97a406149c50d06ce031aa9aebac0212d0030fb3e1ad543bdc151
3
+ size 117223360
bird_weights.weights.keras ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:29392f0e270d399ee5a753485038f819cdac618666f6dc8e198a075ece780428
3
+ size 117244901