Giter Site home page Giter Site logo

Comments (7)

ncullen93 avatar ncullen93 commented on July 1, 2024

hey it's because the current version only supports a single channel. Let me add support for that right now and get back to you

EDIT: ok, it should be fixed. Try that code again. The thing is that multi-channel support makes it a littttle slower. I don't plan to add multi-channel support for 3D affines right now.

from torchsample.

fizzxed avatar fizzxed commented on July 1, 2024

Now there is another issue.
In th_affine2d we assume matrix has dimensions (2, 3) seen:

if matrix.dim() == 2:
    matrix = matrix.view(-1,2,3)

But in the affine_transforms.py the matrix has size (3, 3)

from torchsample.

ncullen93 avatar ncullen93 commented on July 1, 2024

should be fixed... lol i desperately need to write some tests, sorry.

I fix it by just indexing to the second row so if there is a third row it'll get cut off. This is what Keras does.

from torchsample.

bfortuner avatar bfortuner commented on July 1, 2024

Haven't looked closely, but having trouble with both Pad() and Rotate() passing in a tensor (3,256,256) which works for the other Tensor transform types..

Here's the error I see when I call AffineTransforms like Rotate(), Shear(), Zoom(), etc

rotated_img = torchsample.transforms.Rotate(10)(img_tns)

Error:
`/torchsample/utils.py in th_affine2d(x, matrix, mode, center)
---> 86 if matrix.dim() == 2:
87 matrix = matrix[:2,:]
88 matrix = matrix.view(-1,2,3)

RuntimeError: size '[-1 x 2 x 3]' is invalid for input of with 9 elements at /py/conda-bld/pytorch_1490980628440/work/torch/lib/TH/THStorage.c:55`

from torchsample.

ncullen93 avatar ncullen93 commented on July 1, 2024

Sorry I'm not sure what the issue is without seeing more code. These all work for me:

from torchsample.transforms import *
import torch as th
x = th.ones(3,256,256)
xr = Rotate(10)(x)
xs = Shear(0.1)(x)
xz = Zoom((0.8,1.2))(x)
xp = Pad((3,300,300))(x)
print(xp.size()) # torch.Size([3, 300, 300])

Maybe has to do with the new pytorch version? Are you using 0.1.11 or 0.1.12? Let me upgrade. EDIT: Still works on 0.1.12.

from torchsample.

bfortuner avatar bfortuner commented on July 1, 2024

This works! I was "slicing" my tensor with narrow() to remove an extra dimension, but I wasn't doing it right. Thanks

from torchsample.

ncullen93 avatar ncullen93 commented on July 1, 2024

Great!

from torchsample.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.