Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,21 +17,22 @@ models = [
|
|
| 17 |
"models/stabilityai/stable-diffusion-2-1-unclip-small"
|
| 18 |
]
|
| 19 |
|
| 20 |
-
def
|
| 21 |
model = gr.Interface.load(model_name, api_key=os.getenv("HUGGINGFACE_API_KEY"))
|
| 22 |
-
|
|
|
|
| 23 |
|
| 24 |
model_dropdown = gr.inputs.Dropdown(models, label="Select Model")
|
| 25 |
input_text = gr.inputs.Textbox(lines=5, label="Input Text")
|
| 26 |
-
|
| 27 |
|
| 28 |
def change_model(model_name):
|
| 29 |
global interface
|
| 30 |
interface.close()
|
| 31 |
-
interface = gr.Interface(
|
| 32 |
interface.launch()
|
| 33 |
|
| 34 |
-
interface = gr.Interface(
|
| 35 |
|
| 36 |
change_model_button = gr.Interface.load("models/stabilityai/stable-diffusion-2", capture_session=True).launch()
|
| 37 |
interface.launch()
|
|
|
|
| 17 |
"models/stabilityai/stable-diffusion-2-1-unclip-small"
|
| 18 |
]
|
| 19 |
|
| 20 |
+
def generate_image(model_name, input_text):
|
| 21 |
model = gr.Interface.load(model_name, api_key=os.getenv("HUGGINGFACE_API_KEY"))
|
| 22 |
+
output_image = model.process(input_text)
|
| 23 |
+
return output_image
|
| 24 |
|
| 25 |
model_dropdown = gr.inputs.Dropdown(models, label="Select Model")
|
| 26 |
input_text = gr.inputs.Textbox(lines=5, label="Input Text")
|
| 27 |
+
output_image = gr.outputs.Image(label="Output Image")
|
| 28 |
|
| 29 |
def change_model(model_name):
|
| 30 |
global interface
|
| 31 |
interface.close()
|
| 32 |
+
interface = gr.Interface(generate_image, inputs=[model_name, input_text], outputs=output_image)
|
| 33 |
interface.launch()
|
| 34 |
|
| 35 |
+
interface = gr.Interface(generate_image, inputs=[model_dropdown, input_text], outputs=output_image, capture_session=True)
|
| 36 |
|
| 37 |
change_model_button = gr.Interface.load("models/stabilityai/stable-diffusion-2", capture_session=True).launch()
|
| 38 |
interface.launch()
|