Last active
October 16, 2022 07:46
-
-
Save uday-cohere/caf58348cf1c3cc4d809841d51fce1f0 to your computer and use it in GitHub Desktop.
dev.paint.cohere.ai samples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Image to Image API | |
import requests | |
import base64 | |
# give a path to an image on disk | |
image = open('init.png', 'rb').read() | |
bytes = base64.b64encode(image) | |
bytestr = bytes.decode('utf-8') | |
host = 'https://dev.paint.cohere.ai/img2img' | |
response = requests.post(host, json={'prompt': 'California', 'n_samples' : 1, 'n_iter' : 1, | |
'init_img': bytestr}) | |
# decode image | |
imageBytes = base64.b64decode(response.json()['image']) | |
# save to disk | |
f = open("sample.png", "wb") | |
f.write(imageBytes) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Text to Image API | |
import requests | |
import base64 | |
host = 'https://dev.paint.cohere.ai/txt2img' | |
response = requests.post(host, json={'prompt': 'California', 'n_samples' : 1, 'n_iter' : 1}) | |
# decode image | |
imageBytes = base64.b64decode(response.json()['image']) #decode | |
# save to disk | |
f = open("sample.png", "wb") | |
f.write(imageBytes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment