Spaces:
Paused
Paused
Update freesplatter/webui/runner.py
Browse files
freesplatter/webui/runner.py
CHANGED
|
@@ -3,6 +3,7 @@ import os
|
|
| 3 |
import json
|
| 4 |
import uuid
|
| 5 |
import time
|
|
|
|
| 6 |
import numpy as np
|
| 7 |
import torch
|
| 8 |
import fpsample
|
|
@@ -75,11 +76,13 @@ class FreeSplatterRunner:
|
|
| 75 |
self.device = device
|
| 76 |
|
| 77 |
# background remover
|
| 78 |
-
self.rembg = AutoModelForImageSegmentation.from_pretrained(
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
| 83 |
|
| 84 |
# diffusion models
|
| 85 |
pipeline = DiffusionPipeline.from_pretrained(
|
|
@@ -158,7 +161,7 @@ class FreeSplatterRunner:
|
|
| 158 |
torch.cuda.empty_cache()
|
| 159 |
|
| 160 |
if do_rembg:
|
| 161 |
-
image = remove_background(
|
| 162 |
|
| 163 |
return image
|
| 164 |
|
|
|
|
| 3 |
import json
|
| 4 |
import uuid
|
| 5 |
import time
|
| 6 |
+
import rembg
|
| 7 |
import numpy as np
|
| 8 |
import torch
|
| 9 |
import fpsample
|
|
|
|
| 76 |
self.device = device
|
| 77 |
|
| 78 |
# background remover
|
| 79 |
+
# self.rembg = AutoModelForImageSegmentation.from_pretrained(
|
| 80 |
+
# "briaai/RMBG-2.0",
|
| 81 |
+
# trust_remote_code=True,
|
| 82 |
+
# cache_dir='ckpts/',
|
| 83 |
+
# )
|
| 84 |
+
# self.rembg.eval()
|
| 85 |
+
self.rembg = rembg.new_session('birefnet-general')
|
| 86 |
|
| 87 |
# diffusion models
|
| 88 |
pipeline = DiffusionPipeline.from_pretrained(
|
|
|
|
| 161 |
torch.cuda.empty_cache()
|
| 162 |
|
| 163 |
if do_rembg:
|
| 164 |
+
image = remove_background(self.rembg, image)
|
| 165 |
|
| 166 |
return image
|
| 167 |
|