import streamlit as st import numpy as np import cv2 from tensorflow.keras.models import load_model from tensorflow.keras.preprocessing import image # Modeli yükle model = load_model('GTSRB.h5') # Sınıfları tanımlayın (örnek) class_names = [ 'Speed limit (20km/h)', 'Speed limit (30km/h)', 'Speed limit (50km/h)', 'Speed limit (60km/h)', 'Speed limit (70km/h)', 'Speed limit (80km/h)', 'End of speed limit (80km/h)', 'Speed limit (100km/h)', 'Speed limit (120km/h)', 'No passing', 'No passing veh over 3.5 tons', 'Right-of-way at intersection', 'Priority road', 'Yield', 'Stop', 'No vehicles', 'Veh > 3.5 tons prohibited', 'No entry', 'General caution', 'Dangerous curve left', 'Dangerous curve right', 'Double curve', 'Bumpy road', 'Slippery road', 'Road narrows on the right', 'Road work', 'Traffic signals', 'Pedestrians', 'Children crossing', 'Bicycles crossing', 'Beware of ice/snow', 'Wild animals crossing', 'End speed + passing limits', 'Turn right ahead', 'Turn left ahead', 'Ahead only', 'Go straight or right', 'Go straight or left', 'Keep right', 'Keep left', 'Roundabout mandatory', 'End of no passing', 'End no passing veh > 3.5 tons' ] st.title("Trafik İşareti Tanıma Uygulaması") # Resim yükleme uploaded_file = st.file_uploader("Resim yükleyin", type=["jpg", "png", "jpeg"]) if uploaded_file is not None: # Resmi yükle img = image.load_img(uploaded_file, target_size=(32, 32)) st.image(img, caption='Yüklenen Resim', use_column_width=True) # Resmi diziye dönüştür img_array = image.img_to_array(img) img_array = np.expand_dims(img_array, axis=0) / 255.0 # Normalizasyon # Tahmin yap predictions = model.predict(img_array) predicted_class = np.argmax(predictions, axis=1) st.write(f"Tahmin Edilen Sınıf: {class_names[predicted_class[0]]}") # Kamera ile resim çekme st.write("Alternatif olarak kamera ile resim çekebilirsiniz.") # Kamera girdisi (Bu kısım tarayıcıda çalışmayabilir, yerine yerel bir çözüm gerekebilir) if st.button("Kameradan Resim Çek"): st.warning("Bu özellik tarayıcı desteklemiyor. Lütfen bir resim yükleyin.") # Uygulamayı çalıştırmak için terminalde şu komutu kullanın: # streamlit run your_script_name.py