Spaces:
Sleeping
Sleeping
| 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]}") |