File size: 6,832 Bytes
fad49fa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# API Usage Guide - Photo Object Removal

## Overview
This guide provides step-by-step instructions for using the Photo Object Removal API to remove objects from images using AI inpainting.

**Base URL:** `https://logicgoinfotechspaces-object-remover.hf.space`  
**Authentication:** Bearer token (optional)

## Quick Start

### 1. Health Check
Verify the API is running:
```bash
curl -H "Authorization: Bearer <API_TOKEN>" \
  https://logicgoinfotechspaces-object-remover.hf.space/health
```
**Response:** `{"status":"healthy"}`

### 2. Upload Image
Upload the image you want to edit:
```bash
curl -H "Authorization: Bearer <API_TOKEN>" \
  -F image=@your_image.jpg \
  https://logicgoinfotechspaces-object-remover.hf.space/upload-image
```
**Response:** `{"id":"9cf61445-f83b-4c97-9272-c81647f90d68","filename":"your_image.jpg"}`

### 3. Upload Mask
Upload a mask showing areas to remove (white/colored areas = remove):
```bash
curl -H "Authorization: Bearer <API_TOKEN>" \
  -F mask=@mask.png \
  https://logicgoinfotechspaces-object-remover.hf.space/upload-mask
```
**Response:** `{"id":"d044a390-dde2-408a-b7cf-d508385e56ed","filename":"mask.png"}`

### 4. Process Image
Remove objects using the uploaded image and mask:
```bash
curl -H "Authorization: Bearer <API_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"image_id":"9cf61445-f83b-4c97-9272-c81647f90d68","mask_id":"d044a390-dde2-408a-b7cf-d508385e56ed"}' \
  https://logicgoinfotechspaces-object-remover.hf.space/inpaint
```
**Response:** `{"result":"output_b09568698bbd4aa591b1598c01f2f745.png"}`

### 5. View Result
Open the result image in your browser:
```
https://logicgoinfotechspaces-object-remover.hf.space/result/output_b09568698bbd4aa591b1598c01f2f745.png
```

## Alternative Methods

### Method 1: Get Direct URL
Use `/inpaint-url` to get a shareable URL:
```bash
curl -H "Authorization: Bearer <API_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"image_id":"<image_id>","mask_id":"<mask_id>"}' \
  https://logicgoinfotechspaces-object-remover.hf.space/inpaint-url
```
**Response:** 
```json
{
  "result":"output_xxx.png",
  "url":"https://logicgoinfotechspaces-object-remover.hf.space/download/output_xxx.png"
}
```

### Method 2: One-Step Processing
Upload and process in a single request:
```bash
curl -H "Authorization: Bearer <API_TOKEN>" \
  -F image=@image.jpg \
  -F mask=@mask.jpg \
  https://logicgoinfotechspaces-object-remover.hf.space/inpaint-multipart
```

### Method 3: Download Result
Download the result file:
```bash
curl -L https://logicgoinfotechspaces-object-remover.hf.space/download/output_xxx.png \
  -o result.png
```

## Postman Setup

### 1. Upload Image
- **Method:** POST
- **URL:** `https://logicgoinfotechspaces-object-remover.hf.space/upload-image`
- **Headers:** `Authorization: Bearer <API_TOKEN>`
- **Body:** form-data
  - Key: `image` (Type: File)
  - Value: Select your image file

### 2. Upload Mask
- **Method:** POST
- **URL:** `https://logicgoinfotechspaces-object-remover.hf.space/upload-mask`
- **Headers:** `Authorization: Bearer <API_TOKEN>`
- **Body:** form-data
  - Key: `mask` (Type: File)
  - Value: Select your mask file

### 3. Process Image
- **Method:** POST
- **URL:** `https://logicgoinfotechspaces-object-remover.hf.space/inpaint`
- **Headers:** 
  - `Authorization: Bearer <API_TOKEN>`
  - `Content-Type: application/json`
- **Body:** raw JSON
```json
{
  "image_id": "9cf61445-f83b-4c97-9272-c81647f90d68",
  "mask_id": "d044a390-dde2-408a-b7cf-d508385e56ed"
}
```

## Mask Creation Guide

### Mask Formats
- **RGBA PNG:** Pixels with alpha=0 are treated as areas to remove
- **RGB/Grayscale:** Pixels with value > 0 are treated as areas to remove

### Creating Masks
1. **Paint Method:** Use any image editor to paint white/colored areas over objects you want to remove
2. **Transparency Method:** Create a PNG with transparent areas where you want objects removed
3. **Grayscale Method:** Create a black image and paint white areas over objects to remove

### Tips
- Use high contrast (white on black) for best results
- Make sure mask areas are clearly defined
- Avoid thin lines or small details in the mask

## Error Handling

### Common Errors

**422 Unprocessable Entity**
- **Cause:** Missing required fields or invalid file format
- **Solution:** Check file upload and field names

**404 Not Found**
- **Cause:** Invalid image_id or mask_id
- **Solution:** Re-upload files to get fresh IDs

**401 Unauthorized**
- **Cause:** Missing or invalid API token
- **Solution:** Add correct Authorization header

**403 Forbidden**
- **Cause:** Wrong API token
- **Solution:** Use the correct token you configured

### Troubleshooting

**File Upload Issues in Postman:**
- Remove warning icons next to filenames
- Re-select files if warning appears
- Try different file formats (PNG, JPG)
- Check file isn't corrupted

**Slow Processing:**
- Large images take longer to process
- Typical processing time: 1-3 seconds
- Wait for completion before checking results

## Complete Workflow Example

```bash
# 1. Health check
curl -H "Authorization: Bearer <API_TOKEN>" \
  https://logicgoinfotechspaces-object-remover.hf.space/health

# 2. Upload image
curl -H "Authorization: Bearer <API_TOKEN>" \
  -F image=@photo.jpg \
  https://logicgoinfotechspaces-object-remover.hf.space/upload-image

# 3. Upload mask
curl -H "Authorization: Bearer <API_TOKEN>" \
  -F mask=@mask.png \
  https://logicgoinfotechspaces-object-remover.hf.space/upload-mask

# 4. Process (replace with actual IDs from steps 2&3)
curl -H "Authorization: Bearer <API_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"image_id":"IMAGE_ID","mask_id":"MASK_ID"}' \
  https://logicgoinfotechspaces-object-remover.hf.space/inpaint

# 5. View result (replace with actual filename from step 4)
# Open in browser: https://logicgoinfotechspaces-object-remover.hf.space/result/OUTPUT_FILENAME
```

## API Endpoints Summary

| Method | Endpoint | Description | Auth Required |
|--------|----------|-------------|---------------|
| GET | `/health` | Health check | No |
| GET | `/` | API information | No |
| POST | `/upload-image` | Upload image file | Optional |
| POST | `/upload-mask` | Upload mask file | Optional |
| POST | `/inpaint` | Process with IDs | Optional |
| POST | `/inpaint-url` | Process with URL response | Optional |
| POST | `/inpaint-multipart` | One-step processing | Optional |
| GET | `/download/{filename}` | Download result | No |
| GET | `/result/{filename}` | View result in browser | No |
| GET | `/logs` | View processing logs | Optional |
| GET | `/docs` | API documentation | No |

## Support

For issues or questions:
1. Check the API documentation at `/docs`
2. Verify your request format matches examples
3. Ensure files are properly uploaded
4. Check authentication token is correct