-
Notifications
You must be signed in to change notification settings - Fork 199
Can't backward through a transformation matrix #101
Copy link
Copy link
Open
Description
I'm guessing this project is pretty dead given the lack of updates, but filing this in case it bites someone else the way it bit me: if you're using a transformation matrix (the shape_to_canvas parameter to pydiffvg.ShapeGroup), gradients don't get transformed using the matrix. An obvious symptom of this is: if you flip the coordinate space upside down using a matrix, the updates to the shape will push it down when they should push it up and vice versa.
e.g. replacing
Lines 24 to 25 in 85802a7
| path_group = pydiffvg.ShapeGroup(shape_ids = torch.tensor([0]), | |
| fill_color = torch.tensor([0.3, 0.6, 0.3, 1.0])) |
with
transform = torch.tensor(
[
[1.0, 0.0, 0.0],
[0.0, -1.0, 256.0],
[0.0, 0.0, 1.0],
]
)
path_group = pydiffvg.ShapeGroup(
shape_ids=torch.tensor([0]),
fill_color=torch.tensor([0.3, 0.6, 0.3, 1.0]),
shape_to_canvas=transform,
)loss will increase, and the final result will look like this:

Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels