Spaces:
Sleeping
Sleeping
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** | |
```bash | |
git clone https://github.com/CloozyBrands/AI-BodyMeasurement.git | |
``` | |
--- | |
### **2οΈβ£ Install Dependencies** | |
```bash | |
pip install -r requirements.txt | |
``` | |
### **3οΈβ£ Run the FastAPI Server** | |
```bash | |
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:** | |
```http | |
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:** | |
```json | |
{ | |
"gender": 0, | |
"height_cm": 175, | |
"weight_kg": 70, | |
"apparel_type": "all" | |
} | |
``` | |
π **Example Response:** | |
```json | |
{ | |
"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) |