OlafenwaMoses / ImageAI

A python library built to empower developers to build applications and systems with self-contained Computer Vision capabilities
https://www.genxr.co/#products
MIT License
8.48k stars 2.18k forks source link

RetinaNet model tries to write to system directory #833

Open rhysperry111 opened 4 months ago

rhysperry111 commented 4 months ago

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.