Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -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
|
|
@@ -129,7 +129,7 @@ def generate_descriptions(user_prompt, seed_words_input, batch_size=100, max_ite
|
|
| 129 |
return list(parsed_descriptions_queue)
|
| 130 |
|
| 131 |
@spaces.GPU(duration=120)
|
| 132 |
-
def generate_images(parsed_descriptions, max_iterations=
|
| 133 |
pipe = initialize_diffusers()
|
| 134 |
|
| 135 |
if len(parsed_descriptions) < MAX_IMAGES:
|
|
@@ -145,25 +145,19 @@ def generate_images(parsed_descriptions, max_iterations=10):
|
|
| 145 |
|
| 146 |
def combined_function(user_prompt, seed_words_input):
|
| 147 |
parsed_descriptions = generate_descriptions(user_prompt, seed_words_input)
|
| 148 |
-
return parsed_descriptions
|
| 149 |
-
|
| 150 |
-
def generate_images_from_descriptions(parsed_descriptions):
|
| 151 |
images = generate_images(parsed_descriptions)
|
| 152 |
-
return images
|
| 153 |
|
| 154 |
if __name__ == '__main__':
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
outputs=gr.Textbox(label="Generated Descriptions")
|
| 159 |
-
)
|
| 160 |
|
| 161 |
-
|
| 162 |
-
fn=
|
| 163 |
-
inputs=gr.Textbox(
|
| 164 |
-
outputs=gr.Gallery(label="Generated Images")
|
|
|
|
| 165 |
)
|
| 166 |
|
| 167 |
-
interface = gr.TabbedInterface([description_interface, image_interface], ["Generate Descriptions", "Generate Images"])
|
| 168 |
-
|
| 169 |
interface.launch(share=True)
|
|
|
|
| 88 |
return descriptions
|
| 89 |
|
| 90 |
@spaces.GPU
|
| 91 |
+
def generate_descriptions(user_prompt, seed_words_input, batch_size=100, max_iterations=2):
|
| 92 |
descriptions = []
|
| 93 |
description_queue = deque()
|
| 94 |
iteration_count = 0
|
|
|
|
| 129 |
return list(parsed_descriptions_queue)
|
| 130 |
|
| 131 |
@spaces.GPU(duration=120)
|
| 132 |
+
def generate_images(parsed_descriptions, max_iterations=3):
|
| 133 |
pipe = initialize_diffusers()
|
| 134 |
|
| 135 |
if len(parsed_descriptions) < MAX_IMAGES:
|
|
|
|
| 145 |
|
| 146 |
def combined_function(user_prompt, seed_words_input):
|
| 147 |
parsed_descriptions = generate_descriptions(user_prompt, seed_words_input)
|
|
|
|
|
|
|
|
|
|
| 148 |
images = generate_images(parsed_descriptions)
|
| 149 |
+
return parsed_descriptions, images
|
| 150 |
|
| 151 |
if __name__ == '__main__':
|
| 152 |
+
def generate_and_display(user_prompt, seed_words_input):
|
| 153 |
+
parsed_descriptions, images = combined_function(user_prompt, seed_words_input)
|
| 154 |
+
return gr.update(value=parsed_descriptions, visible=True), gr.update(value=images, visible=True)
|
|
|
|
|
|
|
| 155 |
|
| 156 |
+
interface = gr.Interface(
|
| 157 |
+
fn=generate_and_display,
|
| 158 |
+
inputs=[gr.Textbox(lines=2, placeholder="Enter a prompt for descriptions..."), gr.Textbox(lines=2, placeholder='Enter seed words in quotes, e.g., "cat", "dog", "sunset"...')],
|
| 159 |
+
outputs=[gr.Row([gr.Column([gr.Textbox(label="Generated Descriptions")]), gr.Column([gr.Gallery(label="Generated Images")])])],
|
| 160 |
+
live=True
|
| 161 |
)
|
| 162 |
|
|
|
|
|
|
|
| 163 |
interface.launch(share=True)
|