tonyassi commited on
Commit
cc8d15d
1 Parent(s): a11c80c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -21
app.py CHANGED
@@ -27,37 +27,23 @@ def divisible_by_8(image):
27
  return resized_image
28
 
29
 
30
- def generate(image_editor, prompt, neg_prompt, strength, guidance):
31
  image = image_editor['background'].convert('RGB')
32
  image.thumbnail((1024, 1024))
33
  image = divisible_by_8(image)
34
-
35
  original_image_size = image.size
36
 
37
-
38
  layer = image_editor["layers"][0].resize(image.size)
39
-
40
 
41
  image = squarify_image(image)
42
- #layer = squarify_image(layer)
43
 
44
  mask = Image.new("RGBA", image.size, "WHITE")
45
  mask.paste(layer, (0, 0), layer)
46
  mask = ImageOps.invert(mask.convert('L'))
47
 
48
-
49
-
50
-
51
-
52
  final_image = pipeline(prompt=prompt,
53
  image=image,
54
  mask_image=mask).images[0]
55
- #width=image.width,
56
- #height=image.height,
57
- #num_inference_steps=50,
58
- #strength=strength,
59
- #guidance_scale=guidance).images[0]
60
-
61
 
62
  final_image = final_image.crop((0, 0, original_image_size[0], original_image_size[1]))
63
 
@@ -77,17 +63,14 @@ with gr.Blocks() as demo:
77
  with gr.Column():
78
  version_gallery = gr.Gallery(label="Versions")
79
  restore_button = gr.Button("Restore Version")
80
-
81
- with gr.Accordion("Advanced Settings", open=False):
82
- neg_prompt = gr.Textbox(label='Negative Prompt', value='ugly, deformed, nsfw')
83
- strength_slider = gr.Slider(0.0, 1.0, value=1.0, label="Strength")
84
- guidance_slider = gr.Slider(1.0, 15.0, value=7.5, label="Guidance")
85
 
86
  with gr.Row():
87
  out1 = gr.Image(format='png')
88
  out2 = gr.Image(format='png')
89
  out3 = gr.Image(format='png')
90
 
91
- generate_button.click(fn=generate, inputs=[sketch_pad,prompt, neg_prompt, strength_slider, guidance_slider], outputs=[sketch_pad, out1, out2, out3])
92
 
93
  demo.launch()
 
27
  return resized_image
28
 
29
 
30
+ def generate(image_editor, prompt, neg_prompt):
31
  image = image_editor['background'].convert('RGB')
32
  image.thumbnail((1024, 1024))
33
  image = divisible_by_8(image)
 
34
  original_image_size = image.size
35
 
 
36
  layer = image_editor["layers"][0].resize(image.size)
 
37
 
38
  image = squarify_image(image)
 
39
 
40
  mask = Image.new("RGBA", image.size, "WHITE")
41
  mask.paste(layer, (0, 0), layer)
42
  mask = ImageOps.invert(mask.convert('L'))
43
 
 
 
 
 
44
  final_image = pipeline(prompt=prompt,
45
  image=image,
46
  mask_image=mask).images[0]
 
 
 
 
 
 
47
 
48
  final_image = final_image.crop((0, 0, original_image_size[0], original_image_size[1]))
49
 
 
63
  with gr.Column():
64
  version_gallery = gr.Gallery(label="Versions")
65
  restore_button = gr.Button("Restore Version")
66
+ with gr.Accordion("Advanced Settings", open=False):
67
+ neg_prompt = gr.Textbox(label='Negative Prompt', value='ugly, deformed, nsfw')
 
 
 
68
 
69
  with gr.Row():
70
  out1 = gr.Image(format='png')
71
  out2 = gr.Image(format='png')
72
  out3 = gr.Image(format='png')
73
 
74
+ generate_button.click(fn=generate, inputs=[sketch_pad,prompt, neg_prompt], outputs=[sketch_pad, out1, out2, out3])
75
 
76
  demo.launch()