Skip to content

FashionNet is a PyTorch-based neural network designed to classify clothing items from the Fashion MNIST dataset. The model offers robust data preprocessing, customizable architecture, and flexible prediction options. Easily train the model, visualize performance, and predict fashion items from URLs, local ima

License

Notifications You must be signed in to change notification settings

Nightskull100/Simple-Apparel-Detection-using-CNN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation


FashionNet: Simple Apparel Classifier with Python using PyTorch

This repository contains a PyTorch implementation of a neural network designed to classify images from the Fashion MNIST dataset. The dataset consists of grayscale images of various clothing items, with each image being 28x28 pixels.

Project Overview

The project includes the following key components:

  • Data Loading and Preprocessing: The Fashion MNIST dataset is loaded and split into training, validation, and test sets. The images are normalized and transformed into tensors for processing by the neural network.

  • Model Architecture: A simple neural network is built using PyTorch's nn.Sequential with layers including fully connected (linear) layers, ReLU activations, and dropout for regularization. The model outputs class probabilities using LogSoftmax.

  • Training and Validation: The model is trained using the Adam optimizer and negative log likelihood loss (NLLLoss). The training and validation losses, as well as validation accuracy, are tracked and printed for each epoch.

  • Visualization: The training and validation losses are plotted to observe the model's performance over time. Additionally, the model's predictions on sample images are visualized alongside the predicted class probabilities.

  • Image Prediction: Three options are provided to predict images:

    1. Random Image from Dataset: Use a random image from the Fashion MNIST dataset to predict the class.
    2. Image from URL: Preprocess and predict the class of an image from a given URL.
    3. Image from Local File: Upload a local file to predict the class using the trained model. The predictions are then visualized along with the input image.

Dependencies

  • Python 3.x
  • PyTorch
  • torchvision
  • matplotlib
  • numpy
  • requests
  • PIL (Pillow)

You can install the required packages using:

pip install torch torchvision matplotlib numpy requests pillow

Usage

1. Training the Model

To train the model, simply run the main script. The model will train for 25 epochs, and the training and validation losses will be displayed.

python train.py

2. Predicting from a Random Dataset Image

To predict the class of a random image from the Fashion MNIST dataset, use the following command:

python predict_random.py

3. Predicting from a URL

To predict the class of an image from a URL, use the following command:

python predict_url.py --image_url "http://example.com/image.jpg"

4. Predicting from a Local File

To predict the class of an image from a local file, use the following command:

python predict_file.py --image_path "path/to/image.jpg"

Results

The model achieves a validation accuracy of approximately 88% after 25 epochs of training. The trained model can accurately predict the class of various clothing items in the Fashion MNIST dataset.

Examples

Training and Validation Losses

Training and Validation Losses

Sample Prediction

Given an image of an Tshirt, the model predicts the class with a high probability.

Description

Sample Prediction

Contributing

This project was done in collaboration with Prajan Kannan.

LinkedIn

License

This project is licensed under the MIT License - see the LICENSE file for details.


💫 About Me:

🔭 A Simple guy who does coding for fun
👯 Willing to collaborate in all types of Projects
🤝 I’m looking for help with Neural Networking
🌱 I’m currently learning ML and Deep Learning, FIGMA (In near future)

🌐 Socials:

Instagram LinkedIn

💻 Tech Stack:

Python HTML5 CSS3 MySQL Figma Canva



This update includes the information on the notebook's ability to use a random image from the dataset, a URL, or an uploaded image for predictions.

About

FashionNet is a PyTorch-based neural network designed to classify clothing items from the Fashion MNIST dataset. The model offers robust data preprocessing, customizable architecture, and flexible prediction options. Easily train the model, visualize performance, and predict fashion items from URLs, local ima

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published