GithubHelp home page GithubHelp logo

Comments (5)

willprice avatar willprice commented on May 15, 2024

In the README there is a code snippet that shows how to feed in data to the networks:

mtrn = torch.hub.load(repo, 'MTRN', (125, 352), 8, 'RGB',
                     base_model='resnet50', 
                      pretrained='epic-kitchens')
batch_size = 1
segment_count = 8
snippet_length = 1  # Number of frames composing the snippet, 1 for RGB, 5 for optical flow
snippet_channels = 3  # Number of channels in a frame, 3 for RGB, 2 for optical flow
height, width = 224, 224

inputs = torch.randn(
    [batch_size, segment_count, snippet_length, snippet_channels, height, width]
)
# The segment and snippet length and channel dimensions are collapsed into the channel
# dimension
# Input shape: N x TC x H x W
inputs = inputs.reshape((batch_size, -1, height, width))
# You can get features out of the models
features = mtrn.features(inputs)
# and then classify those features
verb_logits, noun_logits = mtrn.logits(features)

# or just call the object to classify inputs in a single forward pass
verb_logits, noun_logits = mtrn(inputs)
print(verb_logits.shape, noun_logits.shape)

Note that the data is fed in N x TC x H x W format. Your 180 x 224 x 224 is actually (60 x 3) x 224 x 224. You need to introduce a batch dimension (e.g. through unsqueeze(0)) for propagating a single example through the network.

from epic-kitchens-55-action-models.

arnavc1712 avatar arnavc1712 commented on May 15, 2024

Thank you. So I did that but I encountered an error "RuntimeError: shape '[-1, 8, 125]' is invalid for input of size 7500".
The error is encountered at this following line

 if self.reshape:
    413                 logits_verb = logits_verb.view(
--> 414                     (-1, self.num_segments) + logits_verb.size()[1:]
    415                 )

I suspect this could be since the input number of frames is not divisible by the num_segments? If so, do we have to add repeated frames/remove frames from input until we get something divisible by num_segments?

from epic-kitchens-55-action-models.

willprice avatar willprice commented on May 15, 2024

That's right, depending on the model you may not be able to feed more/fewer frames than it was trained with. TRN/MTRN has a fixed input size. TSM works best using the same number of frames as it was trained with, TSN can take in a variable number of frames, but you need to initialise the network with same number of segments you are going to feed into it.

from epic-kitchens-55-action-models.

arnavc1712 avatar arnavc1712 commented on May 15, 2024

This might be a stupid question, but in my case, I would have to further perform segment based sampling on the (60, 256, 456, 3) video to make it of size (8, 256, 456, 3), before passing it to the dataloader right? Because the dataloader does not seem to perform this sampling.

from epic-kitchens-55-action-models.

willprice avatar willprice commented on May 15, 2024

from epic-kitchens-55-action-models.

Related Issues (17)

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.