How to load by sorted filename?

I want to label my test data in sequence.
(my test data name … 1.jpg, 2.jpg , 3.jpg, … 12500.jpg)

ex) in result…
index label
1 1
2 0
3 0
… …
12500 1

where index is file name.

But the files were sorted 1.jpg, 10.jpg, 100.jpg, … 9999.jpg… … in linux server.

I use

How to sort by filename? or How to load files in regular sequence ?

Write your own simple dataset class and fetch idx.jpg when __getitem__(self, idx)

1 Like

OH, I got it . Thank you ,

Now ,I have an idea. :slight_smile: