Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ml): inference_vid with canny #696

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions scripts/gen_vid_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ def generate(
bbox_select_list = []
img_tensor_list = []
out_img_list = []
sequence_count = 0
select_canny_list = [1] + [0] * (opt.data_temporal_number_frames - 1)
for img_path, bbox_path in zip(limited_paths_img, limited_paths_bbox):
img_in = os.path.join(os.path.dirname(os.path.dirname(paths_in_file)), img_path)
bbox_in = os.path.join(
Expand Down Expand Up @@ -599,7 +601,7 @@ def generate(
cond_image = fill_img_with_sketch(
img_tensor.unsqueeze(0), mask.unsqueeze(0)
)
elif opt.alg_diffusion_cond_image_creation == "canny":
elif opt.alg_diffusion_cond_image_creation == "computed_sketch": # "canny":
clamp = torch.clamp(mask, 0, 1)
if cond_in:
# mask the background to avoid canny edges around cond image
Expand All @@ -613,6 +615,7 @@ def generate(
high_threshold=alg_diffusion_sketch_canny_thresholds[1],
low_threshold_random=-1,
high_threshold_random=-1,
select_canny=[select_canny_list[sequence_count]],
)
if cond_in:
# restore background
Expand Down Expand Up @@ -683,8 +686,14 @@ def generate(
else:
ref_tensor = None

if opt.alg_diffusion_cond_image_creation in ["computed_sketch", "y_t"]:
if sequence_count == 0:
y_t_list.append(y_t)
else:
y_t_list.append(y_t_list[0])

sequence_count = sequence_count + 1
cond_image_list.append(cond_image)
y_t_list.append(y_t)
y0_tensor_list.append(y0_tensor)
mask_list.append(mask)
bbox_select_list.append(bbox_select)
Expand Down
Loading