File size: 3,256 Bytes
900ed64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
125
126
127
128
129
130
131
132
---
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)