menghanxia commited on
Commit
2ac9f6b
1 Parent(s): 7da59af

support output to be moved to input

Browse files
Files changed (1) hide show
  1. app.py +10 -0
app.py CHANGED
@@ -47,6 +47,14 @@ def run_invhalf(invhalfer, input_img, decoding_only, device="cuda"):
47
  def click_run(input_img, decoding_only):
48
  output = run_invhalf(invhalfer, input_img, decoding_only, device)
49
  return output
 
 
 
 
 
 
 
 
50
 
51
  ## step 2: configure interface
52
  demo = gr.Blocks(title="ReversibleHalftoning")
@@ -63,8 +71,10 @@ with demo:
63
  Button_run = gr.Button(value="Run")
64
  with gr.Column():
65
  Image_output = gr.Image(type="numpy", label="Output").style(height=480)
 
66
 
67
  Button_run.click(fn=click_run, inputs=[Image_input, Radio_mode], outputs=Image_output)
 
68
 
69
  if RUN_MODE != "local":
70
  gr.Examples(examples=[
 
47
  def click_run(input_img, decoding_only):
48
  output = run_invhalf(invhalfer, input_img, decoding_only, device)
49
  return output
50
+
51
+
52
+ def click_move(output_img, decoding_only):
53
+ if decoding_only:
54
+ radio_status = "Halftoning (Photo2Halftone)"
55
+ else:
56
+ radio_status = "Restoration (Halftone2Photo)"
57
+ return output_img, radio_status, None
58
 
59
  ## step 2: configure interface
60
  demo = gr.Blocks(title="ReversibleHalftoning")
 
71
  Button_run = gr.Button(value="Run")
72
  with gr.Column():
73
  Image_output = gr.Image(type="numpy", label="Output").style(height=480)
74
+ Button_move = gr.Button(value="Use it as input")
75
 
76
  Button_run.click(fn=click_run, inputs=[Image_input, Radio_mode], outputs=Image_output)
77
+ Button_move.click(fn=click_move, inputs=[Image_output, Radio_mode], outputs=[Image_input, Radio_mode, Image_output])
78
 
79
  if RUN_MODE != "local":
80
  gr.Examples(examples=[