Fabrice-TIERCELIN commited on
Commit
bd39fc7
·
verified ·
1 Parent(s): 316c2e2

Default parameters

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -44,10 +44,17 @@ def predict(source_img, enlarge_top, enlarge_right, enlarge_bottom, enlarge_left
44
  random.seed(seed)
45
  #pipe = pipe.manual_seed(seed)
46
 
47
- imageio.imwrite("data.png", source_img)
 
 
 
48
 
49
  # Input image
50
- input_image = Image.open("data.png").convert("RGB")
 
 
 
 
51
  original_height, original_width, original_channel = np.array(input_image).shape
52
  output_width = enlarge_left + original_width + enlarge_right
53
  output_height = enlarge_top + original_height + enlarge_bottom
@@ -91,7 +98,7 @@ def predict(source_img, enlarge_top, enlarge_right, enlarge_bottom, enlarge_left
91
 
92
  # Mask
93
  mask_image = Image.new(mode = input_image.mode, size = (output_width, output_height), color = (255, 255, 255, 0))
94
- black_mask = Image.new(mode = input_image.mode, size = (original_width - 20, original_height - 20), color = (0, 0, 0, 0))
95
  mask_image.paste(black_mask, (enlarge_left + 10, enlarge_top + 10))
96
  mask_image = mask_image.filter(ImageFilter.BoxBlur(10))
97
 
@@ -129,7 +136,7 @@ def predict(source_img, enlarge_top, enlarge_right, enlarge_bottom, enlarge_left
129
  with gr.Blocks() as interface:
130
  gr.Markdown(
131
  """
132
- <big style="text-align: center;">Uncrop</big>
133
  <br/>
134
  <p style="text-align: center;">Enlarges the point of view of your image, up to 1 million pixels, freely, without account, without watermark, which can be downloaded</p>
135
  <br/>
@@ -177,11 +184,11 @@ with gr.Blocks() as interface:
177
  with gr.Accordion("Advanced options", open = False):
178
  negative_prompt = gr.Textbox(label = 'Negative prompt', placeholder = 'Describe what you do NOT want to see in the entire image', value = 'Border, frame, painting, scribbling, smear, noise, blur, watermark')
179
  denoising_steps = gr.Slider(minimum = 0, maximum = 1000, value = 1000, step = 1, label = "Denoising", info = "lower=irrelevant result, higher=relevant result")
180
- num_inference_steps = gr.Slider(minimum = 10, maximum = 25, value = 10, step = 1, label = "Number of inference steps", info = "lower=faster, higher=image quality")
181
  guidance_scale = gr.Slider(minimum = 1, maximum = 13, value = 7, step = 0.1, label = "Classifier-Free Guidance Scale", info = "lower=image quality, higher=follow the prompt")
182
  randomize_seed = gr.Checkbox(label = "Randomize seed (not working, always checked)", value = True, info = "If checked, result is always different")
183
  seed = gr.Slider(minimum = 0, maximum = max_64_bit_int, step = 1, randomize = True, label = "Seed (if not randomized)")
184
- debug_mode = gr.Checkbox(label = "Debug mode", value = True, info = "Show intermediate results")
185
  with gr.Row():
186
  submit = gr.Button("Uncrop", variant = "primary")
187
  with gr.Row():
 
44
  random.seed(seed)
45
  #pipe = pipe.manual_seed(seed)
46
 
47
+ try:
48
+ imageio.imwrite("data.png", source_img)
49
+ except:
50
+ raise gr.Error("Can't read input image. You can try to first save your image in another format (.webp, .png, .jpeg, .bmp...).")
51
 
52
  # Input image
53
+ try:
54
+ input_image = Image.open("data.png").convert("RGB")
55
+ except:
56
+ raise gr.Error("Can't open input image. You can try to first save your image in another format (.webp, .png, .jpeg, .bmp...).")
57
+
58
  original_height, original_width, original_channel = np.array(input_image).shape
59
  output_width = enlarge_left + original_width + enlarge_right
60
  output_height = enlarge_top + original_height + enlarge_bottom
 
98
 
99
  # Mask
100
  mask_image = Image.new(mode = input_image.mode, size = (output_width, output_height), color = (255, 255, 255, 0))
101
+ black_mask = Image.new(mode = input_image.mode, size = (original_width - 20, original_height - 20), color = (127, 127, 127, 0))
102
  mask_image.paste(black_mask, (enlarge_left + 10, enlarge_top + 10))
103
  mask_image = mask_image.filter(ImageFilter.BoxBlur(10))
104
 
 
136
  with gr.Blocks() as interface:
137
  gr.Markdown(
138
  """
139
+ <p style="text-align: center;"><b><big>Uncrop</big></b></p>
140
  <br/>
141
  <p style="text-align: center;">Enlarges the point of view of your image, up to 1 million pixels, freely, without account, without watermark, which can be downloaded</p>
142
  <br/>
 
184
  with gr.Accordion("Advanced options", open = False):
185
  negative_prompt = gr.Textbox(label = 'Negative prompt', placeholder = 'Describe what you do NOT want to see in the entire image', value = 'Border, frame, painting, scribbling, smear, noise, blur, watermark')
186
  denoising_steps = gr.Slider(minimum = 0, maximum = 1000, value = 1000, step = 1, label = "Denoising", info = "lower=irrelevant result, higher=relevant result")
187
+ num_inference_steps = gr.Slider(minimum = 10, maximum = 25, value = 20, step = 1, label = "Number of inference steps", info = "lower=faster, higher=image quality")
188
  guidance_scale = gr.Slider(minimum = 1, maximum = 13, value = 7, step = 0.1, label = "Classifier-Free Guidance Scale", info = "lower=image quality, higher=follow the prompt")
189
  randomize_seed = gr.Checkbox(label = "Randomize seed (not working, always checked)", value = True, info = "If checked, result is always different")
190
  seed = gr.Slider(minimum = 0, maximum = max_64_bit_int, step = 1, randomize = True, label = "Seed (if not randomized)")
191
+ debug_mode = gr.Checkbox(label = "Debug mode", value = False, info = "Show intermediate results")
192
  with gr.Row():
193
  submit = gr.Button("Uncrop", variant = "primary")
194
  with gr.Row():