I needed to label a lot of images into 4 classes.
Using the ratings of shotwell this can be really fast.
5 to set a rating on an image.
The next step was to get the ratings for later use as labels in machine learning.
Because shotwell stores its data in a sqlite database we only need some lines of Python to get the labels:
# location of shotwell sqlite file
db_file = os.path.join(os.environ.get("HOME"), '.local/share/shotwell', 'data', 'photo.db')
conn = sqlite3.connect(db_file)
c = conn.cursor()
rows = c.execute('SELECT filename, rating FROM phototable WHERE rating > 0 ORDER BY filename;')
csvwriter = csv.writer(sys.stdout, delimiter=';')
for (filename, rating) in rows:
Only the ratings bigger than 0 are selected.
The CSV is written to stdout by default.