Spaces:
Running
on
Zero
Running
on
Zero
Update app_2.py
Browse files
app_2.py
CHANGED
@@ -54,7 +54,13 @@ import torch
|
|
54 |
from PIL import Image
|
55 |
|
56 |
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|
59 |
# Load
|
60 |
|
@@ -351,7 +357,7 @@ def encode_prompt_pair(positive_prompt, negative_prompt):
|
|
351 |
def infer(
|
352 |
prompt,
|
353 |
image,
|
354 |
-
do_rembg=
|
355 |
seed=42,
|
356 |
randomize_seed=False,
|
357 |
guidance_scale=3.0,
|
@@ -360,8 +366,7 @@ def infer(
|
|
360 |
negative_prompt="watermark, ugly, deformed, noisy, blurry, low contrast",
|
361 |
progress=gr.Progress(track_tqdm=True),
|
362 |
):
|
363 |
-
|
364 |
-
# remove_bg_fn = lambda x: remove_bg(x, birefnet, transform_image, device)
|
365 |
# else:
|
366 |
# remove_bg_fn = None
|
367 |
if randomize_seed:
|
@@ -377,7 +382,7 @@ def infer(
|
|
377 |
num_inference_steps=num_inference_steps,
|
378 |
guidance_scale=guidance_scale,
|
379 |
seed=seed,
|
380 |
-
remove_bg_fn=
|
381 |
reference_conditioning_scale=reference_conditioning_scale,
|
382 |
negative_prompt=negative_prompt,
|
383 |
device=device,
|
|
|
54 |
from PIL import Image
|
55 |
|
56 |
|
57 |
+
transform_image = transforms.Compose(
|
58 |
+
[
|
59 |
+
transforms.Resize((1024, 1024)),
|
60 |
+
transforms.ToTensor(),
|
61 |
+
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
|
62 |
+
]
|
63 |
+
)
|
64 |
|
65 |
# Load
|
66 |
|
|
|
357 |
def infer(
|
358 |
prompt,
|
359 |
image,
|
360 |
+
do_rembg=True,
|
361 |
seed=42,
|
362 |
randomize_seed=False,
|
363 |
guidance_scale=3.0,
|
|
|
366 |
negative_prompt="watermark, ugly, deformed, noisy, blurry, low contrast",
|
367 |
progress=gr.Progress(track_tqdm=True),
|
368 |
):
|
369 |
+
remove_bg_fn = lambda x: remove_bg(x, rmbg, transform_image, device)
|
|
|
370 |
# else:
|
371 |
# remove_bg_fn = None
|
372 |
if randomize_seed:
|
|
|
382 |
num_inference_steps=num_inference_steps,
|
383 |
guidance_scale=guidance_scale,
|
384 |
seed=seed,
|
385 |
+
remove_bg_fn=remove_bg_fn,
|
386 |
reference_conditioning_scale=reference_conditioning_scale,
|
387 |
negative_prompt=negative_prompt,
|
388 |
device=device,
|