File size: 1,820 Bytes
95b119d
 
 
 
 
 
 
 
 
a9efa55
95b119d
 
 
 
 
d676f3a
95b119d
 
 
 
 
 
 
 
 
a9efa55
95b119d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 tensorflow.keras.preprocessing import image
from tensorflow.keras.applications.efficientnet import preprocess_input
#from tensorflow.keras.applications.resnet50 import preprocess_input
import plotly.express as px

# model yükle
model = tf.keras.models.load_model("efficent_netB7.h5")

# Etiketler
waste_labels = {0: 'Fibres', 1: 'Nanowires', 2: 'Particles', 3: 'Powder'}

# uygulama yükle
st.title("SEM Görüntü Sınıflandırma Uygulaması | ")
st.write("Lütfen bir SEM görüntüsü yükleyin. - (Fibres, Nanowires, Powder,Particles)")

# giriş yap
uploaded_image = st.file_uploader("SEM Görüntüsünü Yükleyin", type=["jpg", "png", "jpeg"])

# resim işleme

if uploaded_image is not None:
    # Görüntüyü modelin girdi boyutuna yeniden boyutlandırın
    img = image.load_img(uploaded_image, target_size=(600, 600))
    img = image.img_to_array(img)
    img = np.expand_dims(img, axis=0)
    img = preprocess_input(img)
    

    # tahmin
    prediction = model.predict(img)
    predicted_class = np.argmax(prediction)

    # Sonuç
    st.image(uploaded_image, caption='Yüklenen Görüntü', use_column_width=True)
    st.write(f"Tahmin Edilen Sınıf: {waste_labels[predicted_class]}")

    # görselleştirme
    st.write("Tahmin İhtimalleri:")
    labels = list(waste_labels.values())
    probabilities = prediction[0] * 100  # İhtimalleri yüzde olarak hesapla

    # Çubuk grafik
    fig_bar = px.bar(x=labels, y=probabilities, labels={'x': 'Sınıf', 'y': 'Yüzde (%)'},
                     title="Tahmin İhtimalleri (Çubuk Grafik)")
    st.plotly_chart(fig_bar)

    # Pasta grafiği
    fig_pie = px.pie(values=probabilities, names=labels, title="Tahmin İhtimalleri (Pasta Grafiği)")
    st.plotly_chart(fig_pie)