VIATEUR-AI commited on
Commit
3d80a56
·
verified ·
1 Parent(s): 655c93f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -2,20 +2,22 @@
2
  import gradio as gr
3
  from rembg import remove
4
  from PIL import Image
5
- import io
6
 
7
- # Function to remove background
8
  def remove_background(image):
9
- # Convert uploaded image to PIL
 
 
 
 
10
  pil_image = Image.fromarray(image).convert("RGBA")
11
 
12
  # Remove background
13
  result = remove(pil_image)
14
 
15
- # Convert result to displayable format
16
  return result
17
 
18
- # Gradio UI
19
  title = "AI Background Remover"
20
  description = "Upload an image and remove its background instantly! Made by Viateur Irasubiza."
21
 
@@ -28,5 +30,5 @@ iface = gr.Interface(
28
  allow_flagging="never"
29
  )
30
 
31
- # Launch the app
32
- iface.launch()
 
2
  import gradio as gr
3
  from rembg import remove
4
  from PIL import Image
5
+ import numpy as np
6
 
 
7
  def remove_background(image):
8
+ """
9
+ Remove background from an uploaded image using rembg CPU backend.
10
+ Returns the processed image with transparency.
11
+ """
12
+ # Ensure the image is RGBA
13
  pil_image = Image.fromarray(image).convert("RGBA")
14
 
15
  # Remove background
16
  result = remove(pil_image)
17
 
 
18
  return result
19
 
20
+ # Gradio Interface
21
  title = "AI Background Remover"
22
  description = "Upload an image and remove its background instantly! Made by Viateur Irasubiza."
23
 
 
30
  allow_flagging="never"
31
  )
32
 
33
+ if __name__ == "__main__":
34
+ iface.launch()