Repository: openvinotoolkit/datumaro

Issue:
Test errors after tensorflow installation on Ubuntu 20.04
Ubuntu20.04, Python 3.8.5 
Installation of tensorflow (to enable skipped tests) results with tests errors.

**Steps to reproduce:**
```
git clone https://github.com/openvinotoolkit/datumaro 
cd datumaro
python3 -m pip install virtualenv
python3 -m virtualenv venv
. venv/bin/activate
pip install datumaro
python3 -m unittest -v
//there are some skipped tests - required tensorflow and pandas)
pip install tensorflow
//during installation numpy 1.20.3 was uninstalled and 1.19.5 was installed
python3 -m unittest -v
```
**Expected result:**
No test errors after installation libraries required to perform initially skipped tests.

**Current result:**
```
Ran 390 tests in 11.807s

FAILED (errors=29, skipped=7)
```
```======================================================================
ERROR: test_validate_annotations_segmentation (tests.test_validator.TestValidateAnnotations)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/sstrehlk/src/datum_p/tests/test_validator.py", line 803, in test_validate_annotations_segmentation
    actual_results = validate_annotations(self.dataset, 'segmentation',
  File "/home/sstrehlk/src/datum_p/datumaro/components/validator.py", line 1255, in validate_annotations
    stats = validator.compute_statistics(dataset)
  File "/home/sstrehlk/src/datum_p/datumaro/components/validator.py", line 1064, in compute_statistics
    _update_mask_stats_by_label(
  File "/home/sstrehlk/src/datum_p/datumaro/components/validator.py", line 1026, in _update_mask_stats_by_label
    area = ann.get_area()
  File "/home/sstrehlk/src/datum_p/datumaro/components/extractor.py", line 374, in get_area
    import pycocotools.mask as mask_utils
  File "/home/sstrehlk/src/datum_p/venv/lib/python3.8/site-packages/pycocotools/mask.py", line 3, in <module>
    import pycocotools._mask as _mask
  File "pycocotools/_mask.pyx", line 1, in init pycocotools._mask
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject

----------------------------------------------------------------------
```
It seems that there is incompatibility between numpy 1.19.5 and pycocotools 2.0.2. There is workaround for it: 
```
pip install pycocotools==2.0.0
``` 


Discussion:
We already fought with this problem here: https://github.com/openvinotoolkit/cvat/pull/2756. As far as I remember, there was a problem in newer binary distributions of `pycocotools` and `tensorflow` - they were linked against the mismatching versions of `numpy`, and that caused the problem. Can you check if that is the case? What if we disable binaries for `pycocotools` on the problematic platform?
This is the same case, tensorflow installation results with downgrading of numpy, and then numpy is incompatible with the the newest pycocotools. Tensorflow is not mentioned in requirements.txt and some tests because of that are skipped, so initially there are no errors but only some skips. The problem is visible after installation of tensorflow and automatic downgrade of numpy. Installation of tensorflow enables some skipped tests, but results with errors (on Ubuntu 20.04) because of incompatibility between numpy and pycocotools. Manual downgrading of pycocotools to version 2.0.0 can help on this problem, and all tests then could pass, but I don't know what can be another consequence of pycocotools downgrading.  

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -42,8 +42,17 @@ def get_requirements():
         'matplotlib',
         'numpy>=1.17.3',
         'Pillow',
-        'pycocotools; platform_system != "Windows"',
+
+        # Avoid 2.0.2 Linux binary distribution because of
+        # a conflict in numpy versions with TensorFlow:
+        # - TF is compiled with numpy 1.19 ABI
+        # - pycocotools is compiled with numpy 1.20 ABI
+        # Using a previous version allows to force package rebuilding.
+        #
+        # https://github.com/openvinotoolkit/datumaro/issues/253
+        'pycocotools!=2.0.2; platform_system != "Windows"',
         'pycocotools-windows; platform_system == "Windows"',
+
         'PyYAML',
         'scikit-image',
         'tensorboardX',


Test patch: