Initial commit
This commit is contained in:
commit
25347a86e6
|
@ -0,0 +1,24 @@
|
|||
import openai
|
||||
import datetime
|
||||
import requests
|
||||
|
||||
openai.api_key = "API_TOKEN"
|
||||
|
||||
promtInput = input("Your prompt: ")
|
||||
response = openai.Image.create(
|
||||
prompt = promtInput,
|
||||
n = 4,
|
||||
size = "1024x1024"
|
||||
)
|
||||
|
||||
# Current time
|
||||
current_time = datetime.datetime.now()
|
||||
|
||||
# Format current time to a filename and save it to disk
|
||||
for i in range(4):
|
||||
image_url = response['data'][i]['url']
|
||||
formatDateTime = str(current_time.year) + "-" + str(current_time.month) + "-" + str(current_time.day) + "_" + str(current_time.hour) + "-" + str(current_time.minute) + "-" + str(current_time.second) + "_Image-" + str(i+1) + ".png"
|
||||
img_data = requests.get(image_url).content
|
||||
with open(formatDateTime, 'wb') as handler:
|
||||
handler.write(img_data)
|
||||
print("Image " + str(i+1) + " saved.")
|
Loading…
Reference in New Issue