Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -32,7 +32,7 @@ parsed_descriptions_queue = deque()
|
|
| 32 |
|
| 33 |
# Usage limits
|
| 34 |
MAX_DESCRIPTIONS = 30
|
| 35 |
-
MAX_IMAGES =
|
| 36 |
|
| 37 |
def initialize_diffusers():
|
| 38 |
from optimum.quanto import freeze, qfloat8, quantize
|
|
@@ -88,7 +88,7 @@ def parse_descriptions(text):
|
|
| 88 |
return descriptions
|
| 89 |
|
| 90 |
@spaces.GPU
|
| 91 |
-
def generate_descriptions(user_prompt, seed_words_input, batch_size=100, max_iterations=
|
| 92 |
descriptions = []
|
| 93 |
description_queue = deque()
|
| 94 |
iteration_count = 0
|
|
@@ -128,8 +128,8 @@ def generate_descriptions(user_prompt, seed_words_input, batch_size=100, max_ite
|
|
| 128 |
|
| 129 |
return list(parsed_descriptions_queue)
|
| 130 |
|
| 131 |
-
@spaces.GPU
|
| 132 |
-
def generate_images(parsed_descriptions, max_iterations=
|
| 133 |
pipe = initialize_diffusers()
|
| 134 |
|
| 135 |
if len(parsed_descriptions) < MAX_IMAGES:
|
|
@@ -139,7 +139,7 @@ def generate_images(parsed_descriptions, max_iterations=3):
|
|
| 139 |
|
| 140 |
images = []
|
| 141 |
for prompt in prompts:
|
| 142 |
-
images.extend(pipe(prompt, num_images=1, num_inference_steps=max_iterations, height=
|
| 143 |
|
| 144 |
return images
|
| 145 |
|
|
@@ -161,4 +161,4 @@ if __name__ == '__main__':
|
|
| 161 |
allow_flagging='never' # Disable flagging
|
| 162 |
)
|
| 163 |
|
| 164 |
-
interface.launch(share=True)
|
|
|
|
| 32 |
|
| 33 |
# Usage limits
|
| 34 |
MAX_DESCRIPTIONS = 30
|
| 35 |
+
MAX_IMAGES = 1 # Generate only 1 image
|
| 36 |
|
| 37 |
def initialize_diffusers():
|
| 38 |
from optimum.quanto import freeze, qfloat8, quantize
|
|
|
|
| 88 |
return descriptions
|
| 89 |
|
| 90 |
@spaces.GPU
|
| 91 |
+
def generate_descriptions(user_prompt, seed_words_input, batch_size=100, max_iterations=1): # Set max_iterations to 1
|
| 92 |
descriptions = []
|
| 93 |
description_queue = deque()
|
| 94 |
iteration_count = 0
|
|
|
|
| 128 |
|
| 129 |
return list(parsed_descriptions_queue)
|
| 130 |
|
| 131 |
+
@spaces.GPU
|
| 132 |
+
def generate_images(parsed_descriptions, max_iterations=2): # Set max_iterations to 1
|
| 133 |
pipe = initialize_diffusers()
|
| 134 |
|
| 135 |
if len(parsed_descriptions) < MAX_IMAGES:
|
|
|
|
| 139 |
|
| 140 |
images = []
|
| 141 |
for prompt in prompts:
|
| 142 |
+
images.extend(pipe(prompt, num_images=1, num_inference_steps=max_iterations, height=512, width=512).images) # Set resolution to 512 x 512
|
| 143 |
|
| 144 |
return images
|
| 145 |
|
|
|
|
| 161 |
allow_flagging='never' # Disable flagging
|
| 162 |
)
|
| 163 |
|
| 164 |
+
interface.launch(share=True)
|