Ramzan0553 commited on
Commit
59dba31
·
verified ·
1 Parent(s): f0ed96c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from rembg import remove
3
+ from PIL import Image
4
+ import numpy as np
5
+
6
+ def remove_bg(input_image):
7
+ if input_image is None:
8
+ return None
9
+ input_image = Image.open(input_image).convert("RGBA") # Ensure RGBA format
10
+ output_image = remove(input_image) # Remove background
11
+ return output_image
12
+
13
+ iface = gr.Interface(
14
+ fn=remove_bg,
15
+ inputs=gr.Image(type="filepath", label="Upload an Image"),
16
+ outputs=gr.Image(type="pil", label="Background Removed Image"),
17
+ title="AI Background Remover",
18
+ description="Upload an image, and this tool will remove the background automatically.",
19
+ )
20
+
21
+ iface.launch(share=True)