akhaliq HF Staff commited on
Commit
919f974
·
verified ·
1 Parent(s): e73925f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from rembg import remove
3
+ from PIL import Image
4
+
5
+ def remove_background(image):
6
+ """
7
+ Takes a PIL image as input and returns the image with background removed.
8
+ """
9
+ return remove(image)
10
+
11
+ # Create the Gradio interface
12
+ app = gr.Interface(
13
+ fn=remove_background,
14
+ inputs=gr.Image(type="pil", label="Upload an Image"),
15
+ outputs=gr.Image(type="pil", label="Image with Background Removed"),
16
+ title="Background Removal App",
17
+ description="Upload any image to remove its background using the U²-Net model.",
18
+ examples=[
19
+ ["example_images/person.jpg"],
20
+ ["example_images/object.png"]
21
+ ],
22
+ cache_examples=False,
23
+ theme="default"
24
+ )
25
+
26
+ # Launch the app
27
+ if __name__ == "__main__":
28
+ app.launch()