Copy link to clipboard
Copied
A Firefly newbie here, but I haven't found any discussion or tutorial yet that covers this question -- my apologies if I've missed it.
When I include
"tileable": True
in the data for a post request to Firefly, the request always times out. Even if I explicitly set the timeout parameter to an absurdly high value. I'm making the call from script run by python3.10.
Has anyone else had this experience? I"m pretty sure I'm doing something wrong, but I haven't been able to figure out what. Below is the script, in case that's helpful. It returns images as is, but change the "False" to "True" and it times out.
Any suggestions would be greatly appreciated!
Thank you,
Mary
import os
import sys
import requests
import json
#Set creds based on environment variables.
CLIENT_ID = os.environ.get('CLIENT_ID')
CLIENT_SECRET = os.environ.get('CLIENT_SECRET')
def getAccessToken(id, secret):
response = requests.post(f"https://ims-na1.adobelogin.com/ims/token/v3?client_id={id}&client_secret={secret}&grant_type=client_credentials&scope=openid,AdobeID,session,additional_info,read_organizations,firefly_api,ff_apis")
return response.json()["access_token"]
token = getAccessToken(CLIENT_ID, CLIENT_SECRET)
def generateImage(text, id, token):
data = {
"prompt":text,
"numVariations":2,
"seeds": [
2,
3
],
"size": {
"width": 2048,
"height": 2048
},
"contentClass": "photo",
"tileable": False
}
response = requests.post("https://firefly-api.adobe.io/v2/images/generate", json=data, timeout=10000000, headers = {
"X-API-Key":id,
"Authorization":f"Bearer {token}",
"Content-Type":"application/json"
})
return response.json()
def downloadFile(url, filePath):
with open(filePath,'wb') as output:
bits = requests.get(url, stream=True).content
output.write(bits)
prompt = "a pattern of gold metalwork with bright jewels."
result = generateImage(prompt, CLIENT_ID, token)
if "outputs" in result:
for output in result["outputs"]:
fileName = f'./img/{output["seed"]}.jpg';
downloadFile(output["image"]["presignedUrl"], fileName);
else:
print(json.dumps(result, indent=True))
Have something to add?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now