File size: 931 Bytes
093d452
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import streamlit as st
from streamlit_drawable_canvas import st_canvas
import joblib
import numpy as np
from PIL import Image

st.title("MNIST Rakam Tanıma Uygulaması")

# Modeli yükle
model = joblib.load("mnist_model.joblib")

st.write("Aşağıdaki kutuya bir rakam çizin:")

# Çizim alanı oluşturma
canvas_result = st_canvas(
    fill_color="rgba(255, 255, 255, 1)",
    stroke_width=10,
    stroke_color="#FFFFFF",
    background_color="#000000",
    height=200,
    width=200,
    drawing_mode="freedraw",
    key="canvas",
)

if canvas_result.image_data is not None:
    # Görüntüyü MNIST formatına (28x28) dönüştür
    img = Image.fromarray(canvas_result.image_data.astype('uint8')).convert('L')
    img = img.resize((28, 28))
    img_array = np.array(img).reshape(1, -1)

    if st.button("Tahmin Et"):
        prediction = model.predict(img_array)
        st.header(f"Tahmin Edilen Rakam: {prediction[0]}")