GithubHelp home page GithubHelp logo

kailielexx / ai-classification Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hoangsonww/ai-ml-classifiers

0.0 0.0 0.0 197.55 MB

Home Page: https://hoangsonww.github.io/AI-Classification/

License: MIT License

Python 84.99% Jupyter Notebook 12.68% Dockerfile 1.59% Makefile 0.75%

ai-classification's Introduction

AI Multitask Classifiers: From Objects to Emotions

Created by Son Nguyen in 2024, this repository contains Python scripts for various AI-powered classifiers. These classifiers can be used for object detection, face detection, character recognition, and more. The classifiers are built using popular deep learning frameworks such as OpenCV, TensorFlow, and PyTorch.

This repository contains 8 subdirectories: one for vehicle classification, one for human face classification, one for mood classification, one for flower classification , one for object classification, one for character classification, one for animal classification, and one for speech recognition, namely Vehicle-Classification, Human-Face-Classification, Mood-Classification, Flowers-Classification, Object-Classification, Character-Recognition, Animals-Classification, and Speech-Recognition. Refer to the information below for details on each classifier.

What's even more interesting is that all these classifiers can use your webcam for live testing, video files, or image files!

Table of Contents


Before You Begin

Before you begin, ensure you have the following installed on your machine:

  • Python 3.12 or higher
  • OpenCV
  • TensorFlow
  • PyTorch
  • NumPy
  • Matplotlib
  • Tesseract OCR
  • Pytesseract
  • SpeechRecognition
  • MoviePy
  • PyDub
  • PyAudio
  • Git LFS (for downloading large model weights files)
  • A webcam (if you want to use live testing)
  • A microphone (if you want to use speech recognition)
  • A video file or image file for testing the classifiers
  • A stable internet connection (for downloading model weights and dependencies)
  • A working speaker or headphones (for speech recognition)

You are also recommended to use a virtual environment to use these classifiers. You can create a virtual environment using venv or conda.

python -m venv env
source env/bin/activate

Main Script

If you prefer not to navigate through the subdirectories, you can run the main script main.py to choose and run any of the classifiers. The main script will ask you to choose a classifier from the list of available classifiers. You can then select a classifier and run it.

To run the main script, use the following command:

python main.py

The main script will display a list of available classifiers. Enter the number corresponding to the classifier you want to run. The script will then run the selected classifier.

To stop the script, press Q, ESC, or otherwise close the window.


Vehicle Classification

Files Included

  • coco.names: Class names used for vehicle detection.
  • traffic.mp4: Sample video for vehicle detection.
  • india.jpg: Sample image for vehicle detection.
  • yolov3.cfg: YOLOv3 model configuration file.
  • yolov3.weights: Pre-trained YOLOv3 model weights.
  • vehicle_detection.py: Python script for vehicle detection and classification.

Getting Started

  1. Clone the Repository

    git clone https://github.com/hoangsonww/AI-Classification.git
    cd AI-Classification/Vehicle-Classification
  2. Download Model Weights Download the pre-trained YOLOv3 model weights (yolov3.weights) from the official YOLO website or another trusted source and place it in the Vehicle-Classification directory.

  3. Install Dependencies Install the required Python dependencies.

    pip install -r requirements.txt
  4. Install and Pull Git LFS Install Git LFS by following the instructions on the official Git LFS website. Then, pull the model weights using Git LFS.

    git lfs install
    git lfs pull

    Alternatively, you can download the weights file from the official YOLO website and place it in the Vehicle-Classification directory. However, using Git LFS is recommended.

    This is crucial for pulling the large model weights file. Without Git LFS, the weights file may not be downloaded correctly and the script may not work as expected.

  5. Run Vehicle Detection

    python vehicle_detection.py

You will then be asked to choose your input type (image, video, or webcam). Enter image to classify the vehicles in the sample video provided (traffic.mp4), or enter video to classify vehicles in a video file. You can also use your webcam for live testing.

All our classifiers will only stop when you press Q, ESC, or otherwise close the window.

Output

The output video will display the detected vehicles along with their class labels. The class labels are based on the COCO dataset, which includes various classes such as car, truck, bus, motorcycle, and bicycle.

Example output:

Vehicle Classification Output


Face Classification

