-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
is it possible to add .gif or .mp4 video insted of image/green/white background image? #207
Comments
You need to chage the bgr from constant to corresponding frame in gif or video. if (output_composition is not None) and (output_type == 'video'):
bgr_source = VideoReader(bgr_dir, transform)
bgr_reader = DataLoader(source, batch_size=bgr_source, pin_memory=True, num_workers=num_workers)
try:
with torch.no_grad():
bar = tqdm(total=len(source), disable=not progress, dynamic_ncols=True)
rec = [None] * 4
for src, bgr in zip(reader, bgr_reader):
if downsample_ratio is None:
downsample_ratio = auto_downsample_ratio(*src.shape[2:])
src = src.to(device, dtype, non_blocking=True).unsqueeze(0) # [B, T, C, H, W]
fgr, pha, *rec = model(src, *rec, downsample_ratio)
if output_foreground is not None:
writer_fgr.write(fgr[0])
if output_alpha is not None:
writer_pha.write(pha[0])
if output_composition is not None:
if output_type == 'video':
com = fgr * pha + bgr * (1 - pha)
else:
fgr = fgr * pha.gt(0)
com = torch.cat([fgr, pha], dim=-3)
writer_com.write(com[0])
bar.update(src.size(1)) |
@Asthestarsfalll im not able to get output according to this, I added this code into inference.py
I used this command
|
PeterL1n/BackgroundMattingV2#191 |
@akashAD98 |
@Asthestarsfalll I have assigned path of my video ,still not working |
@akashAD98 |
@Asthestarsfalll i did changes still getting same op with green bg |
@akashAD98 if (output_composition is not None) and (output_type == 'video'):
# bgr = torch.tensor([120, 255, 155], device=device, dtype=dtype).div(255).view(1, 1, 3, 1, 1)
bgr_source = VideoReader("./asianboss.mp4", transform)
bgr_reader = DataLoader(bgr_source, batch_size=seq_chunk, pin_memory=True, num_workers=num_workers)
try:
with torch.no_grad():
bar = tqdm(total=len(source), disable=not progress, dynamic_ncols=True)
rec = [None] * 4
for (src, bgr) in zip(reader, bgr_reader):
if downsample_ratio is None:
downsample_ratio = auto_downsample_ratio(*src.shape[2:])
src = src.to(device, dtype, non_blocking=True).unsqueeze(0) # [B, T, C, H, W]
fgr, pha, *rec = model(src, *rec, downsample_ratio)
if output_foreground is not None:
writer_fgr.write(fgr[0])
if output_alpha is not None:
writer_pha.write(pha[0])
if output_composition is not None:
if output_type == 'video':
com = fgr * pha + bgr * (1 - pha)
else:
fgr = fgr * pha.gt(0)
com = torch.cat([fgr, pha], dim=-3)
writer_com.write(com[0])
bar.update(src.size(1)) |
@Asthestarsfalll are you using this repo https://github.com/PeterL1n/RobustVideoMatting ??
|
very strenge @Asthestarsfalll |
i solve issue. the command i need to run is this
also make sure if you're running it on google collab. you will get 1 error
then just add cuda to bgr
@Asthestarsfalll thanks for your help mate |
it has one issue we need to resize both videos & also there duration |
bgr_source = VideoReader("xxx.mp4", transform) # there, the variable 'transform' is defined before
|
@Asthestarsfalll yes but im already using transform here RobustVideoMatting/inference_utils.py Line 55 in 81a1093
|
im getting this error
|
@akashAD98 if input_resize is not None:
transform = transforms.Compose([
transforms.Resize(input_resize[::-1]),
transforms.ToTensor()
])
else:
transform = transforms.ToTensor() |
@Asthestarsfalll solve problem thanks mate |
@akashAD98 Sir, can I see your code running successfully on colab? |
@darwinOne yes it’s working fine |
@akashAD98 can you share the code file, please? |
@darwinOne yes please drop your mail |
[email protected] |
I want to add .gif or .mp4 video in my background,instead of static image
@PeterL1n @
The text was updated successfully, but these errors were encountered: