Spaces:
Running
Running
NegiTurkey
commited on
Commit
•
30b2582
1
Parent(s):
69fdba2
Update app.py
Browse files
app.py
CHANGED
@@ -12,7 +12,7 @@ torch.set_float32_matmul_precision(["high", "highest"][0])
|
|
12 |
birefnet = AutoModelForImageSegmentation.from_pretrained(
|
13 |
"ZhengPeng7/BiRefNet", trust_remote_code=True
|
14 |
)
|
15 |
-
birefnet.to("
|
16 |
transform_image = transforms.Compose(
|
17 |
[
|
18 |
transforms.Resize((1024, 1024)),
|
@@ -27,7 +27,7 @@ def fn(image):
|
|
27 |
im = im.convert("RGB")
|
28 |
image_size = im.size
|
29 |
origin = im.copy()
|
30 |
-
input_images = transform_image(im).unsqueeze(0).to("
|
31 |
|
32 |
with torch.no_grad():
|
33 |
preds = birefnet(input_images)[-1].sigmoid().cpu()
|
@@ -47,7 +47,7 @@ def fn_url(url):
|
|
47 |
im = im.convert("RGB")
|
48 |
origin = im.copy()
|
49 |
image_size = im.size
|
50 |
-
input_images = transform_image(im).unsqueeze(0).to("
|
51 |
|
52 |
with torch.no_grad():
|
53 |
preds = birefnet(input_images)[-1].sigmoid().cpu()
|
@@ -68,7 +68,7 @@ def batch_fn(images):
|
|
68 |
im = load_img(image_path, output_type="pil")
|
69 |
im = im.convert("RGB")
|
70 |
image_size = im.size
|
71 |
-
input_images = transform_image(im).unsqueeze(0).to("
|
72 |
|
73 |
with torch.no_grad():
|
74 |
preds = birefnet(input_images)[-1].sigmoid().cpu()
|
|
|
12 |
birefnet = AutoModelForImageSegmentation.from_pretrained(
|
13 |
"ZhengPeng7/BiRefNet", trust_remote_code=True
|
14 |
)
|
15 |
+
birefnet.to("cpu")
|
16 |
transform_image = transforms.Compose(
|
17 |
[
|
18 |
transforms.Resize((1024, 1024)),
|
|
|
27 |
im = im.convert("RGB")
|
28 |
image_size = im.size
|
29 |
origin = im.copy()
|
30 |
+
input_images = transform_image(im).unsqueeze(0).to("cpu")
|
31 |
|
32 |
with torch.no_grad():
|
33 |
preds = birefnet(input_images)[-1].sigmoid().cpu()
|
|
|
47 |
im = im.convert("RGB")
|
48 |
origin = im.copy()
|
49 |
image_size = im.size
|
50 |
+
input_images = transform_image(im).unsqueeze(0).to("cpu")
|
51 |
|
52 |
with torch.no_grad():
|
53 |
preds = birefnet(input_images)[-1].sigmoid().cpu()
|
|
|
68 |
im = load_img(image_path, output_type="pil")
|
69 |
im = im.convert("RGB")
|
70 |
image_size = im.size
|
71 |
+
input_images = transform_image(im).unsqueeze(0).to("cpu")
|
72 |
|
73 |
with torch.no_grad():
|
74 |
preds = birefnet(input_images)[-1].sigmoid().cpu()
|