twosixlabs / armory

ARMORY Adversarial Robustness Evaluation Test Bed
MIT License
176 stars 67 forks source link

Move tidecv dependency to be lazily imported in metrics or add to pyproject.toml #1895

Closed jprokos26 closed 1 year ago

jprokos26 commented 1 year ago

If trying to use Armory's metrics code, you currently need to have tidecv installed even though it is not listed as a dependency in pyproject.toml. It would be nice to be able to import metrics as such when armory is installed:

from armory.metrics.task import object_detection_AP_per_class

Currently throws:

$ python3 -c "from armory.metrics.task import object_detection_AP_per_class"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/jonathan.prokos/git/twosixlabs/armory/armory/metrics/__init__.py", line 4, in <module>
    from armory.metrics import compute, perturbation, statistical, task
  File "/home/jonathan.prokos/git/twosixlabs/armory/armory/metrics/task.py", line 10, in <module>
    from tidecv import TIDE
ModuleNotFoundError: No module named 'tidecv'
mwartell commented 1 year ago

The package tidecv is present in the engine dependencies group. I suspect you did pip install . aka pip install armory-testbed which just installs the absolute minimum possible to run the armory launcher. If you instead pip install .[engine], then tidecv will be installed.

The expected use is pip install .[pytorch] which includes engine as a dependency component of pytorch. I had not considered wanting metrics without engine. If this assumption is wrong, we should correct that.