Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
|
|
|
|
|
|
|
| 4 |
model_list = [
|
| 5 |
"stabilityai/stable-diffusion-xl-base-0.9",
|
| 6 |
"stabilityai/stable-diffusion-2-1",
|
|
@@ -17,14 +19,26 @@ model_list = [
|
|
| 17 |
"stabilityai/stable-diffusion-2-1-unclip-small"
|
| 18 |
]
|
| 19 |
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
exit()
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
|
| 4 |
+
api_key = os.environ.get("HUGGINGFACE_API_KEY")
|
| 5 |
+
|
| 6 |
model_list = [
|
| 7 |
"stabilityai/stable-diffusion-xl-base-0.9",
|
| 8 |
"stabilityai/stable-diffusion-2-1",
|
|
|
|
| 19 |
"stabilityai/stable-diffusion-2-1-unclip-small"
|
| 20 |
]
|
| 21 |
|
| 22 |
+
default_model = "stabilityai/stable-diffusion-2"
|
| 23 |
+
model_name = gr.inputs.Dropdown(model_list, label="Select Model", default=default_model)
|
| 24 |
+
model = None
|
| 25 |
+
|
| 26 |
+
def load_model(model_name):
|
| 27 |
+
global model
|
| 28 |
+
model = gr.Interface.load(model_name, api_key=api_key)
|
| 29 |
|
| 30 |
+
def predict(inputs):
|
| 31 |
+
return model.predict(inputs)
|
|
|
|
| 32 |
|
| 33 |
+
iface = gr.Interface(
|
| 34 |
+
fn=predict,
|
| 35 |
+
inputs=model,
|
| 36 |
+
outputs="text",
|
| 37 |
+
capture_session=True,
|
| 38 |
+
title="Model Selection App",
|
| 39 |
+
description="Choose a model and input data to make predictions."
|
| 40 |
+
)
|
| 41 |
|
| 42 |
+
load_model(default_model) # Load the default model initially
|
| 43 |
|
| 44 |
+
iface.launch()
|