Spaces:
Sleeping
Sleeping
kumahiyo
commited on
Commit
•
7e1b030
1
Parent(s):
5400559
add seed no
Browse files
main.py
CHANGED
@@ -30,13 +30,18 @@ def draw(data: Data):
|
|
30 |
if data.member_secret != "" and data.member_secret == os.environ.get("MEMBER_SECRET"):
|
31 |
print(f"Is CUDA available: {torch.cuda.is_available()}")
|
32 |
|
|
|
33 |
if '_seed' in data.string:
|
34 |
seed = 1024
|
|
|
|
|
|
|
|
|
35 |
else:
|
36 |
seed = random.randrange(1024)
|
37 |
|
38 |
text = re.sub('^#', '', data.string)
|
39 |
-
text = re.sub('_seed', '', text)
|
40 |
|
41 |
# prompt = '(('+text+')) (( photograph )), highly detailed, sharp focus, 8k, 4k, (( photorealism )), detailed, saturated, portrait, 50mm, F/2.8, 1m away, ( global illumination, studio light, volumetric light ), ((( multicolor lights )))'
|
42 |
prompt = '(('+text+')) (( photograph )), highly detailed, sharp focus, 8k, 4k, (( photorealism )), detailed, saturated, portrait, 50mm, F/2.8, 1m away, ((( multicolor lights )))'
|
@@ -56,7 +61,11 @@ def draw(data: Data):
|
|
56 |
generator = torch.Generator("cuda").manual_seed(seed)
|
57 |
images = pipe(prompt, negative_prompt=n_prompt, guidance_scale=7.5, generator=generator, num_images_per_prompt=1).images
|
58 |
|
59 |
-
|
|
|
|
|
|
|
|
|
60 |
|
61 |
fileName = "sd_" + str(time.time()) + '.png'
|
62 |
grid.save("/code/tmpdir/" + fileName)
|
|
|
30 |
if data.member_secret != "" and data.member_secret == os.environ.get("MEMBER_SECRET"):
|
31 |
print(f"Is CUDA available: {torch.cuda.is_available()}")
|
32 |
|
33 |
+
seedno = 0
|
34 |
if '_seed' in data.string:
|
35 |
seed = 1024
|
36 |
+
stext = re.search(r'_seed[1-4]?', text)
|
37 |
+
stext = re.sub('_seed', '', stext.group())
|
38 |
+
if stext.isnumeric() and 0 < int(stext) < 5:
|
39 |
+
seedno = stext
|
40 |
else:
|
41 |
seed = random.randrange(1024)
|
42 |
|
43 |
text = re.sub('^#', '', data.string)
|
44 |
+
text = re.sub('_seed[1-4]?', '', text)
|
45 |
|
46 |
# prompt = '(('+text+')) (( photograph )), highly detailed, sharp focus, 8k, 4k, (( photorealism )), detailed, saturated, portrait, 50mm, F/2.8, 1m away, ( global illumination, studio light, volumetric light ), ((( multicolor lights )))'
|
47 |
prompt = '(('+text+')) (( photograph )), highly detailed, sharp focus, 8k, 4k, (( photorealism )), detailed, saturated, portrait, 50mm, F/2.8, 1m away, ((( multicolor lights )))'
|
|
|
61 |
generator = torch.Generator("cuda").manual_seed(seed)
|
62 |
images = pipe(prompt, negative_prompt=n_prompt, guidance_scale=7.5, generator=generator, num_images_per_prompt=1).images
|
63 |
|
64 |
+
if 0 < int(seedno) < 5:
|
65 |
+
grid = images[(int(seedno) - 1)]
|
66 |
+
else:
|
67 |
+
# Limit of T4 small...
|
68 |
+
grid = image_grid(images, rows=1, cols=1)
|
69 |
|
70 |
fileName = "sd_" + str(time.time()) + '.png'
|
71 |
grid.save("/code/tmpdir/" + fileName)
|