atatakun commited on
Commit
05ff922
1 Parent(s): 56b80b8

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -141,14 +141,17 @@ def lineart_anime(img, res):
141
  model_lineart = None
142
 
143
 
144
- def lineart(img, res, coarse=False):
145
  img = resize_image(HWC3(img), res)
146
  global model_lineart
147
  if model_lineart is None:
148
  from annotator.lineart import LineartDetector
149
  model_lineart = LineartDetector()
150
  # result = model_lineart(img, coarse)
151
- result = cv2.bitwise_not(model_lineart(img, coarse))
 
 
 
152
  return [result]
153
 
154
 
@@ -318,11 +321,12 @@ with block:
318
  with gr.Column():
319
  input_image = gr.Image(source='upload', type="numpy")
320
  coarse = gr.Checkbox(label='Using coarse model', value=False)
 
321
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
322
  run_button = gr.Button(label="Run")
323
  with gr.Column():
324
  gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
325
- run_button.click(fn=lineart, inputs=[input_image, resolution, coarse], outputs=[gallery])
326
 
327
  # with gr.Row():
328
  # gr.Markdown("## Uniformer Segmentation")
 
141
  model_lineart = None
142
 
143
 
144
+ def lineart(img, res, coarse=False, invert=True):
145
  img = resize_image(HWC3(img), res)
146
  global model_lineart
147
  if model_lineart is None:
148
  from annotator.lineart import LineartDetector
149
  model_lineart = LineartDetector()
150
  # result = model_lineart(img, coarse)
151
+ if invert is True
152
+ result = cv2.bitwise_not(model_lineart(img, coarse))
153
+ else
154
+ result = model_lineart(img, coarse)
155
  return [result]
156
 
157
 
 
321
  with gr.Column():
322
  input_image = gr.Image(source='upload', type="numpy")
323
  coarse = gr.Checkbox(label='Using coarse model', value=False)
324
+ invert = gr.Checkbox(label='Invert', value=True)
325
  resolution = gr.Slider(label="resolution", minimum=256, maximum=1024, value=512, step=64)
326
  run_button = gr.Button(label="Run")
327
  with gr.Column():
328
  gallery = gr.Gallery(label="Generated images", show_label=False).style(height="auto")
329
+ run_button.click(fn=lineart, inputs=[input_image, resolution, coarse, invert], outputs=[gallery])
330
 
331
  # with gr.Row():
332
  # gr.Markdown("## Uniformer Segmentation")