forked from JianqiangRen/FlowBasedBodyReshaping
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_body_shaping_api.py
More file actions
34 lines (26 loc) · 1.01 KB
/
test_body_shaping_api.py
File metadata and controls
34 lines (26 loc) · 1.01 KB
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
import json
import requests
def test_body_shaping_api(file_path, degree, roi):
url = 'http://123.249.37.76:7565/body_shaping'
# Prepare the files and data
files = {'file': open(file_path, 'rb')}
json_data = {'degree': degree, 'roi': roi}
data = {'json': json.dumps(json_data)}
# Send the POST request
response = requests.post(url, files=files, data=data)
# Handle the response
if response.status_code == 200:
# Save the reshaped image
with open('reshaped_image.jpg', 'wb') as f:
f.write(response.content)
print("Reshaped image saved as 'reshaped_image.jpg'")
else:
# Print the error message
print(f"Error: {response.status_code} - {response.json()['error']}")
if __name__ == '__main__':
# Path to the image file you want to test with
file_path = 'test.jpg'
degree = 1.0 # 美型程度0.1 ~ 1.0
roi = 2 # 0: 胳膊 ; 1 :腿 ; 2 : 全身
# Test the API
test_body_shaping_api(file_path, degree, roi)