Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HerdNet results with a numpy array as input are not saveable through pw_utils.save_detection_images_dots #554

Open
1 of 2 tasks
calebrob6 opened this issue Jan 14, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@calebrob6
Copy link
Member

Search before asking

  • I have searched the Pytorch-Wildlife issues and found no similar bug report.

Bug

Running the following:

img_path = "inputs/0_resized.png"

img = Image.open(img_path)
img = np.array(img)

results = detection_model.single_image_detection(img)
pw_utils.save_detection_images_dots(results, "outputs/", overwrite=False)

results in the following traceback:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[33], [line 7](vscode-notebook-cell:?execution_count=33&line=7)
      [4](vscode-notebook-cell:?execution_count=33&line=4) img = np.array(img)
      [6](vscode-notebook-cell:?execution_count=33&line=6) results = detection_model.single_image_detection(img)
----> [7](vscode-notebook-cell:?execution_count=33&line=7) pw_utils.save_detection_images_dots(results, "outputs/", overwrite=False)

File /opt/conda/envs/pytorch_wildlife/lib/python3.8/site-packages/PytorchWildlife/utils/post_process.py:123, in save_detection_images_dots(results, output_dir, input_dir, overwrite)
    [117](https://vscode-remote+ssh-002dremote-002bv1001.vscode-resource.vscode-cdn.net/opt/conda/envs/pytorch_wildlife/lib/python3.8/site-packages/PytorchWildlife/utils/post_process.py:117)         sink.save_image(
    [118](https://vscode-remote+ssh-002dremote-002bv1001.vscode-resource.vscode-cdn.net/opt/conda/envs/pytorch_wildlife/lib/python3.8/site-packages/PytorchWildlife/utils/post_process.py:118)             image=cv2.cvtColor(annotated_img, cv2.COLOR_RGB2BGR), image_name=image_name
    [119](https://vscode-remote+ssh-002dremote-002bv1001.vscode-resource.vscode-cdn.net/opt/conda/envs/pytorch_wildlife/lib/python3.8/site-packages/PytorchWildlife/utils/post_process.py:119)         )
    [120](https://vscode-remote+ssh-002dremote-002bv1001.vscode-resource.vscode-cdn.net/opt/conda/envs/pytorch_wildlife/lib/python3.8/site-packages/PytorchWildlife/utils/post_process.py:120) else:
    [121](https://vscode-remote+ssh-002dremote-002bv1001.vscode-resource.vscode-cdn.net/opt/conda/envs/pytorch_wildlife/lib/python3.8/site-packages/PytorchWildlife/utils/post_process.py:121)     annotated_img = lab_annotator.annotate(
    [122](https://vscode-remote+ssh-002dremote-002bv1001.vscode-resource.vscode-cdn.net/opt/conda/envs/pytorch_wildlife/lib/python3.8/site-packages/PytorchWildlife/utils/post_process.py:122)         scene=dot_annotator.annotate(
--> [123](https://vscode-remote+ssh-002dremote-002bv1001.vscode-resource.vscode-cdn.net/opt/conda/envs/pytorch_wildlife/lib/python3.8/site-packages/PytorchWildlife/utils/post_process.py:123)             scene=np.array(Image.open(results["img_id"]).convert("RGB")),
    [124](https://vscode-remote+ssh-002dremote-002bv1001.vscode-resource.vscode-cdn.net/opt/conda/envs/pytorch_wildlife/lib/python3.8/site-packages/PytorchWildlife/utils/post_process.py:124)             detections=results["detections"],
    [125](https://vscode-remote+ssh-002dremote-002bv1001.vscode-resource.vscode-cdn.net/opt/conda/envs/pytorch_wildlife/lib/python3.8/site-packages/PytorchWildlife/utils/post_process.py:125)         ),
    [126](https://vscode-remote+ssh-002dremote-002bv1001.vscode-resource.vscode-cdn.net/opt/conda/envs/pytorch_wildlife/lib/python3.8/site-packages/PytorchWildlife/utils/post_process.py:126)         detections=results["detections"],
    [127](https://vscode-remote+ssh-002dremote-002bv1001.vscode-resource.vscode-cdn.net/opt/conda/envs/pytorch_wildlife/lib/python3.8/site-packages/PytorchWildlife/utils/post_process.py:127)         labels=results["labels"],
    [128](https://vscode-remote+ssh-002dremote-002bv1001.vscode-resource.vscode-cdn.net/opt/conda/envs/pytorch_wildlife/lib/python3.8/site-packages/PytorchWildlife/utils/post_process.py:128)     )
    [129](https://vscode-remote+ssh-002dremote-002bv1001.vscode-resource.vscode-cdn.net/opt/conda/envs/pytorch_wildlife/lib/python3.8/site-packages/PytorchWildlife/utils/post_process.py:129)     sink.save_image(
    [130](https://vscode-remote+ssh-002dremote-002bv1001.vscode-resource.vscode-cdn.net/opt/conda/envs/pytorch_wildlife/lib/python3.8/site-packages/PytorchWildlife/utils/post_process.py:130)         image=cv2.cvtColor(annotated_img, cv2.COLOR_RGB2BGR), image_name=os.path.basename(results["img_id"])
    [131](https://vscode-remote+ssh-002dremote-002bv1001.vscode-resource.vscode-cdn.net/opt/conda/envs/pytorch_wildlife/lib/python3.8/site-packages/PytorchWildlife/utils/post_process.py:131)     )

File /opt/conda/envs/pytorch_wildlife/lib/python3.8/site-packages/PIL/Image.py:3431, in open(fp, mode, formats)
   [3428](https://vscode-remote+ssh-002dremote-002bv1001.vscode-resource.vscode-cdn.net/opt/conda/envs/pytorch_wildlife/lib/python3.8/site-packages/PIL/Image.py:3428)     filename = os.path.realpath(os.fspath(fp))
   [3430](https://vscode-remote+ssh-002dremote-002bv1001.vscode-resource.vscode-cdn.net/opt/conda/envs/pytorch_wildlife/lib/python3.8/site-packages/PIL/Image.py:3430) if filename:
-> [3431](https://vscode-remote+ssh-002dremote-002bv1001.vscode-resource.vscode-cdn.net/opt/conda/envs/pytorch_wildlife/lib/python3.8/site-packages/PIL/Image.py:3431)     fp = builtins.open(filename, "rb")
   [3432](https://vscode-remote+ssh-002dremote-002bv1001.vscode-resource.vscode-cdn.net/opt/conda/envs/pytorch_wildlife/lib/python3.8/site-packages/PIL/Image.py:3432)     exclusive_fp = True
   [3433](https://vscode-remote+ssh-002dremote-002bv1001.vscode-resource.vscode-cdn.net/opt/conda/envs/pytorch_wildlife/lib/python3.8/site-packages/PIL/Image.py:3433) else:

FileNotFoundError: [Errno 2] No such file or directory: '/home/davrob/ssdprivate/alaska-fish-and-game.caribou-counting/pw_test/None'

Environment

No response

Minimal Reproducible Example

No response

Additional

No response

Are you willing to submit a PR?

  • Yes I'd like to help by submitting a PR!
@calebrob6 calebrob6 added the bug Something isn't working label Jan 14, 2025
idchacon28 added a commit that referenced this issue Jan 25, 2025
… with dimension less than 512 are scaled to use default herdnet values
zhmiao added a commit that referenced this issue Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant