Problem Statement
With the rise of autonomous vehicles, recognizing road signs accurately and in real-time is crucial for safety and navigation. This project aims to develop an AI-based road sign detection system that can detect and classify road signs from images using machine learning techniques.
Users/Stakeholders
Objectives
Features
AI Used
Dataset
Solution
The system will be implemented using Python, leveraging CNN models to detect and classify road signs from images or video feeds. The project can also be extended to work with live video from vehicle cameras.
import numpy as np
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Conv2D, MaxPooling2D, Flatten, Dense
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelBinarizer
from tensorflow.keras.preprocessing.image import ImageDataGenerator
X = np.load(‘X.npy’) # Array of images
y = np.load(‘y.npy’) # Corresponding labels (road sign classes)
X = X / 255.0
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
label_binarizer = LabelBinarizer()
y_train = label_binarizer.fit_transform(y_train)
y_test = label_binarizer.transform(y_test)
datagen = ImageDataGenerator(
rotation_range=10,
zoom_range=0.1,
width_shift_range=0.1,
height_shift_range=0.1
)
datagen.fit(X_train)
model = Sequential([
Conv2D(32, (3, 3), activation=’relu’, input_shape=X_train.shape[1:]),
MaxPooling2D(pool_size=(2, 2)),
Conv2D(64, (3, 3), activation=’relu’),
MaxPooling2D(pool_size=(2, 2)),
Flatten(),
Dense(128, activation=’relu’),
Dense(len(label_binarizer.classes_), activation=’softmax’)
])
model.compile(optimizer=’adam’, loss=’categorical_crossentropy’, metrics=[‘accuracy’])
model.fit(datagen.flow(X_train, y_train, batch_size=32), validation_data=(X_test, y_test), epochs=10)
test_loss, test_acc = model.evaluate(X_test, y_test, verbose=2)
print(f”Test accuracy: {test_acc}”)
Steps to run this code:
'X.npy'
and 'y.npy'
with the actual image data and labels.pip install tensorflow scikit-learn numpy
.