File size: 1,235 Bytes
0c8b87f
5019eca
 
 
 
d75edf0
5019eca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0c8b87f
5019eca
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
import streamlit as st
import tensorflow as tf
import numpy as np
from PIL import Image

model = tf.keras.models.load_model("src/hurma_cnn_model.h5")

# Sınıf isimlerini yazıyoruz

class_names = [
    "Ajwa",
    "Galaxy",
    "Medjool",
    "Meneifi",
    "Nabtat Ali",
    "Rutab",
    "Shaishe",
    "Sokari",
    "Sugaey"
]

st.title("Hurma Sınıflandırma Uygulaması")
st.write("Bir hurma görseli yükleyin, model hurma türünü tahmin etsin.")

# kullanıcıdan görsel alıyoruz
uploaded_file = st.file_uploader("Bir hurma resmi yükleyin", type=["jpg", "jpeg", "png"])

# Şimdi yüklenen resmi işleyip tahmin yapıyoruz

if uploaded_file is not None:

    image = Image.open(uploaded_file).convert("RGB")

    st.image(image, caption="Yüklenen Görsel", use_container_width=True)

    image = image.resize((128, 128))

    image_array = np.array(image) / 255.0

    image_array = np.expand_dims(image_array, axis=0)

    prediction = model.predict(image_array)

    predicted_index = np.argmax(prediction)

    predicted_class = class_names[predicted_index]

    confidence = np.max(prediction) * 100

    st.success(f"Tahmin Edilen Hurma Türü: {predicted_class}")

    st.write(f"Güven Oranı: %{confidence:.2f}")