TobDeBer commited on
Commit
81d0a4c
1 Parent(s): 8553966

add negative prompt

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -16,8 +16,9 @@ css = """
16
  }
17
  """
18
 
19
- def generate(prompt, turbo_steps, samp_steps, seed, progress=gr.Progress(track_tqdm=True)):
20
  print("prompt = ", prompt)
 
21
  if seed < 0:
22
  seed = random.randint(1,999999)
23
  image = txt2img(
@@ -28,8 +29,9 @@ def generate(prompt, turbo_steps, samp_steps, seed, progress=gr.Progress(track_t
28
  ).images[0]
29
  upscaled_image = image.resize((1024,1024), 1)
30
  final_image = img2img(
31
- prompt,
32
- upscaled_image,
 
33
  num_inference_steps=samp_steps,
34
  guidance_scale=5,
35
  strength=1,
@@ -56,6 +58,7 @@ def set_base_models():
56
  with gr.Blocks(css=css) as demo:
57
  with gr.Column():
58
  prompt = gr.Textbox(label="Prompt")
 
59
  submit_btn = gr.Button("Generate", elem_classes="btn-green")
60
 
61
  with gr.Row():
@@ -66,7 +69,7 @@ with gr.Blocks(css=css) as demo:
66
 
67
  gallery = gr.Gallery(show_label=False, preview=True, container=False, height=1100)
68
 
69
- submit_btn.click(generate, [prompt, turbo_steps, sampling_steps, seed], [gallery, lastSeed], queue=True)
70
 
71
  txt2img, img2img = set_base_models()
72
- demo.launch(debug=True)
 
16
  }
17
  """
18
 
19
+ def generate(prompt, turbo_steps, samp_steps, seed, progress=gr.Progress(track_tqdm=True), negative_prompt = ""):
20
  print("prompt = ", prompt)
21
+ print("negative prompt = ", negative_prompt)
22
  if seed < 0:
23
  seed = random.randint(1,999999)
24
  image = txt2img(
 
29
  ).images[0]
30
  upscaled_image = image.resize((1024,1024), 1)
31
  final_image = img2img(
32
+ prompt=prompt,
33
+ negative_prompt=negative_prompt,
34
+ image=upscaled_image,
35
  num_inference_steps=samp_steps,
36
  guidance_scale=5,
37
  strength=1,
 
58
  with gr.Blocks(css=css) as demo:
59
  with gr.Column():
60
  prompt = gr.Textbox(label="Prompt")
61
+ negative_prompt = gr.Textbox(label="Negative Prompt")
62
  submit_btn = gr.Button("Generate", elem_classes="btn-green")
63
 
64
  with gr.Row():
 
69
 
70
  gallery = gr.Gallery(show_label=False, preview=True, container=False, height=1100)
71
 
72
+ submit_btn.click(generate, [prompt, turbo_steps, sampling_steps, seed, negative_prompt], [gallery, lastSeed], queue=True)
73
 
74
  txt2img, img2img = set_base_models()
75
+ demo.launch(debug=True)