lhackel-tub / ConfigILM

A Library for configurable combination of pre-configured and possibly pre-trained Image and Language Models
https://lhackel-tub.github.io/ConfigILM/
MIT License
32 stars 4 forks source link

FR: Change tuple to NamedTuple in `ClassificationVQADataset.py` #101

Open kai-tub opened 1 month ago

kai-tub commented 1 month ago

I would favour the use of a NamedTuple for the qa_data rather than an index-based tuple ClassificationVQADataset.py.

https://github.com/lhackel-tub/ConfigILM/blob/4d1890740c37aac6d918319f6df3e5159f9e18c2/configilm/extra/DataSets/ClassificationVQADataset.py#L163-L177

Although the doc-string does say how the ordering should be implemented, the information is quickly lost when implementing a subclass or while debugging the application. The following code contains "magic numbers" for example:

https://github.com/lhackel-tub/ConfigILM/blob/4d1890740c37aac6d918319f6df3e5159f9e18c2/configilm/extra/DataSets/ClassificationVQADataset.py#L208-L243

I would just a NamedTuple with the keys: image_key, question, answer, and extra. Where extra may either be an iterable or an object. Though an iterable would require less changes:

https://github.com/lhackel-tub/ConfigILM/blob/4d1890740c37aac6d918319f6df3e5159f9e18c2/configilm/extra/DataSets/ClassificationVQADataset.py#L240-L243