nsfwalex commited on
Commit
92f472f
โ€ข
1 Parent(s): 60efdc5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -14
app.py CHANGED
@@ -29,10 +29,10 @@ def deep_nude_process(inputpath):
29
  def inference(img):
30
  global index
31
  bgra = cv2.cvtColor(img, cv2.COLOR_RGBA2BGRA)
32
- inputpath = "input_" + str(index) + ".jpg"
33
  cv2.imwrite(inputpath, bgra)
34
 
35
- outputpath = "out_" + str(index) + ".jpg"
36
  index += 1
37
  print(time.strftime("START!!!!!!!!! %Y-%m-%d %H:%M:%S", time.localtime()))
38
  output = mainTest(inputpath, outputpath)
@@ -47,16 +47,11 @@ examples = [
47
  ['input.jpg', 'Test'],
48
  ]
49
 
50
- def update_image(img):
51
- return gr.update(value=inference(img))
 
 
 
 
52
 
53
- web = gr.Interface(fn=update_image,
54
- inputs=gr.Image(type="numpy", label="Upload Image"),
55
- outputs=gr.Image(type="numpy", label="Processed Image"),
56
- title=title,
57
- description=description,
58
- examples=examples,
59
- )
60
-
61
- if __name__ == '__main__':
62
- web.launch()
 
29
  def inference(img):
30
  global index
31
  bgra = cv2.cvtColor(img, cv2.COLOR_RGBA2BGRA)
32
+ inputpath = f"input_{index}.jpg"
33
  cv2.imwrite(inputpath, bgra)
34
 
35
+ outputpath = f"out_{index}.jpg"
36
  index += 1
37
  print(time.strftime("START!!!!!!!!! %Y-%m-%d %H:%M:%S", time.localtime()))
38
  output = mainTest(inputpath, outputpath)
 
47
  ['input.jpg', 'Test'],
48
  ]
49
 
50
+ with gr.Blocks() as demo:
51
+ with gr.Column():
52
+ image_input = gr.Image(type="numpy", label="Upload Image")
53
+ process_button = gr.Button("Process Image")
54
+
55
+ process_button.click(inference, inputs=image_input, outputs=image_input)
56
 
57
+ demo.launch()