Friday, November 15, 2024

Sign Language Detection Using Resnet

 

Sign Language Detection 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 *
from pathlib import Path

# Step 1: Define the path to the dataset
# Replace ‘/path/to/dataset’ with your dataset path
dataset_path = Path(‘/path/to/sign_language_dataset’)

# Step 2: Set up the DataBlock
# Configure DataBlock for image classification
data_block = DataBlock(
 blocks=(ImageBlock, CategoryBlock), # Set up image classification
 get_items=get_image_files, # Fetch image files
 splitter=RandomSplitter(valid_pct=0.2, seed=42), # 80–20 train-validation split
 get_y=parent_label, # Use folder names as labels
 item_tfms=Resize(224), # Resize images to 224x224
 batch_tfms=aug_transforms() # Apply augmentations
)

# Step 3: Create DataLoaders
# Load data with batch size of 64 (adjust if needed)
dls = data_block.dataloaders(dataset_path, bs=64)

# Optional: Show a batch of images to verify data loading
dls.show_batch(max_n=9, figsize=(7, 6))

# Step 4: Initialize the Model and Train
# Load ResNet50 as the base model and set accuracy as the metric
learn = cnn_learner(dls, resnet50, metrics=accuracy)

# Fine-tune the model
learn.fine_tune(5) # Adjust epochs as needed

# Step 5: Evaluate the Model
# Interpret and plot the confusion matrix
interp = ClassificationInterpretation.from_learner(learn)
interp.plot_confusion_matrix(figsize=(10, 10), dpi=80)

# Step 6: Test the Model with a Custom Image
# Path to a test image for prediction
test_image_path = ‘/path/to/test_image.jpg’ # Replace with your test image path
img = PILImage.create(test_image_path)

# Predict the class of the test image
pred_class, pred_idx, outputs = learn.predict(img)
print(f”Predicted class: {pred_class}”)

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