Spaces:
Sleeping
Sleeping
Commit
·
d720c97
1
Parent(s):
d4048bd
Upload 3 files
Browse files- efficent_net224B0.h5 +3 -0
- requirements.txt +4 -0
- streamlit_sem.py +52 -0
efficent_net224B0.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:78e599dd31a9edfd06818679e8b66936c1643783df2bab6914899f811ad92dd8
|
3 |
+
size 31033688
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit==1.23.1
|
2 |
+
pandas==1.5.3
|
3 |
+
plotly==5.0.0
|
4 |
+
tensorflow==2.12.0
|
streamlit_sem.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|