Skip to content

RetinaNet model tries to write to system directory #833

@rhysperry111

Description

@rhysperry111

When trying to use ObjectDetection on an image with RetinaNet I get the following error:

Traceback (most recent call last):
  File "/home/rhys/src/imagerec/detector.py", line 19, in <module>
    detection = detector.detectObjectsFromImage(input_image=image)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/imageai/Detection/__init__.py", line 387, in detectObjectsFromImage
    fnames, original_imgs, scaled_images = self.__load_image_retinanet(input_image)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/imageai/Detection/__init__.py", line 150, in __load_image_retinanet
    input_image = self.__save_temp_img(input_image=input_image)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/imageai/Detection/__init__.py", line 131, in __save_temp_img
    input_image.save(temp_path)
  File "/usr/lib/python3.11/site-packages/PIL/Image.py", line 2436, in save
    fp = builtins.open(filename, "w+b")
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: '/usr/lib/python3.11/site-packages/imageai/Detection/e28e5dc8-a4cd-4238-bd9b-95a60ab9c46f.jpg'

It seems to be trying to write to the system directory with which imageai is installed. I can fix the error by running as root, however this is obviously not the correct way to solve the problem, and it also ends up cluttering the system directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions