Kvikontent commited on
Commit
bb4fab0
·
verified ·
1 Parent(s): 806fb09

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -21
app.py CHANGED
@@ -4,10 +4,10 @@ from PIL import Image
4
  import io
5
 
6
  def background_remover(input_image):
7
- input_bytes = input_image.read()
8
  input_img = Image.open(io.BytesIO(input_bytes))
9
- output_img = remove(input_img)
10
-
11
  buf = io.BytesIO()
12
  output_img.save(buf, format='PNG')
13
  buf.seek(0)
@@ -18,22 +18,16 @@ This app uses the rembg library to remove the background from uploaded images.
18
  Simply upload your image and let the model do its work. Download the result immediately after!
19
  """
20
 
21
- with gr.Blocks() as demo:
22
- gr.Markdown("<h1 style='text-align: center;'>Background Remover</h1>")
23
- gr.Markdown(description)
24
-
25
- with gr.Row():
26
- with gr.Column(scale=1):
27
- input_image = gr.Image(type='pil', label="Upload Image")
28
- with gr.Column(scale=1):
29
- output_image = gr.Image(type='pil', label="Result")
30
-
31
- with gr.Row():
32
- gr.Button("Remove Background").click(
33
- fn=background_remover,
34
- inputs=input_image,
35
- outputs=output_image
36
- )
37
 
38
- demo_examples = [["woman.jpg"], ["groot.jpg"]]
39
- demo.launch(share=True, examples=demo_examples, theme="soft")
 
4
  import io
5
 
6
  def background_remover(input_image):
7
+ input_bytes = input_image.read()
8
  input_img = Image.open(io.BytesIO(input_bytes))
9
+ output_img = remove(input_img)
10
+
11
  buf = io.BytesIO()
12
  output_img.save(buf, format='PNG')
13
  buf.seek(0)
 
18
  Simply upload your image and let the model do its work. Download the result immediately after!
19
  """
20
 
21
+ # Create the Gradio interface
22
+ iface = gr.Interface(
23
+ fn=background_remover,
24
+ inputs=gr.Image(type='pil', label="Upload Image"),
25
+ outputs="image",
26
+ examples=["woman.jpg", "groot.jpg"],
27
+ title="Background Remover",
28
+ description=description,
29
+ theme="soft"
30
+ )
 
 
 
 
 
 
31
 
32
+ # Launch the interface
33
+ iface.launch(share=True)