-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_diff.py
More file actions
31 lines (25 loc) · 888 Bytes
/
python_diff.py
File metadata and controls
31 lines (25 loc) · 888 Bytes
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
import replicate
import requests
from dotenv import load_dotenv
from pprint import pprint
import random
load_dotenv()
def download_image(image_url, filename):
response = requests.get(image_url)
if response.status_code == 200:
with open(filename, 'wb') as file:
file.write(response.content)
else:
print("failure :(")
for i in range(10):
seed = random.randint(0, 100000)
output = replicate.run(
"stability-ai/sdxl:39ed52f2a78e934b3ba6e2a89f5b1c712de7dfea535525255b1aa35c5565e08b",
input={"prompt": "a man spending time with friends", "seed": seed}
)
pprint(output)
if output and isinstance(output, list) and output[0].startswith('http'):
download_image(output[0], f"output_{i+1}.jpg")
print(f"Image {i+1} generated and saved.")
else:
print(f"Failed to generate Image {i+1}.")