Zeph27 commited on
Commit
28a2385
1 Parent(s): 93c4d28
Files changed (2) hide show
  1. app.py +22 -0
  2. requirements.txt +6 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ from PIL import Image
3
+ import gradio as gr
4
+
5
+ def remove_background_bria(input_image):
6
+ print(f"Removing background using bria for image")
7
+ pipe = pipeline("image-segmentation", model="briaai/RMBG-1.4", trust_remote_code=True, device=-1)
8
+ input_image = Image.fromarray(input_image)
9
+ output_image = pipe(input_image)
10
+ return output_image
11
+
12
+ with gr.Blocks() as demo:
13
+ gr.Markdown("# Background Removal with BRIA")
14
+ with gr.Row():
15
+ input_image = gr.Image(label="Input Image")
16
+ output_image = gr.Image(label="Output Image")
17
+
18
+ remove_button = gr.Button("Remove Background")
19
+ remove_button.click(fn=remove_background_bria, inputs=input_image, outputs=output_image)
20
+
21
+ if __name__ == "__main__":
22
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ torch==2.2.0
2
+ torchvision==0.17.0
3
+ gradio==4.41.0
4
+ transformers==4.42.4
5
+ scikit-image==0.24.0
6
+