| import streamlit as st |
| import numpy as np |
| from PIL import Image |
| import tensorflow as tf |
|
|
| |
| st.set_page_config(page_title="Grape Disease Detection", layout="wide") |
|
|
| |
| |
| |
| @st.cache_resource |
| def load_my_model(): |
| return tf.keras.models.load_model("grape_disease_model.h5") |
|
|
| model = load_my_model() |
| class_names = ['Black Rot', 'ESCA', 'Healthy', 'Leaf Blight'] |
|
|
| |
| |
| |
| with st.sidebar: |
| st.header("📌 Hastalık Bilgileri / Info") |
| |
| st.markdown("### 1. Black Rot") |
| st.caption("🇹🇷 Kara Leke/Çürüklük: Mantar kaynaklı bir hastalık.") |
| st.caption("🇺🇸 Fungal disease causing dark spots.") |
| |
| st.markdown("### 2. ESCA") |
| st.caption("🇹🇷 Gövde Kanseri: Bağlarda görülen karmaşık bir mantar hastalığı.") |
| st.caption("🇺🇸 Complex fungal disease affecting the vines.") |
| |
| st.markdown("### 3. Healthy") |
| st.caption("🇹🇷 Sağlıklı: Yaprağın herhangi bir hastalık taşımadığını ifade eder.") |
| st.caption("🇺🇸 Indicates the leaf is free from disease.") |
| |
| st.markdown("### 4. Leaf Blight") |
| st.caption("🇹🇷 Yaprak Yanıklığı: Yapraklarda kurumaya ve lekelere neden olur.") |
| st.caption("🇺🇸 Causes browning and spotting on leaves.") |
| |
| st.divider() |
| st.write("Academic Project - 2026") |
|
|
| |
| |
| |
| st.title("🍇 Üzüm Yaprağı Hastalık Tespiti") |
| st.subheader("Grape Leaf Disease Detection") |
| st.markdown("---") |
|
|
| |
| col1, col2 = st.columns([1, 1]) |
|
|
| with col1: |
| st.markdown("### 📷 Fotoğraf Yükle / Upload Image") |
| |
| uploaded_file = st.file_uploader("Bir yaprak fotoğrafı seçin / Select a leaf image", type=["jpg", "png", "jpeg"]) |
|
|
| if uploaded_file is not None: |
| image = Image.open(uploaded_file).convert("RGB") |
| |
| with col1: |
| st.image(image, caption="Yüklenen Resim / Uploaded Image", use_container_width=True) |
|
|
| |
| with col2: |
| st.markdown("### 🔍 Analiz Sonucu / Analysis Result") |
| |
| with st.spinner('Analiz ediliyor / Analyzing...'): |
| |
| img_resized = image.resize((170, 170)) |
| img_array = np.array(img_resized) / 255.0 |
| img_array = np.expand_dims(img_array, axis=0) |
|
|
| |
| prediction = model.predict(img_array) |
| class_index = np.argmax(prediction) |
| confidence = np.max(prediction) * 100 |
|
|
| |
| st.success(f"**Tahmin / Prediction:** {class_names[class_index]}") |
| st.metric(label="Güven Oranı / Confidence", value=f"%{confidence:.2f}") |
| st.progress(int(confidence)) |
|
|
| |
| |
| if confidence > 50: |
| st.balloons() |
| st.toast(f"Tahmin Başarılı: {class_names[class_index]}", icon='🎉') |
|
|
| |
| st.info(""" |
| **TR:** Bu sistem yapay zeka kullanarak analiz yapmaktadır. |
| **EN:** This system uses AI for leaf analysis. |
| """) |
| else: |
| with col2: |
| st.write("👈 Lütfen analiz için bir fotoğraf yükleyin.") |
| st.write("👈 Please upload a photo for analysis.") |