Spaces:
Sleeping
Sleeping
Download app.py from serhatkagans/asd: direct link, hf CLI and curl.
- Browser
- Download file 931 Bytes
-
https://huggingface.co/spaces/serhatkagans/asd/resolve/main/app.py
- Command line
-
hf download hf://spaces/serhatkagans/asd/app.py
-
curl -L -o app.py https://huggingface.co/spaces/serhatkagans/asd/resolve/main/app.py
931 Bytes
| import streamlit as st | |
| import pickle | |
| from PIL import Image | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| import os | |
| # Başlık | |
| st.title("Rakam Tanıma Uygulaması") | |
| # Dosya yolunu belirle | |
| model_path = os.path.join(os.path.dirname(__file__), 'model.pkl') | |
| # Modeli yükle | |
| with open(model_path, 'rb') as file: | |
| loaded_model = pickle.load(file) | |
| # Kullanıcıdan resim yüklemesi iste | |
| uploaded_file = st.file_uploader("Lütfen bir resim dosyası yükleyin", type=["png", "jpg", "jpeg"]) | |
| if uploaded_file is not None: | |
| # Resmi göster | |
| img = Image.open(uploaded_file) | |
| st.image(img, caption='Yüklenen Resim', use_column_width=True) | |
| # Resmi işleme | |
| img = img.resize((28, 28)) | |
| img = img.convert("L") | |
| img_array = np.array(img).reshape(1, -1) | |
| # Tahmin yap | |
| pred = loaded_model.predict(img_array) | |
| st.write(f"Tahmin edilen rakam: {pred[0]}") | |
| else: | |
| st.write("Lütfen bir resim yükleyin.") |