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
|
|
@@ -145,14 +145,25 @@ 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 |
images = generate_images(parsed_descriptions)
|
| 149 |
-
return
|
| 150 |
|
| 151 |
if __name__ == '__main__':
|
| 152 |
-
|
| 153 |
fn=combined_function,
|
| 154 |
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"...')],
|
| 155 |
-
outputs=
|
| 156 |
)
|
| 157 |
|
| 158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
# Usage limits
|
| 34 |
MAX_DESCRIPTIONS = 30
|
| 35 |
+
MAX_IMAGES = 3
|
| 36 |
|
| 37 |
def initialize_diffusers():
|
| 38 |
from optimum.quanto import freeze, qfloat8, quantize
|
|
|
|
| 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 |
+
description_interface = gr.Interface(
|
| 156 |
fn=combined_function,
|
| 157 |
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"...')],
|
| 158 |
+
outputs=gr.Textbox(label="Generated Descriptions")
|
| 159 |
)
|
| 160 |
|
| 161 |
+
image_interface = gr.Interface(
|
| 162 |
+
fn=generate_images_from_descriptions,
|
| 163 |
+
inputs=gr.Textbox(label="Generated Descriptions"),
|
| 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)
|