Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -33,7 +33,7 @@ parsed_descriptions_queue = deque()
|
|
33 |
|
34 |
# Usage limits
|
35 |
MAX_DESCRIPTIONS = 30
|
36 |
-
MAX_IMAGES =
|
37 |
|
38 |
# Preload models and checkpoints
|
39 |
print("Preloading models and checkpoints...")
|
@@ -133,15 +133,14 @@ def generate_descriptions(user_prompt, seed_words_input, batch_size=100, max_ite
|
|
133 |
return list(parsed_descriptions_queue)
|
134 |
|
135 |
@spaces.GPU(duration=120)
|
136 |
-
def generate_images(parsed_descriptions, max_iterations=
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
prompts = [parsed_descriptions.pop(0) for _ in range(MAX_IMAGES)]
|
141 |
|
142 |
images = []
|
143 |
-
for prompt in
|
144 |
-
images.extend(pipe(prompt,
|
145 |
|
146 |
return images
|
147 |
|
|
|
33 |
|
34 |
# Usage limits
|
35 |
MAX_DESCRIPTIONS = 30
|
36 |
+
MAX_IMAGES = 2 # Limit to 2 images
|
37 |
|
38 |
# Preload models and checkpoints
|
39 |
print("Preloading models and checkpoints...")
|
|
|
133 |
return list(parsed_descriptions_queue)
|
134 |
|
135 |
@spaces.GPU(duration=120)
|
136 |
+
def generate_images(parsed_descriptions, max_iterations=2: # Set max_iterations to 1
|
137 |
+
# Limit the number of descriptions passed to the image generator to 2
|
138 |
+
if len(parsed_descriptions) > MAX_IMAGES:
|
139 |
+
parsed_descriptions = parsed_descriptions[:MAX_IMAGES]
|
|
|
140 |
|
141 |
images = []
|
142 |
+
for prompt in parsed_descriptions:
|
143 |
+
images.extend(pipe(prompt, num_inference_steps=max_iterations, height=512, width=512).images) # Set resolution to 512 x 512
|
144 |
|
145 |
return images
|
146 |
|