jveitchmichaelis / deeplabel

A cross-platform desktop image annotation tool for machine learning
205 stars 39 forks source link

Export on ubuntu does not export - unable to open image #35

Open vladaman opened 2 years ago

vladaman commented 2 years ago

Deeplabel reports errors when exporting files on ubuntu 20.04

My source folder with images: /home/vlad/Pictures/Cleaned/zluty/ DB file at: /home/vlad/Pictures/Cleaned/zluty/deeplabel-db.lbldb

Failed top open image "/home/vlad/Pictures/Cleaned/zluty/deeplabel-db.lbldb/../IMG_20220223_114543.jpg"
Failed top open image "/home/vlad/Pictures/Cleaned/zluty/deeplabel-db.lbldb/../IMG_20220223_114949.jpg"
Failed top open image "/home/vlad/Pictures/Cleaned/zluty/deeplabel-db.lbldb/../IMG_20220223_112833.jpg"
Failed top open image "/home/vlad/Pictures/Cleaned/zluty/deeplabel-db.lbldb/../IMG_20220223_113744.jpg"
Failed top open image "/home/vlad/Pictures/Cleaned/zluty/deeplabel-db.lbldb/../IMG_20220223_112706.jpg"
Failed top open image "/home/vlad/Pictures/Cleaned/zluty/deeplabel-db.lbldb/../IMG_20220223_112823.jpg"
jveitchmichaelis commented 2 years ago

What format are you exporting?

vladaman commented 2 years ago

I was trying COCO (JSON) however:

So in fact, I am unable to export any format. Only COCO reports problems in console. In fact others report Export output folder doesn't exist yet the folder exists. I also try to remove special characters or spaces from path but it didn't help.

Thank you!

jveitchmichaelis commented 2 years ago

You make your own names file. It's a list of classes that you want to export - just newline delimited. It comes from YOLO, but it's a useful way of (a) forcing a specific class order, if that matters and (b) allowing you to filter which classes you export.

But I'll take a look at the export - seems like something is up! Usually if the OK button is disabled, something is missing, but perhaps it's a bug. If you have the code compiled, you could add some debug statements to see what the program is trying to create.

vladaman commented 2 years ago

I tried to create names file corresponding with my 2 class names. Then I tried to export using Darknet format and I get following errors:

15  images selected for train set.
58  images selected for validation set.
QString::arg: Argument missing: "IMG_20220223_115017.txt" , 1
QString::arg: Argument missing: "IMG_20220223_113727.txt" , 1
QString::arg: Argument missing: "IMG_20220223_112807.txt" , 1
QString::arg: Argument missing: "IMG_20220223_112906.txt" , 1
QString::arg: Argument missing: "IMG_20220223_114412.txt" , 1
QString::arg: Argument missing: "IMG_20220223_114415.txt" , 1

BTW where is the debug flag, I can change that and recompile

jveitchmichaelis commented 2 years ago

Oh fun! Well the names file should be like this (e..g for COCO classes): https://github.com/pjreddie/darknet/blob/master/data/coco.names

I would suggest doing it in Qt Creator - then you can breakpoint easily (and add a debug build). Or you can use qDebug(), that should work in release mode.

vladaman commented 2 years ago

OK, what I found it's very likely related to QDir()

return QDir(db.databaseName());

It returns full path which includes also the database file.

I tried following:

  1. updated DB with update images set path = replace(path, "../", "" )
  2. changed method call to:
    QDir getDbFolder(){
            auto db = getDatabase();
            auto rs = QFileInfo(db.databaseName());
            return rs.absoluteDir();
            // return QDir(db.databaseName());
    }

After this the export worked and images were placed into export folder. Unfortunately this is not a fix since it breaks the UI. hopefully this will help you to identify the core issue. Original code leads to a path which looks like (please note, the db name is included in path) /home/vlad/Pictures/Cleaned/zluty/deeplabel-db.lbldb/../IMG_20220223_114543.jpg

I also found this article with similar issue https://stackoverflow.com/questions/13783876/qdir-absolutepath-still-returning-the-filename