Merge pull request #49 from daniel347x/background_image
Resolve crash in 'backward' when a background image with only 3 channels is passed to 'forward'
This commit is contained in:
@@ -384,9 +384,7 @@ class RenderFunction(torch.autograd.Function):
|
|||||||
if background_image is not None:
|
if background_image is not None:
|
||||||
background_image = background_image.to(pydiffvg.get_device())
|
background_image = background_image.to(pydiffvg.get_device())
|
||||||
if background_image.shape[2] == 3:
|
if background_image.shape[2] == 3:
|
||||||
background_image = torch.cat((\
|
raise NotImplementedError('Background image must have 4 channels, not 3. Add a fourth channel with all ones via torch.ones().')
|
||||||
background_image, torch.ones(background_image.shape[0], background_image.shape[1], 1,
|
|
||||||
device = background_image.device)), dim = 2)
|
|
||||||
background_image = background_image.contiguous()
|
background_image = background_image.contiguous()
|
||||||
assert(background_image.shape[0] == rendered_image.shape[0])
|
assert(background_image.shape[0] == rendered_image.shape[0])
|
||||||
assert(background_image.shape[1] == rendered_image.shape[1])
|
assert(background_image.shape[1] == rendered_image.shape[1])
|
||||||
|
Reference in New Issue
Block a user