Jagrut Thakare commited on
Commit
ae0de65
·
1 Parent(s): 274b9fb
Files changed (2) hide show
  1. README.md +2 -2
  2. app.py +11 -3
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
  title: Object Remover
3
  emoji: ⚡
4
- colorFrom: gray
5
- colorTo: gray
6
  sdk: gradio
7
  sdk_version: 5.23.1
8
  app_file: app.py
 
1
  ---
2
  title: Object Remover
3
  emoji: ⚡
4
+ colorFrom: indigo
5
+ colorTo: green
6
  sdk: gradio
7
  sdk_version: 5.23.1
8
  app_file: app.py
app.py CHANGED
@@ -10,9 +10,15 @@ import spaces
10
  login(os.getenv("HF_TOKEN"))
11
 
12
  @spaces.GPU()
13
- def process_image(image, progress=gr.Progress(track_tqdm=True)):
14
- output = process_inpaint(image["background"], image["layers"][0])
 
 
 
 
 
15
  img_output = Image.fromarray(output).convert("RGB")
 
16
  return img_output
17
 
18
 
@@ -21,9 +27,11 @@ with gr.Blocks() as demo:
21
  with gr.Row():
22
  with gr.Column():
23
  image = gr.ImageMask(type="numpy", layers=False, label="Upload Image")
 
 
24
  button = gr.Button("Remove")
25
  with gr.Column():
26
  output = gr.Image(format="png", label="Output Image")
27
- button.click(fn=process_image, inputs=[image], outputs=[output])
28
 
29
  demo.launch(debug=True)
 
10
  login(os.getenv("HF_TOKEN"))
11
 
12
  @spaces.GPU()
13
+ def process_image(image, mask, progress=gr.Progress(track_tqdm=True)):
14
+ if np.unique(mask["background"]).size == 1:
15
+ print("\n Did not Receive Mask\n")
16
+ output = process_inpaint(image["background"], image["layers"][0])
17
+ else:
18
+ print("Processing Received Mask")
19
+ output = process_inpaint(image["background"], mask["background"])
20
  img_output = Image.fromarray(output).convert("RGB")
21
+
22
  return img_output
23
 
24
 
 
27
  with gr.Row():
28
  with gr.Column():
29
  image = gr.ImageMask(type="numpy", layers=False, label="Upload Image")
30
+ with gr.Accordion(label="Advanced", open=False):
31
+ mask = gr.ImageMask(type="numpy", layers=False, label="Upload Mask")
32
  button = gr.Button("Remove")
33
  with gr.Column():
34
  output = gr.Image(format="png", label="Output Image")
35
+ button.click(fn=process_image, inputs=[image, mask], outputs=[output])
36
 
37
  demo.launch(debug=True)