Defkhan5960 commited on
Commit
3cafaee
·
1 Parent(s): d720c97

Delete streamlit_sem.py

Browse files
Files changed (1) hide show
  1. streamlit_sem.py +0 -52
streamlit_sem.py DELETED
@@ -1,52 +0,0 @@
1
- import streamlit as st
2
- import tensorflow as tf
3
- import numpy as np
4
- from tensorflow.keras.preprocessing import image
5
- from tensorflow.keras.applications.efficientnet import preprocess_input
6
- #from tensorflow.keras.applications.resnet50 import preprocess_input
7
- import plotly.express as px
8
-
9
- # model yükle
10
- model = tf.keras.models.load_model("efficent_net224B0.h5")
11
-
12
- # Etiketler
13
- waste_labels = {0: 'Fibres', 1: 'Nanowires', 2: 'Particles', 3: 'Powder'}
14
-
15
- # uygulama yükle
16
- st.title("SEM Görüntü Sınıflandırma Uygulaması")
17
- st.write("Lütfen bir SEM görüntüsü yükleyin. - (Fibres, Nanowires, Powder,Particles)")
18
-
19
- # giriş yap
20
- uploaded_image = st.file_uploader("SEM Görüntüsünü Yükleyin", type=["jpg", "png", "jpeg"])
21
-
22
- # resim işleme
23
-
24
- if uploaded_image is not None:
25
- # Görüntüyü modelin girdi boyutuna yeniden boyutlandırın
26
- img = image.load_img(uploaded_image, target_size=(224, 224))
27
- img = image.img_to_array(img)
28
- img = np.expand_dims(img, axis=0)
29
- img = preprocess_input(img)
30
-
31
-
32
- # tahmin
33
- prediction = model.predict(img)
34
- predicted_class = np.argmax(prediction)
35
-
36
- # Sonuç
37
- st.image(uploaded_image, caption='Yüklenen Görüntü', use_column_width=True)
38
- st.write(f"Tahmin Edilen Sınıf: {waste_labels[predicted_class]}")
39
-
40
- # görselleştirme
41
- st.write("Tahmin İhtimalleri:")
42
- labels = list(waste_labels.values())
43
- probabilities = prediction[0] * 100 # İhtimalleri yüzde olarak hesapla
44
-
45
- # Çubuk grafik
46
- fig_bar = px.bar(x=labels, y=probabilities, labels={'x': 'Sınıf', 'y': 'Yüzde (%)'},
47
- title="Tahmin İhtimalleri (Çubuk Grafik)")
48
- st.plotly_chart(fig_bar)
49
-
50
- # Pasta grafiği
51
- fig_pie = px.pie(values=probabilities, names=labels, title="Tahmin İhtimalleri (Pasta Grafiği)")
52
- st.plotly_chart(fig_pie)