Spaces:
Runtime error
Runtime error
init
Browse files- .gitignore +1 -0
- app.py +24 -0
- requirements.txt +8 -0
.gitignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
/venv
|
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
from PIL import Image
|
| 3 |
+
import gradio as gr
|
| 4 |
+
import spaces
|
| 5 |
+
|
| 6 |
+
@spaces.GPU
|
| 7 |
+
def remove_background_bria(input_image):
|
| 8 |
+
print(f"Removing background using bria for image")
|
| 9 |
+
pipe = pipeline("image-segmentation", model="briaai/RMBG-1.4", trust_remote_code=True, device=0)
|
| 10 |
+
input_image = Image.fromarray(input_image)
|
| 11 |
+
output_image = pipe(input_image)
|
| 12 |
+
return output_image
|
| 13 |
+
|
| 14 |
+
with gr.Blocks() as demo:
|
| 15 |
+
gr.Markdown("# Background Removal with BRIA")
|
| 16 |
+
with gr.Row():
|
| 17 |
+
input_image = gr.Image(label="Input Image")
|
| 18 |
+
output_image = gr.Image(label="Output Image")
|
| 19 |
+
|
| 20 |
+
remove_button = gr.Button("Remove Background")
|
| 21 |
+
remove_button.click(fn=remove_background_bria, inputs=input_image, outputs=output_image)
|
| 22 |
+
|
| 23 |
+
if __name__ == "__main__":
|
| 24 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
--extra-index-url https://download.pytorch.org/whl/cu118
|
| 2 |
+
torch==2.2.0+cu118
|
| 3 |
+
torchvision==0.17.0
|
| 4 |
+
gradio==4.41.0
|
| 5 |
+
spaces==0.29.3
|
| 6 |
+
transformers==4.42.4
|
| 7 |
+
scikit-image==0.24.0
|
| 8 |
+
|