atatakun commited on
Commit
cc789d9
1 Parent(s): aee7150

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -6
app.py CHANGED
@@ -4,7 +4,7 @@ import cv2
4
  from annotator.util import resize_image, HWC3
5
 
6
  DESCRIPTION = '# ControlNet v1.1 Annotators (that runs on cpu only)'
7
- DESCRIPTION += '\n<p>HEIC image are not converted. Please use PNG or JPG images.</p>'
8
 
9
 
10
  model_canny = None
@@ -127,14 +127,18 @@ model_uniformer = None
127
  model_lineart_anime = None
128
 
129
 
130
- def lineart_anime(img, res):
131
  img = resize_image(HWC3(img), res)
132
  global model_lineart_anime
133
  if model_lineart_anime is None:
134
  from annotator.lineart_anime import LineartAnimeDetector
135
  model_lineart_anime = LineartAnimeDetector()
136
  # result = model_lineart_anime(img)
137
- result = cv2.bitwise_not(model_lineart_anime(img))
 
 
 
 
138
  return [result]
139
 
140
 
@@ -305,18 +309,19 @@ with block:
305
  run_button.click(fn=openpose, inputs=[input_image, resolution, hand_and_face], outputs=[gallery])
306
 
307
  with gr.Row():
308
- gr.Markdown("## Lineart Anime (The converted image is color-inverted.)")
309
  with gr.Row():
310
  with gr.Column():
311
  input_image = gr.Image(source='upload', type="numpy")
 
312
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
313
  run_button = gr.Button(label="Run")
314
  with gr.Column():
315
  gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
316
- run_button.click(fn=lineart_anime, inputs=[input_image, resolution], outputs=[gallery])
317
 
318
  with gr.Row():
319
- gr.Markdown("## Lineart (The converted image is color-inverted.)")
320
  with gr.Row():
321
  with gr.Column():
322
  input_image = gr.Image(source='upload', type="numpy")
 
4
  from annotator.util import resize_image, HWC3
5
 
6
  DESCRIPTION = '# ControlNet v1.1 Annotators (that runs on cpu only)'
7
+ DESCRIPTION += '\n<p>HEIC image are not converted. Please use PNG or JPG image.</p>'
8
 
9
 
10
  model_canny = None
 
127
  model_lineart_anime = None
128
 
129
 
130
+ def lineart_anime(img, res, invert=True):
131
  img = resize_image(HWC3(img), res)
132
  global model_lineart_anime
133
  if model_lineart_anime is None:
134
  from annotator.lineart_anime import LineartAnimeDetector
135
  model_lineart_anime = LineartAnimeDetector()
136
  # result = model_lineart_anime(img)
137
+ # result = model_lineart(img, coarse)
138
+ if (invert):
139
+ result = cv2.bitwise_not(model_lineart(img, coarse))
140
+ else:
141
+ result = model_lineart(img, coarse)
142
  return [result]
143
 
144
 
 
309
  run_button.click(fn=openpose, inputs=[input_image, resolution, hand_and_face], outputs=[gallery])
310
 
311
  with gr.Row():
312
+ gr.Markdown("## Lineart Anime \n<p>Check Invert to use with Mochi Diffusion.")
313
  with gr.Row():
314
  with gr.Column():
315
  input_image = gr.Image(source='upload', type="numpy")
316
+ invert = gr.Checkbox(label='Invert', value=True)
317
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
318
  run_button = gr.Button(label="Run")
319
  with gr.Column():
320
  gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
321
+ run_button.click(fn=lineart_anime, inputs=[input_image, resolution, invert], outputs=[gallery])
322
 
323
  with gr.Row():
324
+ gr.Markdown("## Lineart \n<p>Check Invert to use with Mochi Diffusion.")
325
  with gr.Row():
326
  with gr.Column():
327
  input_image = gr.Image(source='upload', type="numpy")