dhanushreddy29 commited on
Commit
014c53c
·
verified ·
1 Parent(s): 7414c62

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +9 -7
main.py CHANGED
@@ -2,18 +2,18 @@ import gradio as gr
2
  from rembg import remove
3
  from PIL import Image
4
 
5
-
6
  def remove_background(input_image):
 
 
 
 
7
  output_image = remove(input_image)
8
  return output_image
9
 
10
-
11
- inputs = gr.inputs.Image()
12
- outputs = gr.outputs.Image(type="pil")
13
  interface = gr.Interface(
14
  fn=remove_background,
15
- inputs=inputs,
16
- outputs=outputs,
17
  title="Remove Background",
18
  description="This App removes the background from an image",
19
  examples=[
@@ -23,4 +23,6 @@ interface = gr.Interface(
23
  ],
24
  cache_examples=True,
25
  )
26
- interface.launch(enable_queue=True)
 
 
 
2
  from rembg import remove
3
  from PIL import Image
4
 
 
5
  def remove_background(input_image):
6
+ # Convert to PIL Image if not already
7
+ if not isinstance(input_image, Image.Image):
8
+ input_image = Image.fromarray(input_image)
9
+
10
  output_image = remove(input_image)
11
  return output_image
12
 
 
 
 
13
  interface = gr.Interface(
14
  fn=remove_background,
15
+ inputs=gr.Image(type="pil"),
16
+ outputs=gr.Image(type="pil"),
17
  title="Remove Background",
18
  description="This App removes the background from an image",
19
  examples=[
 
23
  ],
24
  cache_examples=True,
25
  )
26
+
27
+ if __name__ == "__main__":
28
+ interface.launch(enable_queue=True)