Skip to content

Commit

Permalink
Cleaned up example
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleykleynhans committed Jul 8, 2023
1 parent c99142e commit 9cd6d7b
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions examples/face_swap.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,25 @@
SOURCE_IMAGE = '/Users/ashley/src/inswapper/data/src.jpg'
TARGET_IMAGE = '/Users/ashley/src/inswapper/data/target.jpg'

payload = {
'request_id': 0,
'user_id': 0,
'event_id': 0
}

files = {
'source_image': open(SOURCE_IMAGE, 'rb'),
'target_image': open(TARGET_IMAGE, 'rb')
}
if __name__ == '__main__':
files = {
'source_image': open(SOURCE_IMAGE, 'rb'),
'target_image': open(TARGET_IMAGE, 'rb')
}

r = requests.post(
URL,
data=payload,
files=files
)
r = requests.post(
URL,
files=files
)

print(f'HTTP status code: {r.status_code}')
print(f'HTTP status code: {r.status_code}')

resp_json = r.json()
resp_json = r.json()

img = Image.open(io.BytesIO(base64.b64decode(resp_json['image'])))
output_file = f'{uuid.uuid4()}.jpg'
img = Image.open(io.BytesIO(base64.b64decode(resp_json['image'])))
output_file = f'{uuid.uuid4()}.jpg'

with open(output_file, 'wb') as f:
print(f'Saving image: {output_file}')
img.save(f, format='JPEG')
with open(output_file, 'wb') as f:
print(f'Saving image: {output_file}')
img.save(f, format='JPEG')

0 comments on commit 9cd6d7b

Please sign in to comment.