Giter Site home page Giter Site logo

Comments (11)

gaochen315 avatar gaochen315 commented on August 24, 2024 2

A naive solution is to zero pad the filename. For example, 0.png --> 000.png. You can do str(idx).zfill(3) + '.png'.

from fgvc.

jelenaaaaa avatar jelenaaaaa commented on August 24, 2024 1

@GrahamboJangles wherever you have sorted function in the code just replace it with natsorted. It does make an ordered list and the rest of the code will just use a list that is sorted in that way, you don't have to do anything else with it.
For example, here (lines 395,396):

for filename in sorted(filename_list):
video.append(torch.from_numpy(np.array(Image.open(filename)).astype(np.uint8)).permute(2, 0, 1).float())

This loads your files from a list and appends them to a video. If the sorted function doesn't sort images as it should, it will append it to a video in a irregular way so your video final video will skip (because the rest of the code will use images that were not sorted correctly). Try to print filename_list when you use sorted and also when you use natsorted, if you have the same issue that I had the problem will be obvious. Also, if the masks are loaded irregularly you will have a similar problem.

from fgvc.

gaochen315 avatar gaochen315 commented on August 24, 2024

Can you first check if the output images are in the right order?

from fgvc.

jelenaaaaa avatar jelenaaaaa commented on August 24, 2024

Can you check in what order sorted function is returning your images?

from fgvc.

GrahamboJangles avatar GrahamboJangles commented on August 24, 2024

Can you check in what order sorted function is returning your images?

Yup you guys might be right, I will invest investigate that and report back.

from fgvc.

GrahamboJangles avatar GrahamboJangles commented on August 24, 2024

@gaochen315 @jelenaaaaa - So the frames are in the right order when I open each jpeg in numerical order. But in Colab, it looks like this:

image

I don't know if this is the problem though, because no matter how the files are arranged on screen they are still in order.

from fgvc.

jelenaaaaa avatar jelenaaaaa commented on August 24, 2024

@gaochen315 @jelenaaaaa - So the frames are in the right order when I open each jpeg in numerical order. But in Colab, it looks like this:

image

I don't know if this is the problem though, because no matter how the files are arranged on screen they are still in order.

Try to use natsorted instead of sorted function (you can install natsort from pip and then from natsort import natsorted)

from fgvc.

GrahamboJangles avatar GrahamboJangles commented on August 24, 2024

@jelenaaaaa

I sorted used natsort, sorry for the noob question but then am I supposed to shutil.move() according to the sorted list of items?

I zipped up the files in Colab and downloaded them onto my Windows PC, and they were ordered correctly. Then I put them into Colab again, unzipped it, and they are in the wrong order again. I think it's just the way that Colab shows the order of files, but as long as the files are numerically in order it shouldn't be a problem.

Is this a Colab problem?

from fgvc.

jelenaaaaa avatar jelenaaaaa commented on August 24, 2024

@jelenaaaaa

I sorted used natsort, sorry for the noob question but then am I supposed to shutil.move() according to the sorted list of items?

I zipped up the files in Colab and downloaded them onto my Windows PC, and they were ordered correctly. Then I put them into Colab again, unzipped it, and they are in the wrong order again. I think it's just the way that Colab shows the order of files, but as long as the files are numerically in order it shouldn't be a problem.

Is this a Colab problem?

I had a similar problem myself and I just used natsorted instead of sorted (I changed it everywhere) and It worked just fine. I did not use shutil.move(). The problem was with reading images and masks, if images are not appended in video in the right order (and also the corresponding masks) the final video will look like it's skipping frames. I did not use Colab so I really don't know if the problem is with that or something else.

from fgvc.

GrahamboJangles avatar GrahamboJangles commented on August 24, 2024

@jelenaaaaa Where did you natsort, exactly? It just seems to make an ordered list, I'm not sure what to do with the list.

from fgvc.

GrahamboJangles avatar GrahamboJangles commented on August 24, 2024

@jelenaaaaa I replaced the instances in the code of sorted(filename_list) with natsorted(filename_list) and it seemed to help a little bit but I still had some skipping for some reason. Maybe I missed a line. But then I implemented what @gaochen315 said with my frame extracting code and the padding of the filenames fixed the issue. Thank you guys for your help!

from fgvc.

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.