Spaces:
Paused
Paused
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +21 -39
src/streamlit_app.py
CHANGED
|
@@ -1,40 +1,22 @@
|
|
| 1 |
-
import
|
|
|
|
|
|
|
| 2 |
import numpy as np
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
radius = indices
|
| 22 |
-
|
| 23 |
-
x = radius * np.cos(theta)
|
| 24 |
-
y = radius * np.sin(theta)
|
| 25 |
-
|
| 26 |
-
df = pd.DataFrame({
|
| 27 |
-
"x": x,
|
| 28 |
-
"y": y,
|
| 29 |
-
"idx": indices,
|
| 30 |
-
"rand": np.random.randn(num_points),
|
| 31 |
-
})
|
| 32 |
-
|
| 33 |
-
st.altair_chart(alt.Chart(df, height=700, width=700)
|
| 34 |
-
.mark_point(filled=True)
|
| 35 |
-
.encode(
|
| 36 |
-
x=alt.X("x", axis=None),
|
| 37 |
-
y=alt.Y("y", axis=None),
|
| 38 |
-
color=alt.Color("idx", legend=None, scale=alt.Scale()),
|
| 39 |
-
size=alt.Size("rand", legend=None, scale=alt.Scale(range=[1, 150])),
|
| 40 |
-
))
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from tensorflow.keras.models import load_model
|
| 3 |
+
from PIL import Image
|
| 4 |
import numpy as np
|
| 5 |
+
model=load_model('src/skin_cancer_model.h5')
|
| 6 |
+
def process_image(img):
|
| 7 |
+
img=img.resize((170,170))
|
| 8 |
+
img=np.array(img)
|
| 9 |
+
img=img/255.0
|
| 10 |
+
img=np.expand_dims(img,axis=0)
|
| 11 |
+
return img
|
| 12 |
+
st.title('Deri Kanser resmi sınıflandırma :cancer:')
|
| 13 |
+
st.write('Resim seç, model kanser olup olmadığını tahmin etsin!')
|
| 14 |
+
file=st.file_uploader('Bir resim yükle',type=['jpg','jpeg','png'])
|
| 15 |
+
if file is not None: # Resim yuklenmisse burasi calisacak
|
| 16 |
+
img=Image.open(file)
|
| 17 |
+
st.image(img, caption='Yuklenen Resim')
|
| 18 |
+
image=process_image(img)
|
| 19 |
+
prediction=model.predict(image)
|
| 20 |
+
predicted_class = 1 if prediction > 0.5 else 0
|
| 21 |
+
class_names=['Kanser değil','Kanser']
|
| 22 |
+
st.write(class_names[predicted_class])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|