fastapi-model / README.md
chemistrymath's picture
Update README.md
900ed64 verified
metadata
title: FastAPI Model
sdk: docker
emoji: πŸš€
colorFrom: blue
colorTo: purple
pinned: false

<<<<<<< HEAD

AI-Powered Body Measurement & Apparel Sizing

This project is a FastAPI-based AI system that predicts body measurements and recommends clothing sizes using deep learning. It processes front and side images, removes backgrounds, and utilizes a trained Keras model for accurate predictions.


πŸ“Œ Features

βœ… AI-powered body measurement estimation using images.
βœ… Automatic background removal for clean image processing.
βœ… Deep learning-based predictions using a trained model.
βœ… FastAPI integration for quick and efficient API responses.


πŸš€ Installation

To set up the project, follow these steps:

1️⃣ Clone the Repository

git clone https://github.com/CloozyBrands/AI-BodyMeasurement.git

2️⃣ Install Dependencies

pip install -r requirements.txt

3️⃣ Run the FastAPI Server

uvicorn app.main:app --reload

Then open http://127.0.0.1:8000/docs to test the API.


πŸ› οΈ How It Works

1️⃣ Upload Images

  • The API accepts two images:
    • Front view
    • Side view

2️⃣ AI-Based Processing

  • The images are processed using single_person_processor.py, which:
    βœ… Removes the background using rembg.
    βœ… Converts the images into a model-compatible format.
    βœ… Predicts body measurements like chest, waist, and height.

3️⃣ Clothing Size Prediction

  • Based on the body measurements, the system suggests a T-shirt and pants size using predefined size charts.

πŸ” API Endpoints

1️⃣ /predict/ (POST) - Predict Body Measurements

πŸ“Œ Example Request:

POST /predict/

πŸ“Œ Request Parameters:

Parameter Type Description
front_image File Front view image (JPEG/PNG)
side_image File Side view image (JPEG/PNG)
input_data JSON User data (height, weight, gender)

πŸ“Œ Example JSON Payload:

{
  "gender": 0, 
  "height_cm": 175, 
  "weight_kg": 70, 
  "apparel_type": "all"
}

πŸ“Œ Example Response:

{
  "results": {
    "body_measurements": {
      "chest": 100.5,
      "waist": 80.2,
      "hip": 97.3
    },
    "tshirt_size": "L",
    "pants_size": 34
  }
}

🎯 Model & AI Processing

πŸ“Œ The model used in this project is a TensorFlow/Keras model stored as best_model.keras.
πŸ“Œ The AI processing is handled inside single_person_processor.py, which:

  • Loads the trained model using tf.keras.models.load_model.
  • Extracts measurements based on input images.
  • Maps the measurements to standard clothing sizes.

πŸ“œ License

This project is licensed under the MIT License – feel free to modify and use it.


🀝 Contributing

  1. Fork the repository
  2. Create a new branch
  3. Make your changes
  4. Submit a pull request

We welcome contributions and improvements! πŸš€

>>>>>>> 4e80050 (FastAPI model for size recommendation)