Spaces:
Runtime error
Runtime error
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,124 +1,132 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
---
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
```
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
"
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: FastAPI Model
|
| 3 |
+
sdk: docker
|
| 4 |
+
emoji: π
|
| 5 |
+
colorFrom: blue
|
| 6 |
+
colorTo: purple
|
| 7 |
+
pinned: false
|
| 8 |
+
---
|
| 9 |
+
<<<<<<< HEAD
|
| 10 |
+
# AI-Powered Body Measurement & Apparel Sizing
|
| 11 |
+
|
| 12 |
+
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.
|
| 13 |
+
|
| 14 |
+
---
|
| 15 |
+
|
| 16 |
+
## π Features
|
| 17 |
+
β
AI-powered **body measurement estimation** using images.
|
| 18 |
+
β
Automatic **background removal** for clean image processing.
|
| 19 |
+
β
Deep learning-based **predictions** using a trained model.
|
| 20 |
+
β
**FastAPI integration** for quick and efficient API responses.
|
| 21 |
+
|
| 22 |
+
---
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
## π Installation
|
| 26 |
+
|
| 27 |
+
To set up the project, follow these steps:
|
| 28 |
+
|
| 29 |
+
### **1οΈβ£ Clone the Repository**
|
| 30 |
+
```bash
|
| 31 |
+
git clone https://github.com/CloozyBrands/AI-BodyMeasurement.git
|
| 32 |
+
```
|
| 33 |
+
---
|
| 34 |
+
### **2οΈβ£ Install Dependencies**
|
| 35 |
+
```bash
|
| 36 |
+
pip install -r requirements.txt
|
| 37 |
+
```
|
| 38 |
+
|
| 39 |
+
### **3οΈβ£ Run the FastAPI Server**
|
| 40 |
+
```bash
|
| 41 |
+
uvicorn app.main:app --reload
|
| 42 |
+
```
|
| 43 |
+
Then open **http://127.0.0.1:8000/docs** to test the API.
|
| 44 |
+
|
| 45 |
+
---
|
| 46 |
+
|
| 47 |
+
## π οΈ How It Works
|
| 48 |
+
|
| 49 |
+
### **1οΈβ£ Upload Images**
|
| 50 |
+
- The API accepts **two images**:
|
| 51 |
+
- **Front view**
|
| 52 |
+
- **Side view**
|
| 53 |
+
|
| 54 |
+
### **2οΈβ£ AI-Based Processing**
|
| 55 |
+
- The images are processed using **`single_person_processor.py`**, which:
|
| 56 |
+
β
Removes the background using `rembg`.
|
| 57 |
+
β
Converts the images into a **model-compatible format**.
|
| 58 |
+
β
Predicts **body measurements** like chest, waist, and height.
|
| 59 |
+
|
| 60 |
+
### **3οΈβ£ Clothing Size Prediction**
|
| 61 |
+
- Based on the body measurements, the system suggests a **T-shirt and pants size** using predefined **size charts**.
|
| 62 |
+
|
| 63 |
+
---
|
| 64 |
+
|
| 65 |
+
## π API Endpoints
|
| 66 |
+
|
| 67 |
+
### **1οΈβ£ `/predict/` (POST) - Predict Body Measurements**
|
| 68 |
+
π **Example Request:**
|
| 69 |
+
```http
|
| 70 |
+
POST /predict/
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
π **Request Parameters:**
|
| 74 |
+
| Parameter | Type | Description |
|
| 75 |
+
|---------------|--------|-------------|
|
| 76 |
+
| `front_image` | File | Front view image (JPEG/PNG) |
|
| 77 |
+
| `side_image` | File | Side view image (JPEG/PNG) |
|
| 78 |
+
| `input_data` | JSON | User data (height, weight, gender) |
|
| 79 |
+
|
| 80 |
+
π **Example JSON Payload:**
|
| 81 |
+
```json
|
| 82 |
+
{
|
| 83 |
+
"gender": 0,
|
| 84 |
+
"height_cm": 175,
|
| 85 |
+
"weight_kg": 70,
|
| 86 |
+
"apparel_type": "all"
|
| 87 |
+
}
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
π **Example Response:**
|
| 91 |
+
```json
|
| 92 |
+
{
|
| 93 |
+
"results": {
|
| 94 |
+
"body_measurements": {
|
| 95 |
+
"chest": 100.5,
|
| 96 |
+
"waist": 80.2,
|
| 97 |
+
"hip": 97.3
|
| 98 |
+
},
|
| 99 |
+
"tshirt_size": "L",
|
| 100 |
+
"pants_size": 34
|
| 101 |
+
}
|
| 102 |
+
}
|
| 103 |
+
```
|
| 104 |
+
|
| 105 |
+
---
|
| 106 |
+
|
| 107 |
+
## π― Model & AI Processing
|
| 108 |
+
|
| 109 |
+
π The model used in this project is a **TensorFlow/Keras** model stored as `best_model.keras`.
|
| 110 |
+
π The AI processing is handled inside **`single_person_processor.py`**, which:
|
| 111 |
+
- Loads the trained model using `tf.keras.models.load_model`.
|
| 112 |
+
- Extracts measurements based on input images.
|
| 113 |
+
- Maps the measurements to standard clothing sizes.
|
| 114 |
+
|
| 115 |
+
---
|
| 116 |
+
|
| 117 |
+
## π License
|
| 118 |
+
|
| 119 |
+
This project is licensed under the **MIT License** β feel free to modify and use it.
|
| 120 |
+
|
| 121 |
+
---
|
| 122 |
+
|
| 123 |
+
## π€ Contributing
|
| 124 |
+
|
| 125 |
+
1. Fork the repository
|
| 126 |
+
2. Create a new branch
|
| 127 |
+
3. Make your changes
|
| 128 |
+
4. Submit a pull request
|
| 129 |
+
|
| 130 |
+
We welcome contributions and improvements! π
|
| 131 |
+
```
|
| 132 |
+
>>>>>>> 4e80050 (FastAPI model for size recommendation)
|