oliveox / digikam-object-detection-plugin

DigiKam media files search by contained objects
9 stars 1 forks source link

Error when analysing filepath #5

Open quartztester opened 2 years ago

quartztester commented 2 years ago

"Error while analysing filepath: [W:/Historical/Devices/new ipad/PhotoBackup/Link/ScreenRecording_09-28-2020 08-39-29.MP4]. Exception: [startswith first arg must be str or a tuple of str, not SUPPORTED_FILE_TYPES]"

Error is seems self-explanatory, I do not have an extensive knowledge base to know what exactly is causing and how to fix this issue.

Reference line 22 of object_detection.py

  if (kind.mime.startswith(SUPPORTED_FILE_TYPES.IMAGE)):
            # print(f'Analysing [image]')
            return cls.get_objects_in_image(model, file_path)
        elif (kind.mime.startswith(SUPPORTED_FILE_TYPES.VIDEO)):
            # print(f'Analysing [video]')
            cap=cv2.VideoCapture(file_path)
            total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))

Seems like this error from the looks of it https://pytutorial.com/solve-startswith-must-str-tuple

Platform: Windows 10 Digikam: 7.7.0 No dependency errors

Any assistance would be appreciated, thank you

quartztester commented 2 years ago

Going back on your previous commit I found that changing values back to the string "image/" was able to get images to be detected.

 if (kind.mime.startswith("image/")):
            # print(f'Analysing [image]')
            return cls.get_objects_in_image(model, file_path)

################################ Inserted [W:/Historical/Devices/new ipad/PhotoBackup/IMG_8697.JPG] in database!" Objects: [chair] ################################

This does not fully solve, only a makeshift patch that I found

liam-maps commented 1 year ago

Hello, I'm having the same error as @quartztester

Error while analysing filepath: [D:/images/100.jpg]. Exception: [startswith first arg must be str or a tuple of str, not SUPPORTED_FILE_TYPES]

If I replace the original code with

if (kind.mime.startswith("/image")):
elif (kind.mime.startswith("/video")):

as suggested by @quartztester , then the error is:

Unsupported type [image/jpeg]. File: [D:/images/100.jpg]
Traceback (most recent call last):
  File "d:\digikam-object-detection-plugin-master\src\adapters\db.py", line 42, in insert_image_objects
    result = cls.execute_query(cls.insert_image_objects_query, (row_id, file_hash, ' '.join(objects)))
TypeError: can only join an iterable
Error while analysing filepath: [D:/images/100.jpg]. Exception: [can only join an iterable]