svjack commited on
Commit
981b9b1
1 Parent(s): fd582ec

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -4
app.py CHANGED
@@ -10,6 +10,9 @@ from datasets import load_dataset
10
  dataset = load_dataset("Gustavosta/Stable-Diffusion-Prompts")
11
  prompt_df = dataset["train"].to_pandas()
12
 
 
 
 
13
  def get_samples():
14
  prompt_list = prompt_df.sample(n = 10)["Prompt"].map(lambda x: x).values.tolist()
15
  return prompt_list
@@ -67,7 +70,9 @@ def generate_txt2img(current_model, prompt, is_negative=False, image_style="None
67
  API_TOKEN = os.environ.get("HF_READ_TOKEN")
68
  headers = {"Authorization": f"Bearer {API_TOKEN}"}
69
  if type(current_model) != type(""):
70
- current_model = "stabilityai/stable-diffusion-2-1"
 
 
71
  api = InferenceApi(current_model)
72
  api.headers = headers
73
 
@@ -225,15 +230,17 @@ with gr.Blocks(css=css) as demo:
225
  with gr.Column():
226
  btn_refresh = gr.Button(value="Click Refresh to get current deployed models")
227
  btn_refresh.click(None, js="window.location.reload()")
228
- current_model = gr.Dropdown(label="Current Model", choices=list_models, value="stabilityai/stable-diffusion-2-1")
229
 
230
  with gr.Row("prompt-container"):
231
  text_prompt = gr.Textbox(label="Prompt", placeholder="a cute dog",
232
- value = "1girl, aqua eyes, baseball cap, blonde hair, closed mouth, earrings, green background, hat, hoop earrings, jewelry, looking at viewer, shirt, short hair, simple background, solo, upper body, yellow shirt",
233
  lines=2, elem_id="prompt-text-input")
234
  text_button = gr.Button("Manualy input Generate", variant='primary', elem_id="gen-button")
235
  with gr.Row("prompt-container"):
236
- select_prompt = gr.Dropdown(label="prompt selected", choices=list_prompts, value=list_prompts[1])
 
 
237
  select_button = gr.Button("Select Prompt Generate", variant='primary', elem_id="gen-button")
238
 
239
  with gr.Row():
 
10
  dataset = load_dataset("Gustavosta/Stable-Diffusion-Prompts")
11
  prompt_df = dataset["train"].to_pandas()
12
 
13
+ DEFAULT_MODEL = "stabilityai/stable-diffusion-2-1"
14
+ DEFAULT_PROMPT = "1girl, aqua eyes, baseball cap, blonde hair, closed mouth, earrings, green background, hat, hoop earrings, jewelry, looking at viewer, shirt, short hair, simple background, solo, upper body, yellow shirt"
15
+
16
  def get_samples():
17
  prompt_list = prompt_df.sample(n = 10)["Prompt"].map(lambda x: x).values.tolist()
18
  return prompt_list
 
70
  API_TOKEN = os.environ.get("HF_READ_TOKEN")
71
  headers = {"Authorization": f"Bearer {API_TOKEN}"}
72
  if type(current_model) != type(""):
73
+ current_model = DEFAULT_MODEL
74
+ if type(prompt) != type(""):
75
+ prompt = DEFAULT_PROMPT
76
  api = InferenceApi(current_model)
77
  api.headers = headers
78
 
 
230
  with gr.Column():
231
  btn_refresh = gr.Button(value="Click Refresh to get current deployed models")
232
  btn_refresh.click(None, js="window.location.reload()")
233
+ current_model = gr.Dropdown(label="Current Model", choices=list_models, value=DEFAULT_MODEL)
234
 
235
  with gr.Row("prompt-container"):
236
  text_prompt = gr.Textbox(label="Prompt", placeholder="a cute dog",
237
+ value = DEFAULT_PROMPT,
238
  lines=2, elem_id="prompt-text-input")
239
  text_button = gr.Button("Manualy input Generate", variant='primary', elem_id="gen-button")
240
  with gr.Row("prompt-container"):
241
+ select_prompt = gr.Dropdown(label="prompt selected", choices=list_prompts,
242
+ value = "1girl, aqua eyes, baseball cap, blonde hair, closed mouth, earrings, green background, hat, hoop earrings, jewelry, looking at viewer, shirt, short hair, simple background, solo, upper body, yellow shirt"
243
+ )
244
  select_button = gr.Button("Select Prompt Generate", variant='primary', elem_id="gen-button")
245
 
246
  with gr.Row():