Closed JaimyvS closed 8 months ago
Hello @JaimyvS, thank you very much for submitting the issue, and thank you for trying Pytorch-Wildlife out! This NotImplementError is kind of new to us. Would you mind sharing your pytorch version with us? Also, what operating system are you using? Is it a mac or linux? Me and @aa-hernandez will take a look at this and see if we could reproduce this error.
Also, since it shows "(e.g., you passed an empty list of Tensors)" on this line 150, in batch_image_detection, I am wondering, whether you would mind to print out total_preds
before line 148? Maybe total_preds
was an empty list, which means nothing was produced in line 140. In that case, and since you mentioned single image detection worked, would you mind debugging by creating a folder only consist a few worked single images, and run batch detection on this example folder and see if the results come through? If yes, then maybe the model didn't predict anything in your previous batch folder, if no, then there is a chance the dataloader
didn't work. Then would you mind print out len(dataloader)
before line 139
And yes, it actually doesn't matter with the input image sizes because all images will be down sampled to adapt to the model requirements. And I doubt it is about cpu or gpu.
Thanks for the response!
I'm using Windows Subsystem for Linux 2 on Windows 11 V23H2. Running Ubuntu 22.04.3 LTS with PyTorch version 1.10.1
I've checked total_preds and it does print out an empty list. I also created a folder of 3 images that work when using single image detect. But not with the batch detection. Length of dataloader is 0.
When I remove my own photos from the folder and add your demo photos of the Tamandua in the Amazon. It does work like it should.
Hello @JaimyvS, thank you very much for the information. So based on what you said, in the same folder, the Tamandua images work but your own images don't, right? It might be some file format issue. Would you mind print out self.images
before this line to make sure if the images are recognized by glob
. The default file extension is JPG
. I am afraid the images are not recognized automatically. If your images are not correctly picked up by glob
, then it must be the file extensions are different. We need to manually specify the extension for pw_data.DetectionImageFolder()
. We are sorry we didn't clarify this in our demo notebook. Also please keep in mind that the extension here is case sensitive because it is a string search function. So if your images are x.jpg
, then your extension argument should be extension="jpg"
. Maybe we should make this image extension more universal in future updates so we don't need to manually specify case sensitive extensions.
If your images are correctly picked up by glob
, then there must be some other issues. I wonder if you would mind sending us one or two images from your data for us to do some further testing? Thanks again!
Ahh! The issue was in the file extension. Adobe Lightroom exports into lowercase .jpg, so all my photos were formatted like this. After changing the file extensions to .JPG, the batch detection script works. Thanks for the explanation!
Do you also happen to know why the output images are tinted differently than the input images. This is the input: And this is the output:
Hello @JaimyvS, this is actually a bug and we have just fixed this in our latest commits https://github.com/microsoft/CameraTraps/commit/0c15bbff4321ac4afc99fa6b197c8cc9ea33abe2. Generally the image saving function we use came from supervision
which uses opencv
. opencv
uses BGR channel rather than RGB channel, while the default image generation functions we use are numpy
and PIL
, which are RGB images. This channel missmatch is the cause of this weird color output. We have updated the package version to 1.0.2.4. Please update the package using pip install PytorchWildlife --upgrade
for the fix, and let us know if the issue still persists!
Also, I want to mention that the argument where you can change the file extensions in pw_data.DetectionImageFolder()
instead of the Transform
function. I made a mistake. You can also check our updated demo, for example this line.
Yes, it works now! Thank you for the fast help with my issues!
@JaimyvS , we are always happy to help!
First of all, thanks for building the MegaDetector and keeping it free to use for everyone.
In the past, I've successfully used the previous version of the MegaDetector but decided to install the new PyTorch Wildlife package.
I've tested the demo python scripts which all seem to work, but when I try to run the pw_data.DetectionImageFolder function on a folder of custom photos I get the following error:
When I use the single image detect code as shown in the ReadTheDocs on a custom photo, it runs properly. Although in the output photo with bounding box, the colors seem to be altered a bit.
My photos are JPG's around 3 MB's in size each and a resolution of 6048 x 4024.
I've already tried to use the CPU instead of the GPU and lower the resolution of the images. But since a single image detect does work, this would probably not be the issue.
Any help would be much appreciated!