Spaces:
Sleeping
Sleeping
ErenKontas
commited on
Commit
•
b0b29e1
1
Parent(s):
424c7f6
Update app.py
Browse files
app.py
CHANGED
@@ -1,29 +1,28 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
from tensorflow.keras.models import load_model
|
3 |
-
from PIL import Image
|
4 |
-
import numpy as np
|
5 |
-
import
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
img = img.
|
12 |
-
img =
|
13 |
-
img =
|
14 |
-
img = img
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
st.
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
img =
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
st.write(f"Tahmin edilen sınıf: {class_names[predicted_class]}")
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from tensorflow.keras.models import load_model
|
3 |
+
from PIL import Image
|
4 |
+
import numpy as np
|
5 |
+
import pandas as pd
|
6 |
+
|
7 |
+
model = load_model('Bulut_CNN_model.keras')
|
8 |
+
|
9 |
+
def process_image(img):
|
10 |
+
img = img.resize((64, 64))
|
11 |
+
img = img.convert('RGB')
|
12 |
+
img = np.array(img)
|
13 |
+
img = img / 255.0
|
14 |
+
img = np.expand_dims(img, axis=0)
|
15 |
+
return img
|
16 |
+
|
17 |
+
df = pd.read_csv('train.csv')
|
18 |
+
class_names = df['label'].unique()
|
19 |
+
st.write("Resim seç ve model ne olduğunu tahmin etsin")
|
20 |
+
file = st.file_uploader('Bir resim seç', type=['jpg', 'jpeg', 'png'])
|
21 |
+
|
22 |
+
if file is not None:
|
23 |
+
img = Image.open(file)
|
24 |
+
st.image(img, caption='Yüklenen resim', use_column_width=True)
|
25 |
+
image = process_image(img)
|
26 |
+
prediction = model.predict(image)
|
27 |
+
predicted_class = np.argmax(prediction, axis=1)[0]
|
28 |
+
st.write(f"Tahmin edilen sınıf: {class_names[predicted_class]}")
|
|