ErenKontas commited on
Commit
b0b29e1
1 Parent(s): 424c7f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -29
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 cv2
6
- import pandas as pd
7
-
8
- model = load_model('Bulut_CNN_model.keras')
9
-
10
- def process_image(img):
11
- img = img.resize((64, 64))
12
- img = img.convert('RGB')
13
- img = np.array(img)
14
- img = img / 255.0
15
- img = np.expand_dims(img, axis=0)
16
- return img
17
-
18
- df = pd.read_csv('train.csv')
19
- class_names = df['label'].unique()
20
- st.write("Resim seç ve model ne olduğunu tahmin etsin")
21
- file = st.file_uploader('Bir resim seç', type=['jpg', 'jpeg', 'png'])
22
-
23
- if file is not None:
24
- img = Image.open(file)
25
- st.image(img, caption='Yüklenen resim', use_column_width=True)
26
- image = process_image(img)
27
- prediction = model.predict(image)
28
- predicted_class = np.argmax(prediction, axis=1)[0]
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]}")