Skip to content

armanchinai/GarmentRecognitionAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

332 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues


Logo

Garment Recognition API

An API that uses computer vision and semantic textual analysis to recognize clothing items through images.
Explore the docs »
Watch a demo »

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Deployment
  5. Developer Team
  6. Acknowledgments

About The Project

Product Name Screen Shot

The Garment Recognition API is a RESTful API that uses computer vision and semantic textual analysis to recognize clothing items through images. The project was developed by a team of 5 students as part of BCIT's COMP 3800 course. The API leverages Azure's Dense Captioning model to generate textual descriptions of images, which are then processed by a custom-built NLP model to extract relevant information about the clothing items. The server is built using Flask and the API is documented using Swagger.

(back to top)

Built With

  • Python
  • Pandas
  • Flask
  • Azure
  • HuggingFace
  • Swagger

(back to top)

Getting Started

The following instructions will guide you through setting up the project on your local machine.

Prerequisites

  1. Python (version 3.11 or higher)

    • Download and install Python from here.
      • Ensure that you check the box that says "Add Python to PATH" during installation.
      • Ensure that you check the box that says "Install pip" during installation.
    • Verify installation by running the following command in your terminal:
    python --version        # Check the version of Python
  2. Pip (Python package installer)

    • Verify installation by running the following command in your terminal:
    pip --version       # Check the version of pip
  3. Git (optional, but recommended)

    • Download and install Git from here.
    • Verify installation by running the following command in your terminal:
    git --version       # Check the version of Git
  4. VSCode (or any other code editor).

    • Download and install VSCode from here.
  5. An Azure Dense Captioning model API Key.

  6. An NVIDIA GPU (optional, but recommended for faster processing).

Installation

  1. Clone the repo (or download the ZIP file and extract it to a folder on your local machine)

    git clone https://github.com/ChinaiArman/GarmentRecognitionAPI.git       # Clone the repository
  2. Create a virtual environment

    2.1 Create a virtual environment using the following commands:

    cd GarmentRecognitionAPI            # Change to the project directory
    python -m venv .venv                 # Create a virtual environment

    2.2 Activate the virtual environment:

    • Mac:
      • Activation command:
        source .venv/bin/activate     # Activate the virtual environment
      • Deactivation command:
        source .venv/bin/deactivate       # Deactivate the virtual environment
    • Windows:
      • Activation command:
        .venv\Scripts\activate.bat        # Activate the virtual environment
      • Deactivation command:
        .venv\Scripts\deactivate.bat      # Deactivate the virtual environment
      Your interpreter should now be set to the Virtual Environment instance of python.
  3. Install required Python libraries

    cd server                           # Change to the server directory
    pip install -r requirements.txt     # Install the required libraries
    • If after running the command, none of the packages have installed, restart the terminal and try again, ensuring that the virtual environment is activated.
    • If a single package fails to install, try installing it separately using the following command:
    pip install <package_name>          # Install the package separately
  4. Set up environment variables

    • Create a .env file in the server directory of the project.
    • Add the following environment variables to the .env file:
    AZURE_VISION_ENDPOINT=""        # your_azure_vision_endpoint
    AZURE_VISION_KEY_1=""           # your_azure_vision_key
    AZURE_VISION_KEY_2=""           # your_azure_vision_key
    RAPID_API_KEY=""                # your_rapid_api_key
    EMBEDDED_MODEL=""               # your_embedded_model
    DATA_SOURCE_FILE=""             # your_data_source_file
    PYTHONPATH="server"             # Set the PYTHONPATH to "server"
    • Replace the placeholder values with your own API keys and file paths.
    • Note: RAPID_API_KEY is only used within the data aggregation module. You can obtain an API key by creating an account here. If you do not plan to use that module for gathering clothing data then this can be left empty.
    • Note: DATA_SOURCE_FILE is the path to the data source file. This file can be modified to point to any CSV file with the appropriate columns.
    • Note: EMBEDDED_MODEL is the name of the HuggingFace model that you want to use for the NLP processing. The model can be substituted with any other model from the HuggingFace model hub, but we suggest using gte-small for optimal results.

(back to top)

Usage

  1. Start the server by running the following command:

    cd ..                       # Return to the root directory
    python server/app.py        # Start the server
  2. Access the API documentation at http://localhost:5000/ to view the available endpoints and interact with the API.

  3. You can also use client software of your choice (cURL, Postman, etc.) to send HTTP requests to the endpoints. The API documentation will guide you in how to format any request bodies and path parameters for the HTTP requests.

(back to top)

Deployment

Full Deployment (server and UI)

The full API can be deployed to a cloud platform such as Azure or AWS directly.

  1. Ensure that the required environment variables are set in the deployment environment.
  2. Set the entry point of the server to server/app.py.
  3. Deploy the server to the cloud platform of your choice. The server will serve the Swagger UI at the root URL, and will respond to all other API requests as a RESTful API.

Flask Server Deployment (only for the server)

The API server can be deployed to a cloud platform such as Azure or AWS with minimal changes.

  1. Ensure that the required environment variables are set in the deployment environment.

  2. In app.py, change the initialization of the Flask app (line 29 in server/app.py) to the following:

    app = Flask(__name__)
  3. In app.py, change the root route of the Flask server (line 330 in server/app.py) to the following:

    return jsonify("Hello World")
  4. Deploy the server folder to the cloud platform of your choice.

Swagger UI Deployment (only for the UI)

The Swagger frontend can be deployed to GitHub Pages or any other static site hosting service.

  • A guide to deploying the Swagger UI to GitHub can be found here.
  • Swagger can also be deployed on any major cloud platform such as Azure or AWS.
    • A guide to deploying Swagger on AWS can be found here.
    • A guide to deploying Swagger on Azure can be found here.

The Swagger YAML file can be found here. Ensure that all references to the server are updated to the deployed server URL.

(back to top)

Developer Team

Arman Chinai:

LinkedIn GitHub

Lex Wong:

LinkedIn GitHub

Natalie Yu:

LinkedIn GitHub

Ehsan Emadi:

LinkedIn GitHub

Collin Chan:

LinkedIn GitHub

Project Link:

GitHub

(back to top)

Acknowledgments

  • Chris Thompson - Project Supervisor

    • GitHub
  • Farnaz Dargahi - COMP 3800 Instructor

  • Laura Aslan - Founder and CEO of Odd Fabric, owner of this product

  • Will Stahl - Laura’s business partner, co-owner of this product

Thank you for your continued support throughout the project!

(back to top)

About

A RESTful API built in Flask that uses Azure computer vision and an open source natural language processing model to recognize clothing items in a database through images.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors