karthikcmani commited on
Commit
e838934
·
verified ·
1 Parent(s): 920ba72

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -15
app.py CHANGED
@@ -4,26 +4,17 @@ from PIL import Image
4
  import io
5
 
6
  def remove_bg(image):
7
- # Convert PIL image to bytes
8
  img_bytes = io.BytesIO()
9
- image.save(img_bytes, format="PNG")
10
-
11
- # Remove background
12
  result = remove(img_bytes.getvalue())
13
-
14
- # Convert bytes back to PIL image
15
  return Image.open(io.BytesIO(result))
16
 
17
- # Gradio interface
18
  demo = gr.Interface(
19
  fn=remove_bg,
20
- inputs=gr.Image(type="pil", label="🖼️ Upload an Image"),
21
- outputs=gr.Image(label="Background Removed"),
22
- title="🎨 AI Background Remover",
23
- description="Upload an image and instantly remove its background using **Rembg**.",
24
- theme=gr.themes.Soft(primary_hue="emerald", secondary_hue="teal")
25
  )
26
 
27
- # Launch app
28
- demo.launch(share=True)
29
- print("App running - built by Karthik")
 
4
  import io
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 any image to remove its background instantly using Rembg!"
 
18
  )
19
 
20
+ demo.launch()