Spaces:
Running
on
Zero
Running
on
Zero
Upload folder using huggingface_hub
Browse files- remove-backround-gradio.py +4 -1
- requirements.txt +1 -0
remove-backround-gradio.py
CHANGED
|
@@ -5,7 +5,9 @@ from PIL import Image
|
|
| 5 |
import io
|
| 6 |
import zipfile
|
| 7 |
from typing import List, Tuple
|
|
|
|
| 8 |
|
|
|
|
| 9 |
def remove_background_single(image_file) -> Image.Image:
|
| 10 |
"""Remove background from a single image file"""
|
| 11 |
if image_file is None:
|
|
@@ -25,6 +27,7 @@ def remove_background_single(image_file) -> Image.Image:
|
|
| 25 |
output_image = Image.open(io.BytesIO(output_data))
|
| 26 |
return output_image
|
| 27 |
|
|
|
|
| 28 |
def remove_background_multiple(image_files) -> Tuple[str, List[Image.Image]]:
|
| 29 |
"""Remove background from multiple image files and return as zip + preview images"""
|
| 30 |
if not image_files:
|
|
@@ -215,4 +218,4 @@ with gr.Blocks(title="Background Removal Tool", theme=gr.themes.Default()) as ap
|
|
| 215 |
)
|
| 216 |
|
| 217 |
if __name__ == "__main__":
|
| 218 |
-
app.launch(
|
|
|
|
| 5 |
import io
|
| 6 |
import zipfile
|
| 7 |
from typing import List, Tuple
|
| 8 |
+
import spaces
|
| 9 |
|
| 10 |
+
@spaces.GPU
|
| 11 |
def remove_background_single(image_file) -> Image.Image:
|
| 12 |
"""Remove background from a single image file"""
|
| 13 |
if image_file is None:
|
|
|
|
| 27 |
output_image = Image.open(io.BytesIO(output_data))
|
| 28 |
return output_image
|
| 29 |
|
| 30 |
+
@spaces.GPU
|
| 31 |
def remove_background_multiple(image_files) -> Tuple[str, List[Image.Image]]:
|
| 32 |
"""Remove background from multiple image files and return as zip + preview images"""
|
| 33 |
if not image_files:
|
|
|
|
| 218 |
)
|
| 219 |
|
| 220 |
if __name__ == "__main__":
|
| 221 |
+
app.launch()
|
requirements.txt
CHANGED
|
@@ -3,3 +3,4 @@ rembg>=2.0.0
|
|
| 3 |
pillow>=9.0.0
|
| 4 |
numpy>=1.21.0
|
| 5 |
onnxruntime>=1.12.0
|
|
|
|
|
|
| 3 |
pillow>=9.0.0
|
| 4 |
numpy>=1.21.0
|
| 5 |
onnxruntime>=1.12.0
|
| 6 |
+
spaces>=0.19.4
|