xnetba commited on
Commit
134ee73
·
1 Parent(s): 1cd1277

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -12
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 load_model(model_name):
27
- global model
28
  model = gr.Interface.load(model_name, source="huggingface", 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_name,
36
- outputs="text",
37
- title="Model Selection App",
38
- description="Choose a model and input data to make predictions."
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()