hysts HF staff commited on
Commit
edb2f4b
1 Parent(s): 206fc98
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -58,7 +58,8 @@ style_list = [
58
  ]
59
 
60
  styles = {k["name"]: (k["prompt"], k["negative_prompt"]) for k in style_list}
61
- default_style = styles["Photographic"]
 
62
  style_names = list(styles.keys())
63
 
64
 
@@ -99,18 +100,18 @@ def run(
99
  image: PIL.Image.Image,
100
  prompt: str,
101
  negative_prompt: str,
102
- style=default_style,
103
- num_steps=25,
104
- guidance_scale=5,
105
- adapter_conditioning_scale=0.8,
106
- cond_tau=0.8,
107
- seed=0,
108
  ) -> PIL.Image.Image:
109
  image = image.convert("RGB").resize((1024, 1024))
110
  image = TF.to_tensor(image) > 0.5
111
  image = TF.to_pil_image(image.to(torch.float32))
112
 
113
- prompt, negative_prompt = apply_style(style, prompt, negative_prompt)
114
 
115
  generator = torch.Generator(device=device).manual_seed(seed)
116
  out = pipe(
@@ -144,7 +145,7 @@ with gr.Blocks() as demo:
144
  prompt = gr.Textbox(label="Prompt")
145
  run_button = gr.Button("Run")
146
  with gr.Accordion("Advanced options", open=False):
147
- style = gr.Dropdown(choices=style_names, value=default_style, label="Style")
148
  negative_prompt = gr.Textbox(label="Negative prompt", value="")
149
  num_steps = gr.Slider(
150
  label="Number of steps",
 
58
  ]
59
 
60
  styles = {k["name"]: (k["prompt"], k["negative_prompt"]) for k in style_list}
61
+ default_style_name = "Photographic"
62
+ default_style = styles[default_style_name]
63
  style_names = list(styles.keys())
64
 
65
 
 
100
  image: PIL.Image.Image,
101
  prompt: str,
102
  negative_prompt: str,
103
+ style_name: str = default_style_name,
104
+ num_steps: int = 25,
105
+ guidance_scale: float = 5,
106
+ adapter_conditioning_scale: float = 0.8,
107
+ cond_tau: float = 0.8,
108
+ seed: int = 0,
109
  ) -> PIL.Image.Image:
110
  image = image.convert("RGB").resize((1024, 1024))
111
  image = TF.to_tensor(image) > 0.5
112
  image = TF.to_pil_image(image.to(torch.float32))
113
 
114
+ prompt, negative_prompt = apply_style(style_name, prompt, negative_prompt)
115
 
116
  generator = torch.Generator(device=device).manual_seed(seed)
117
  out = pipe(
 
145
  prompt = gr.Textbox(label="Prompt")
146
  run_button = gr.Button("Run")
147
  with gr.Accordion("Advanced options", open=False):
148
+ style = gr.Dropdown(choices=style_names, value=default_style_name, label="Style")
149
  negative_prompt = gr.Textbox(label="Negative prompt", value="")
150
  num_steps = gr.Slider(
151
  label="Number of steps",