Spaces:
Sleeping
Sleeping
zaferturan
commited on
Commit
•
5523ece
1
Parent(s):
5fa89a2
Upload 3 files
Browse files- .gitattributes +1 -0
- app.py +51 -0
- model.keras +3 -0
- requirements.txt +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
model.keras filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from streamlit_drawable_canvas import st_canvas
|
3 |
+
import numpy as np
|
4 |
+
from PIL import Image
|
5 |
+
import tensorflow as tf
|
6 |
+
from tensorflow.keras.models import load_model
|
7 |
+
|
8 |
+
with st.spinner("Model Yükleniyor. Lütfen bekleyiniz!.."):
|
9 |
+
model = load_model("model.keras")
|
10 |
+
|
11 |
+
st.title("Digit Recognition :writing_hand:")
|
12 |
+
st.write("El yazısı rakam tahmin aracı")
|
13 |
+
st.write("Aşağıdaki alana bir rakam çizin. Model kaç olduğunu tahmin etsin.")
|
14 |
+
|
15 |
+
rakamlar=[":zero:", ":one:", ":two:", ":three:", ":four:", ":five:", ":six:", ":seven:", ":eight:", ":nine:"]
|
16 |
+
|
17 |
+
col1, col2 = st.columns([1,2])
|
18 |
+
|
19 |
+
with col1:
|
20 |
+
canvas_result = st_canvas(
|
21 |
+
fill_color="rgb(0, 0, 0)", # Başlangıç dolgu rengi siyah
|
22 |
+
stroke_width=20,
|
23 |
+
stroke_color="rgb(255, 255, 255)", # Başlangıç çizgi rengi beyaz
|
24 |
+
background_color="rgb(0, 0, 0)", # Arka plan rengi siyah
|
25 |
+
update_streamlit=True, # update_streamlit parametresini False olarak ayarlayın
|
26 |
+
width=200,
|
27 |
+
height=200,
|
28 |
+
drawing_mode="freedraw",
|
29 |
+
key="canvas",
|
30 |
+
)
|
31 |
+
|
32 |
+
with col2:
|
33 |
+
if st.button("Tahmin Et"):
|
34 |
+
col21, col22 = st.columns(2)
|
35 |
+
with col21:
|
36 |
+
image_data = np.array(canvas_result.image_data)
|
37 |
+
image_data = image_data.astype(np.uint8)
|
38 |
+
image = Image.fromarray(image_data)
|
39 |
+
image = image.resize((28, 28)).convert("L")
|
40 |
+
image = np.array(image).reshape((1, 28, 28, 1)) / 255.0
|
41 |
+
|
42 |
+
prediction = model.predict(image)
|
43 |
+
predicted_class = np.argmax(prediction)
|
44 |
+
st.title("Sonuç")
|
45 |
+
st.title(rakamlar[predicted_class])
|
46 |
+
|
47 |
+
with col22:
|
48 |
+
st.write("Diğer değerler:")
|
49 |
+
for i in range(10):
|
50 |
+
if np.round(prediction[0][i], 3)>0.0:
|
51 |
+
st.write(i, ":",np.round(prediction[0][i] * 100, 2), "%")
|
model.keras
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3b33282259fee601747776befea2f6e4c6087aeb87e647b0fe29b7dd52dc7d29
|
3 |
+
size 1617208
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
tensorflow
|
3 |
+
streamlit-drawable-canvas
|