Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,56 +1,57 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
from PIL import Image
|
| 3 |
-
import numpy as np
|
| 4 |
-
from tensorflow.keras.models import load_model
|
| 5 |
-
|
| 6 |
-
# Üzüm yaprağı çeşitleri
|
| 7 |
-
leaf_varieties = ['ESCA', 'Healthy', 'Leaf Blight', 'Black Rot']
|
| 8 |
-
|
| 9 |
-
# Modeli yükleme
|
| 10 |
-
model = load_model('leafmodel.h5')
|
| 11 |
-
model.summary()
|
| 12 |
-
|
| 13 |
-
def process_img(img):
|
| 14 |
-
img = img.
|
| 15 |
-
img =
|
| 16 |
-
img = np.
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
st.
|
| 21 |
-
|
| 22 |
-
"
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from PIL import Image
|
| 3 |
+
import numpy as np
|
| 4 |
+
from tensorflow.keras.models import load_model
|
| 5 |
+
|
| 6 |
+
# Üzüm yaprağı çeşitleri
|
| 7 |
+
leaf_varieties = ['ESCA', 'Healthy', 'Leaf Blight', 'Black Rot']
|
| 8 |
+
|
| 9 |
+
# Modeli yükleme
|
| 10 |
+
model = load_model('leafmodel.h5')
|
| 11 |
+
model.summary()
|
| 12 |
+
|
| 13 |
+
def process_img(img):
|
| 14 |
+
img = img.convert('RGB') # Resmi RGB formatına dönüştürme
|
| 15 |
+
img = img.resize((128, 128), Image.LANCZOS) # 128x128 piksel boyutuna dönüştürme
|
| 16 |
+
img = np.array(img) / 255.0 # Normalize etme
|
| 17 |
+
img = np.expand_dims(img, axis=0) # Resme boyut ekleme
|
| 18 |
+
return img
|
| 19 |
+
|
| 20 |
+
st.title("Üzüm Yaprağı Çeşidi Sınıflandırması :leaves:")
|
| 21 |
+
st.write(
|
| 22 |
+
"Bir üzüm yaprağı resmi seçin ve modelimiz, bu resmin hangi üzüm yaprağı çeşidinden olduğunu tahmin etsin. 🖼️📊\n"
|
| 23 |
+
"Upload an image and the model will predict which grape leaf variety your image shows."
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
# Stil ayarları
|
| 27 |
+
st.markdown("""
|
| 28 |
+
<style>
|
| 29 |
+
.reportview-container {
|
| 30 |
+
background: #F0F2F6;
|
| 31 |
+
}
|
| 32 |
+
.sidebar .sidebar-content {
|
| 33 |
+
background: #E0E0E0;
|
| 34 |
+
}
|
| 35 |
+
.css-18e3th9 {
|
| 36 |
+
font-size: 1.25em;
|
| 37 |
+
color: #333;
|
| 38 |
+
}
|
| 39 |
+
</style>
|
| 40 |
+
""", unsafe_allow_html=True)
|
| 41 |
+
|
| 42 |
+
file = st.file_uploader("Resim Yükle & Bir resim seçiniz", type=['png', 'jpg', 'jpeg'])
|
| 43 |
+
|
| 44 |
+
if file is not None:
|
| 45 |
+
img = Image.open(file)
|
| 46 |
+
st.image(img, caption="Yüklenen Resim", use_column_width=True)
|
| 47 |
+
|
| 48 |
+
result = process_img(img)
|
| 49 |
+
prediction = model.predict(result)
|
| 50 |
+
prediction_class = np.argmax(prediction) # En yüksek tahmin edilen sınıf
|
| 51 |
+
|
| 52 |
+
# Sınıf isimleri
|
| 53 |
+
result_text = leaf_varieties[prediction_class]
|
| 54 |
+
|
| 55 |
+
st.write(f"**Sonuç:** {result_text}")
|
| 56 |
+
else:
|
| 57 |
+
st.write("Lütfen bir resim yükleyin.")
|