Files Included

  • deploy.prototxt: Model configuration file for the face detector.
  • res10_300x300_ssd_iter_140000.caffemodel: Pre-trained model weights for face detection.
  • age_deploy.prototxt: Model configuration file for age prediction.
  • age_net.caffemodel: Pre-trained model weights for age prediction.
  • gender_deploy.prototxt: Model configuration file for gender prediction.
  • gender_net.caffemodel: Pre-trained model weights for gender prediction.
  • faces_classification.py: Python script for face detection, age, and gender classification.
  • woman-30.mp4: Sample video for face classification
  • man.jpg: Sample image for face classification.

Getting Started

  1. Clone the Repository

    git clone https://github.com/hoangsonww/AI-Classification.git
    cd AI-Classification/Face-Classification
  2. Download Model Weights: Ensure you have the model weights (res10_300x300_ssd_iter_140000.caffemodel, age_net.caffemodel, gender_net.caffemodel) in the Human-Face-Classification directory.

  3. Install Dependencies: Install the required Python dependencies.

    pip install -r requirements.txt
    
  4. Run Face Classification: Execute the face_classification.py script.

    python face_classification.py
    

You will then be asked to choose your input type (image, video, or webcam). Enter image to classify the faces in the sample image provided (woman-30.mp4), or enter video to classify faces in a video file. You can also use your webcam for live testing.

All our classifiers will only stop when you press Q, ESC, or otherwise close the window.

Output

The output will be a video displaying the detected faces along with their estimated age and gender.

Example output:

Face Classification Output


Mood Classification

Files Included

  • mood_classifier.py: Python script for mood classification.
  • angry.mp4: Sample video for mood classification (angry).
  • surprised.jpg: Sample image for mood classification (surprised).

Getting Started

  1. Clone the Repository
    git clone
    cd AI-Classification/Mood-Classification
  2. Install Dependencies Install the required Python dependencies.
    pip install -r requirements.txt
  3. Run Mood Classification
    python mood_classifier.py

You will then be asked to choose your input type (image, video, or webcam). Enter image to classify the mood in the sample image provided (surprised.jpg), or enter video to classify the mood in a video file. You can also use your webcam for live testing.

The script will then display the detected mood in the image, video, or webcam stream and in the console.

All our classifiers will only stop when you press Q, ESC, or otherwise close the window.

Output

The output will be displayed the detected mood in the image, video, or webcam stream and in the console.

Example output:

Mood Classification Output


Character Classification

Files Included

  • ocr.py: Python script for character classification.
  • OIP.jpg: Sample JPEG image for character classification.
  • chars.jpg: Sample JPEG image for character classification.
  • chars.mp4: Sample video for character classification.
  • letters.mp4: Sample video for character classification.

Getting Started

  1. Clone the Repository

    git clone
    cd AI-Classification/Character-Recognition
  2. Install the required Python dependencies.

    pip install -r requirements.txt
  3. Install Tessaract OCR

    • For Windows: Download and install the Tesseract OCR executable from the official Tesseract OCR website.
    • For Linux: Install Tesseract OCR using the package manager.
      sudo apt-get install tesseract-ocr
    • For macOS: Install Tesseract OCR using Homebrew.
        brew install tesseract
    • This is required for the OCR functionality to work. Also, when you install, note down the installation path of the Tesseract OCR executable. Replace the path in the pytesseract.pytesseract.tesseract_cmd variable in the ocr.py script with yours.
    • For example, if you installed Tesseract OCR in the default location on Windows, the path would be:
      pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
  4. Run Character Classification

    python ocr.py

    You will then be asked to choose your input type (image, video, or webcam). Enter image to classify the characters in the sample image provided (OIP.jpg), or enter video to classify characters in a video file. You can also use your webcam for live testing.

    image
    

The script will then display the detected characters in the image, video, or webcam stream.

All our classifiers will only stop when you press Q, ESC, or otherwise close the window.

Output

The output will display the class labels of the characters detected in the image along with the confidence scores.

Example output:

Character Classification Output


Flower Classification

Files Included

  • flower_classification.py: Python script for flower classification.
  • daisy.jpg: Sample JPEG image for flower classification (Daisy).
  • marigold.jpg: Sample JPEG image for flower classification (Marigold).
  • rose.mp4: Sample video for flower classification (Rose).

