ESMATUGBA commited on
Commit
0eb6bd2
·
verified ·
1 Parent(s): 2051f04

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +90 -0
  2. grape_disease_model.h5 +3 -0
app.py ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ from PIL import Image
4
+ import tensorflow as tf
5
+
6
+ # Sayfa Genişliği Ayarı
7
+ st.set_page_config(page_title="Grape Disease Detection", layout="wide")
8
+
9
+ # -----------------------------
10
+ # MODEL YÜKLEME
11
+ # -----------------------------
12
+ @st.cache_resource # Modelin her seferinde tekrar yüklenmesini engeller, hızı artırır
13
+ def load_my_model():
14
+ return tf.keras.models.load_model("grape_disease_model.h5")
15
+
16
+ model = load_my_model()
17
+
18
+ # Sınıf İsimleri
19
+ class_names = ['Black Rot', 'ESCA', 'Healthy', 'Leaf Blight']
20
+
21
+ # -----------------------------
22
+ # SOL PANEL (SIDEBAR) - BİLGİLENDİRME
23
+ # -----------------------------
24
+ with st.sidebar:
25
+ st.header("Hastalık Bilgileri / Disease Info")
26
+
27
+ st.markdown("""
28
+ **1. Black Rot (Kara Leke/Çürüklük):** - 🇹🇷 Mantar kaynaklı bir hastalık.
29
+ - 🇺🇸 A fungal disease caused by Guignardia bidwellii.
30
+
31
+ ---
32
+ **2. ESCA (Gövde Kanseri):** - 🇹🇷 Bağlarda görülen karmaşık bir mantar hastalığı.
33
+ - 🇺🇸 A complex fungal disease affecting the trunk and leaves.
34
+
35
+ ---
36
+ **3. Healthy (Sağlıklı):** - 🇹🇷 Yaprağın herhangi bir hastalık taşımadığını ifade eder.
37
+ - 🇺🇸 Indicates that the leaf is healthy and disease-free.
38
+
39
+ ---
40
+ **4. Leaf Blight (Yaprak Yanıklığı):** - 🇹🇷 Yapraklarda kurumaya ve lekelere neden olan bir hastalık türü.
41
+ - 🇺🇸 A disease causing browning and spotting on leaves.
42
+ """)
43
+
44
+ # -----------------------------
45
+ # ANA BAŞLIKLAR (ÇİFT DİLLİ)
46
+ # -----------------------------
47
+ st.title("🍇 Üzüm Yaprağı Hastalık Tespiti")
48
+ st.subheader("Grape Leaf Disease Detection")
49
+ st.write("---")
50
+
51
+ # Sayfayı iki sütuna bölelim: Sol taraf yükleme, Sağ taraf sonuç
52
+ col1, col2 = st.columns(2)
53
+
54
+ with col1:
55
+ st.markdown("### 📷 Fotoğraf Yükle / Upload Image")
56
+ uploaded_file = st.file_uploader("", type=["jpg", "png", "jpeg"])
57
+
58
+ if uploaded_file is not None:
59
+ image = Image.open(uploaded_file).convert("RGB")
60
+ st.image(image, caption="Yüklenen Resim / Uploaded Image", use_container_width=True)
61
+
62
+ # Ön İşleme (Preprocess)
63
+ img = image.resize((170, 170))
64
+ img = np.array(img) / 255.0
65
+ img = np.expand_dims(img, axis=0)
66
+
67
+ # Tahmin (Prediction)
68
+ with st.spinner('Teşhis konuluyor / Diagnosing...'):
69
+ pred = model.predict(img)
70
+ class_index = np.argmax(pred)
71
+ confidence = np.max(pred) * 100
72
+
73
+ with col2:
74
+ st.markdown("### 🔍 Analiz Sonucu / Analysis Result")
75
+
76
+ # Sonuç Kutusu (Görselleştirme)
77
+ st.success(f"**Tahmin / Prediction:** {class_names[class_index]}")
78
+
79
+ # Güven Skoru Göstergesi
80
+ st.metric(label="Güven Oranı / Confidence", value=f"%{confidence:.2f}")
81
+
82
+ # İlerleme Çubuğu (Progress Bar)
83
+ st.progress(int(confidence))
84
+
85
+ # Bilgi Notu
86
+ st.info("""
87
+ **TR:** Bu sistem yapay zeka kullanarak analiz yapmaktadır. Kesin teşhis için uzman görüşü alınız.
88
+
89
+ **EN:** This system uses AI for analysis. Please consult an expert for definitive diagnosis.
90
+ """)
grape_disease_model.h5 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:09cf0b200ebbcd4e198a083fb3dafe20f5441bc332adc208ebc0db2aaa48c2bf
3
+ size 59775744