Thursday, November 14, 2024

Traffic Sign Detection Project Using Resnet

 
Traffic Sign Detection Project Using Resnet


INTRODUCTION:

Residual Networks, or ResNets, learn residual functions with reference to the layer inputs, instead of learning unreferenced functions. Instead of hoping each few stacked layers directly fit a desired underlying mapping, residual nets let these layers fit a residual mapping.

CODE πŸ˜ƒπŸ‘‡:

from fastai.vision.all import *
import numpy as np
import pandas as pd
from pathlib import Path

path = Path(‘path/to/your/traffic-signs’)

np.random.seed(42)

data_block = DataBlock(
 blocks=(ImageBlock, CategoryBlock), # Define image classification task
 get_items=get_image_files, # Get all image files
 splitter=RandomSplitter(valid_pct=0.2, seed=42), # 20% data for validation
 get_y=parent_label, # Labels are the parent directory names
 item_tfms=Resize(224), # Resize images to 224x224 for ResNet50
 batch_tfms=aug_transforms(mult=1.0) # Apply data augmentation
)

dls = data_block.dataloaders(path, bs=64) # Batch size of 64
dls.show_batch(max_n=9, figsize=(8, 8))

learn = cnn_learner(dls, resnet50, metrics=[accuracy])
learn.fine_tune(5) # Fine-tune the model for 5 epochs

img_path = ‘path/to/your/test-image.jpg’
img = PILImage.create(img_path)
pred_class, pred_idx, outputs = learn.predict(img)
print(f”Predicted class: {pred_class}”)

learn.export(‘traffic_sign_resnet50_model.pkl’)

DATASET LINK πŸ˜ƒπŸ‘‡:

https://www.kaggle.com/datasets/neelpratiksha/indian-traffic-sign-dataset


SUPPORT ME πŸ˜Ÿ

FREE C++ SKILLSHARE COURSE

https://skl.sh/3AUpE4C


FREE C SKILLSHARE COURSE

https://skl.sh/3Ynolmw


All Courses πŸ˜ƒπŸ‘‡

https://linktr.ee/Freetech2024


All Products πŸ˜ƒπŸ‘‡

https://linktr.ee/rockstararun


HP Laptop πŸ€©πŸ‘‡

https://dir.indiamart.com/impcat/hp-laptop.html?utm_source=freetech-xu1ob&utm_medium=affiliate&utm_campaign=1024&utm_content=29&mTd=1

Asus Laptop πŸ€©πŸ‘‡

https://www.indiamart.com/proddetail/24957009948.html?utm_source=freetech-xu1ob&utm_medium=affiliate&utm_campaign=1024&utm_content=43&mTd=1




No comments:

Post a Comment

SQL INJECTION DETECTION USING RANDOM FOREST CLASSIFIER

  SQL INJECTION DETECTION USING RANDOM FOREST CLASSIFIER