Getting Started

  1. Clone the Repository

    git clone https://github.com/hoangsonww/AI-Classification.git
    cd AI-Classification/Flowers-Classification
  2. Install Dependencies Install the required Python dependencies.

    pip install -r requirements.txt
  3. Run Object Classification

    python flower_classification.py

You will then be asked to choose your input type (image, video, or webcam). Enter image to classify the flowers in the sample image provided (daisy.jpg), or enter video to classify flowers in a video file. You can also use your webcam for live testing.

All our classifiers will only stop when you press Q, ESC, or otherwise close the window.

Output

The output will display the class label of the flower detected in the image along with the confidence score.

Example output: Here are the sample image of Daisy flowers.

Flower Classification Output


Object Classification

Files Included

  • object_classification.py: Python script for object classification.
  • objects.jpg: Sample JPEG image for object classification.
  • objects.png: Sample PNG image for object classification.
  • balls.mp4: Sample video for object classification.
  • OIP.jpg: Sample image for object classification.

Getting Started

  1. Clone the Repository

    git clone https://github.com/hoangsonww/AI-Classification.git
    cd AI-Classification/object_classification
  2. Install Dependencies Install the required Python dependencies.

    pip install -r requirements.txt
  3. Run Object Classification

    python object_classification.py

You will then be asked to choose your input type (image, video, or webcam). Enter image to classify the objects in the sample image provided (objects.jpg), or enter video to classify objects in a video file. You can also use your webcam for live testing.

Feel free to change the paths and other parameters in the script to suit your needs.

Note: All our classifiers will only stop when you press Q, ESC, or otherwise close the window.

Output

The output will display the class labels of the objects detected in the image along with the confidence scores. Or, if you choose to use your webcam, the output will display the class labels of the objects detected in the video stream. If you choose to use a video file, the output will be a video displaying the detected objects along with their class labels.

Example output:

Object Classification Output


Animal Classification

Files Included

  • animal_classification.py: Python script for animal classification.
  • cow.jpg: Sample JPEG image for animal classification (Cow).
  • ox.jpg: Sample JPEG image for animal classification (Ox).

Getting Started

  1. Clone the Repository

    git clone https://github.com/hoangsonww/AI-Classification.git
    cd AI-Classification/Animals-Classification
  2. Install Dependencies Install the required Python dependencies.

    pip install -r requirements.txt
  3. Run Object Classification

    python animal_classification.py

The script will then ask you to choose your input type (image, video, or webcam). Enter image to classify the animals in the sample image provided (cow.jpg), or enter video to classify animals in a video file. You can also use your webcam for live testing.

All our classifiers will only stop when you press Q, ESC, or otherwise close the window.

Output

The output will display the class labels of the animals detected in the image along with the confidence scores.

Example output:

Animal Classification Output


Speech Recognition

Files Included

  • speech_classifier.py: Python script for speech recognition.
  • speech.mp4: Sample video file for speech recognition in a video context.
  • temp_audio.wav: Temp audio file (used by our AI) for speech recognition.

Getting Started

  1. Clone the Repository

    git clone https://github.com/hoangsonww/AI-Classification.git
    cd AI-Classification/Speech-Recognition
  2. Install Dependencies Install the required Python dependencies.

    pip install -r requirements.txt
  3. Run Speech Recognition

     python speech_classifier.py

You will then be asked to choose your preferred input method (microphone or video). Enter microphone to use your microphone for live speech recognition, or enter video to use a video file for speech recognition.

Output

You will see the output of the speech recognition process in the console. The script will display the recognized speech from the audio input. The audio is processed in chunks and recognized in real-time. All our classifiers will stop when you press Q, ESC, or otherwise close the window.

Example output:

Speech Recognition Output


Contact Information

For any questions or issues, please contact:

Future Work & Enhancements

  • Add more classifiers for various tasks such as emotion recognition, sentiment analysis, and more.
  • Refine existing classifiers and improve their accuracy and performance.
  • Add more sample images and videos for testing the classifiers.

License

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


This repository is a work in progress and under active development. If you have any suggestions or improvements, feel free to contribute to this repository. Thank you for visiting!

ai-classification's People

Contributors

hoangsonww avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.