karthikcmani commited on
Commit
a54a7b1
·
verified ·
1 Parent(s): e525bd6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -16
app.py CHANGED
@@ -5,22 +5,16 @@ import io
5
 
6
  def remove_bg(image):
7
  img_bytes = io.BytesIO()
8
- image.save(img_bytes, format="PNG")
9
- output = remove(img_bytes.getvalue())
10
- return Image.open(io.BytesIO(output))
11
 
12
- with gr.Blocks(title="AI Background Remover") as demo:
13
- gr.Markdown("### 🖼️ AI Background Remover\nUpload an image and remove background instantly using **Rembg**")
14
-
15
- with gr.Row():
16
- input_img = gr.Image(type="pil", label="Upload Image")
17
- output_img = gr.Image(label="Result")
18
-
19
- with gr.Row():
20
- clear_btn = gr.ClearButton(input_img)
21
- process_btn = gr.Button("Remove Background")
22
-
23
- process_btn.click(fn=remove_bg, inputs=input_img, outputs=output_img)
24
 
25
  demo.launch()
26
- print("App running - built by Karthik")
 
5
 
6
  def remove_bg(image):
7
  img_bytes = io.BytesIO()
8
+ image.save(img_bytes, format='PNG')
9
+ result = remove(img_bytes.getvalue())
10
+ return Image.open(io.BytesIO(result))
11
 
12
+ demo = gr.Interface(
13
+ fn=remove_bg,
14
+ inputs=gr.Image(type="pil", label="🖼️ Upload an Image"),
15
+ outputs=gr.Image(label="✨ Background Removed"),
16
+ title="🎨 AI Background Remover",
17
+ description="Upload an image and instantly remove the background using AI",
18
+ )
 
 
 
 
 
19
 
20
  demo.launch()