Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -21,23 +21,20 @@ model_list = [
|
|
| 21 |
|
| 22 |
default_model = "stabilityai/stable-diffusion-2"
|
| 23 |
model_name = gr.inputs.Dropdown(choices=model_list, label="Select Model", default=default_model)
|
| 24 |
-
model = None
|
| 25 |
|
| 26 |
-
def
|
| 27 |
-
global model
|
| 28 |
model = gr.Interface.load(model_name, source="huggingface", api_key=api_key)
|
|
|
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
|
| 33 |
iface = gr.Interface(
|
| 34 |
-
fn=
|
| 35 |
-
inputs=model_name,
|
| 36 |
-
outputs=
|
| 37 |
-
title="
|
| 38 |
-
description="
|
| 39 |
)
|
| 40 |
|
| 41 |
-
load_model(default_model) # Load the default model initially
|
| 42 |
-
|
| 43 |
iface.launch()
|
|
|
|
| 21 |
|
| 22 |
default_model = "stabilityai/stable-diffusion-2"
|
| 23 |
model_name = gr.inputs.Dropdown(choices=model_list, label="Select Model", default=default_model)
|
|
|
|
| 24 |
|
| 25 |
+
def generate_image(text, model_name):
|
|
|
|
| 26 |
model = gr.Interface.load(model_name, source="huggingface", api_key=api_key)
|
| 27 |
+
return model.predict(text)
|
| 28 |
|
| 29 |
+
input_text = gr.inputs.Textbox(label="Input Text")
|
| 30 |
+
output_image = gr.outputs.Image(label="Generated Image")
|
| 31 |
|
| 32 |
iface = gr.Interface(
|
| 33 |
+
fn=generate_image,
|
| 34 |
+
inputs=[input_text, model_name],
|
| 35 |
+
outputs=output_image,
|
| 36 |
+
title="Text to Image Generation",
|
| 37 |
+
description="Generate an image from input text using a Hugging Face model."
|
| 38 |
)
|
| 39 |
|
|
|
|
|
|
|
| 40 |
iface.launch()
|