Object detection installation - dependency problems

Question:
I am trying to install the Tensorflow Object Detection API, however when i run the installation it seems to get stuck in a dependency/compability loop (running Ubuntu 20.04). This is the last part of the installation:
`
Downloading psutil-5.6.3.tar.gz (435 kB)
|████████████████████████████████| 435 kB 11.4 MB/s
Downloading psutil-5.6.2.tar.gz (432 kB)
|████████████████████████████████| 432 kB 11.4 MB/s
Downloading psutil-5.6.1.tar.gz (427 kB)
|████████████████████████████████| 427 kB 11.3 MB/s
Downloading psutil-5.6.0.tar.gz (426 kB)
|████████████████████████████████| 426 kB 11.6 MB/s
INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. If you want to abort this run, you can press Ctrl + C to do so. To improve how pip performs, tell us what happened here: https://pip.pypa.io/surveys/backtracking
Downloading psutil-5.5.1.tar.gz (426 kB)
|████████████████████████████████| 426 kB 11.5 MB/s
Downloading psutil-5.5.0.tar.gz (425 kB)
|████████████████████████████████| 425 kB 11.4 MB/s
Downloading psutil-5.4.8.tar.gz (422 kB)
|████████████████████████████████| 422 kB 11.3 MB/s
Downloading psutil-5.4.7.tar.gz (420 kB)
|████████████████████████████████| 420 kB 11.0 MB/s
Downloading psutil-5.4.6.tar.gz (418 kB)
|████████████████████████████████| 418 kB 9.9 MB/s
Downloading psutil-5.4.5.tar.gz (418 kB)
|████████████████████████████████| 418 kB 13.5 MB/s
Downloading psutil-5.4.4.tar.gz (417 kB)
|████████████████████████████████| 417 kB 11.4 MB/s
Downloading psutil-5.4.3.tar.gz (412 kB)
|████████████████████████████████| 412 kB 11.3 MB/s
INFO: pip is looking at multiple versions of proto-plus to determine which version is compatible with other requirements. This could take a while.
Collecting proto-plus>=1.10.0
Downloading proto_plus-1.18.1-py3-none-any.whl (42 kB)
|████████████████████████████████| 42 kB 1.3 MB/s
Downloading proto_plus-1.18.0-py3-none-any.whl (42 kB)
|████████████████████████████████| 42 kB 836 kB/s
Downloading proto_plus-1.17.0-py3-none-any.whl (42 kB)
|████████████████████████████████| 42 kB 1.7 MB/s
Downloading proto_plus-1.16.0-py3-none-any.whl (42 kB)
|████████████████████████████████| 42 kB 1.7 MB/s
Downloading proto_plus-1.15.0-py3-none-any.whl (42 kB)
|████████████████████████████████| 42 kB 1.7 MB/s
Downloading proto_plus-1.14.2-py3-none-any.whl (42 kB)
|████████████████████████████████| 42 kB 615 kB/s
Downloading proto-plus-1.13.0.tar.gz (44 kB)
|████████████████████████████████| 44 kB 3.0 MB/s
INFO: pip is looking at multiple versions of proto-plus to determine which version is compatible with other requirements. This could take a while.
Downloading proto-plus-1.11.0.tar.gz (44 kB)
|████████████████████████████████| 44 kB 2.8 MB/s
Downloading proto-plus-1.10.2.tar.gz (42 kB)
|████████████████████████████████| 42 kB 1.2 MB/s
Downloading proto-plus-1.10.1.tar.gz (42 kB)
|████████████████████████████████| 42 kB 2.2 MB/s
Downloading proto-plus-1.10.0.tar.gz (24 kB)
INFO: pip is looking at multiple versions of packaging to determine which version is compatible with other requirements. This could take a while.
Collecting packaging>=14.3
Downloading packaging-20.9-py2.py3-none-any.whl (40 kB)
|████████████████████████████████| 40 kB 5.6 MB/s
INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. If you want to abort this
`
Anyway to solve this issue?

Context:
I had this issue when trying to install it after making the following updates to my environment:
tensorflow 2.4.1–> 2.5
python 3.7.10–> 3.8.10
Cuda toolkit 10.1–> 11.2
This was the error message:
WARNING: --use-feature=2020-resolver no longer has any effect, since it is now the default dependency resolver in pip. This will become an error in pip 21.0.
Processing /home/labuser/tlt2/Tensorflow/models/research
  DEPRECATION: A future pip version will change local packages to be built in-place without first copying to a temporary directory. We recommend you use --use-feature=in-tree-build to test your packages with this new behavior before it becomes the default.
   pip 21.3 will remove support for this functionality. You can find discussion regarding this at https://github.com/pypa/pip/issues/7555.
Collecting avro-python3
  Using cached avro-python3-1.10.2.tar.gz (38 kB)
Collecting apache-beam
  Using cached apache_beam-2.31.0-cp38-cp38-manylinux2010_x86_64.whl (11.5 MB)
Requirement already satisfied: pillow in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from object-detection==0.1) (8.3.1)
Collecting lxml
  Using cached lxml-4.6.3-cp38-cp38-manylinux2014_x86_64.whl (6.8 MB)
Requirement already satisfied: matplotlib in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from object-detection==0.1) (3.4.2)
Collecting Cython
  Using cached Cython-0.29.24-cp38-cp38-manylinux1_x86_64.whl (1.9 MB)
Collecting contextlib2
  Using cached contextlib2-21.6.0-py2.py3-none-any.whl (13 kB)
Collecting tf-slim
  Using cached tf_slim-1.1.0-py2.py3-none-any.whl (352 kB)
Requirement already satisfied: six in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from object-detection==0.1) (1.16.0)
Collecting pycocotools
  Using cached pycocotools-2.0.2-cp38-cp38-linux_x86_64.whl
Collecting lvis
  Using cached lvis-0.5.3-py3-none-any.whl (14 kB)
Collecting scipy
  Using cached scipy-1.7.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (28.4 MB)
Collecting pandas
  Using cached pandas-1.3.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (10.6 MB)
Collecting tf-models-official
  Using cached tf_models_official-2.5.0-py2.py3-none-any.whl (1.6 MB)
Requirement already satisfied: typing-extensions<3.8.0,>=3.7.0 in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from apache-beam->object-detection==0.1) (3.7.4.3)
Collecting oauth2client<5,>=2.0.1
  Using cached oauth2client-4.1.3-py2.py3-none-any.whl (98 kB)
Collecting dill<0.3.2,>=0.3.1.1
  Using cached dill-0.3.1.1-py3-none-any.whl
Collecting avro-python3
  Using cached avro_python3-1.9.2.1-py3-none-any.whl
Collecting pytz>=2018.3
  Using cached pytz-2021.1-py2.py3-none-any.whl (510 kB)
Collecting future<1.0.0,>=0.18.2
  Using cached future-0.18.2.tar.gz (829 kB)
Requirement already satisfied: protobuf<4,>=3.12.2 in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from apache-beam->object-detection==0.1) (3.17.3)
Collecting pyarrow<5.0.0,>=0.15.1
  Using cached pyarrow-4.0.1-cp38-cp38-manylinux2014_x86_64.whl (21.9 MB)
Collecting hdfs<3.0.0,>=2.1.0
  Using cached hdfs-2.6.0-py3-none-any.whl (33 kB)
Collecting pydot<2,>=1.2.0
  Using cached pydot-1.4.2-py2.py3-none-any.whl (21 kB)
Requirement already satisfied: requests<3.0.0,>=2.24.0 in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from apache-beam->object-detection==0.1) (2.26.0)
Collecting fastavro<2,>=0.21.4
  Using cached fastavro-1.4.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.7 MB)
Collecting crcmod<2.0,>=1.7
  Using cached crcmod-1.7-cp38-cp38-linux_x86_64.whl
Requirement already satisfied: grpcio<2,>=1.29.0 in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from apache-beam->object-detection==0.1) (1.34.1)
Collecting httplib2<0.20.0,>=0.8
  Using cached httplib2-0.19.1-py3-none-any.whl (95 kB)
Collecting pymongo<4.0.0,>=3.8.0
  Using cached pymongo-3.12.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (545 kB)
Requirement already satisfied: python-dateutil<3,>=2.8.0 in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from apache-beam->object-detection==0.1) (2.8.2)
Collecting numpy<1.21.0,>=1.14.3
  Using cached numpy-1.20.3-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.4 MB)
Collecting docopt
  Using cached docopt-0.6.2-py2.py3-none-any.whl
Requirement already satisfied: pyparsing<3,>=2.4.2 in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from httplib2<0.20.0,>=0.8->apache-beam->object-detection==0.1) (2.4.7)
Requirement already satisfied: pyasn1>=0.1.7 in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from oauth2client<5,>=2.0.1->apache-beam->object-detection==0.1) (0.4.8)
Requirement already satisfied: pyasn1-modules>=0.0.5 in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from oauth2client<5,>=2.0.1->apache-beam->object-detection==0.1) (0.2.8)
Requirement already satisfied: rsa>=3.1.4 in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from oauth2client<5,>=2.0.1->apache-beam->object-detection==0.1) (4.7.2)
Requirement already satisfied: idna<4,>=2.5 in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from requests<3.0.0,>=2.24.0->apache-beam->object-detection==0.1) (3.2)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from requests<3.0.0,>=2.24.0->apache-beam->object-detection==0.1) (1.26.6)
Requirement already satisfied: certifi>=2017.4.17 in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from requests<3.0.0,>=2.24.0->apache-beam->object-detection==0.1) (2021.5.30)
Requirement already satisfied: charset-normalizer~=2.0.0 in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from requests<3.0.0,>=2.24.0->apache-beam->object-detection==0.1) (2.0.3)
Collecting opencv-python>=4.1.0.25
  Using cached opencv_python-4.5.3.56-cp38-cp38-manylinux2014_x86_64.whl (49.9 MB)
Requirement already satisfied: kiwisolver>=1.1.0 in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from lvis->object-detection==0.1) (1.3.1)
Requirement already satisfied: cycler>=0.10.0 in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from lvis->object-detection==0.1) (0.10.0)
Requirement already satisfied: setuptools>=18.0 in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from pycocotools->object-detection==0.1) (52.0.0.post20210125)
Collecting tensorflow-model-optimization>=0.4.1
  Using cached tensorflow_model_optimization-0.6.0-py2.py3-none-any.whl (211 kB)
Collecting tensorflow-hub>=0.6.0
  Using cached tensorflow_hub-0.12.0-py2.py3-none-any.whl (108 kB)
Collecting sacrebleu
  Using cached sacrebleu-1.5.1-py3-none-any.whl (54 kB)
Collecting pyyaml>=5.1
  Using cached PyYAML-5.4.1-cp38-cp38-manylinux1_x86_64.whl (662 kB)
Collecting gin-config
  Using cached gin_config-0.4.0-py2.py3-none-any.whl (46 kB)
Collecting kaggle>=1.3.9
  Using cached kaggle-1.5.12-py3-none-any.whl
Collecting psutil>=5.4.3
  Using cached psutil-5.8.0-cp38-cp38-manylinux2010_x86_64.whl (296 kB)
Collecting py-cpuinfo>=3.3.0
  Using cached py_cpuinfo-8.0.0-py3-none-any.whl
Collecting seqeval
  Using cached seqeval-1.2.2-py3-none-any.whl
Collecting opencv-python-headless
  Using cached opencv_python_headless-4.5.3.56-cp38-cp38-manylinux2014_x86_64.whl (37.1 MB)
Collecting tensorflow-addons
  Using cached tensorflow_addons-0.13.0-cp38-cp38-manylinux2010_x86_64.whl (679 kB)
Collecting tensorflow-datasets
  Using cached tensorflow_datasets-4.3.0-py3-none-any.whl (3.9 MB)
Collecting google-cloud-bigquery>=0.31.0
  Using cached google_cloud_bigquery-2.22.1-py2.py3-none-any.whl (195 kB)
Requirement already satisfied: tensorflow>=2.5.0 in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from tf-models-official->object-detection==0.1) (2.5.0)
Collecting sentencepiece
  Using cached sentencepiece-0.1.96-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB)
Collecting google-api-python-client>=1.6.7
  Using cached google_api_python_client-2.14.0-py2.py3-none-any.whl (7.1 MB)
Requirement already satisfied: google-auth<3.0.0dev,>=1.16.0 in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from google-api-python-client>=1.6.7->tf-models-official->object-detection==0.1) (1.33.1)
Collecting uritemplate<4dev,>=3.0.0
  Using cached uritemplate-3.0.1-py2.py3-none-any.whl (15 kB)
Collecting google-api-core<3.0.0dev,>=1.21.0
  Using cached google_api_core-1.31.0-py2.py3-none-any.whl (93 kB)
Collecting google-auth-httplib2>=0.1.0
  Using cached google_auth_httplib2-0.1.0-py2.py3-none-any.whl (9.3 kB)
Collecting googleapis-common-protos<2.0dev,>=1.6.0
  Using cached googleapis_common_protos-1.53.0-py2.py3-none-any.whl (198 kB)
Collecting packaging>=14.3
  Using cached packaging-21.0-py3-none-any.whl (40 kB)
Requirement already satisfied: cachetools<5.0,>=2.0.0 in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from google-auth<3.0.0dev,>=1.16.0->google-api-python-client>=1.6.7->tf-models-official->object-detection==0.1) (4.2.2)
Collecting google-resumable-media<3.0dev,>=0.6.0
  Using cached google_resumable_media-1.3.1-py2.py3-none-any.whl (75 kB)
Collecting google-cloud-core<3.0.0dev,>=1.4.1
  Using cached google_cloud_core-1.7.1-py2.py3-none-any.whl (28 kB)
Collecting proto-plus>=1.10.0
  Using cached proto_plus-1.19.0-py3-none-any.whl (42 kB)
Collecting grpcio<2,>=1.29.0
  Using cached grpcio-1.39.0-cp38-cp38-manylinux2014_x86_64.whl (4.3 MB)
Collecting google-crc32c<2.0dev,>=1.0
  Using cached google_crc32c-1.1.2-cp38-cp38-manylinux2014_x86_64.whl (38 kB)
Collecting cffi>=1.0.0
  Using cached cffi-1.14.6-cp38-cp38-manylinux1_x86_64.whl (411 kB)
Collecting pycparser
  Using cached pycparser-2.20-py2.py3-none-any.whl (112 kB)
Collecting tqdm
  Using cached tqdm-4.61.2-py2.py3-none-any.whl (76 kB)
Collecting python-slugify
  Using cached python_slugify-5.0.2-py2.py3-none-any.whl (6.7 kB)
Collecting six
  Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Requirement already satisfied: tensorboard~=2.5 in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from tensorflow>=2.5.0->tf-models-official->object-detection==0.1) (2.5.0)
Requirement already satisfied: astunparse~=1.6.3 in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from tensorflow>=2.5.0->tf-models-official->object-detection==0.1) (1.6.3)
Requirement already satisfied: h5py~=3.1.0 in /home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages (from tensorflow>=2.5.0->tf-models-official->object-detection==0.1) (3.1.0)
INFO: pip is looking at multiple versions of pyyaml to determine which version is compatible with other requirements. This could take a while.
Collecting pyyaml>=5.1
  Using cached PyYAML-5.4-cp38-cp38-manylinux1_x86_64.whl (662 kB)
  Using cached PyYAML-5.3.1.tar.gz (269 kB)
  Using cached PyYAML-5.3.tar.gz (268 kB)
  Using cached PyYAML-5.2.tar.gz (265 kB)
  Using cached PyYAML-5.1.2.tar.gz (265 kB)
  Using cached PyYAML-5.1.1.tar.gz (274 kB)
  Using cached PyYAML-5.1.tar.gz (274 kB)
INFO: pip is looking at multiple versions of pyyaml to determine which version is compatible with other requirements. This could take a while.
INFO: pip is looking at multiple versions of py-cpuinfo to determine which version is compatible with other requirements. This could take a while.
Collecting py-cpuinfo>=3.3.0
  Using cached py-cpuinfo-7.0.0.tar.gz (95 kB)
INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. If you want to abort this run, you can press Ctrl + C to do so. To improve how pip performs, tell us what happened here: https://pip.pypa.io/surveys/backtracking
  Using cached py-cpuinfo-6.0.0.tar.gz (145 kB)
  Using cached py-cpuinfo-5.0.0.tar.gz (82 kB)
  Using cached py-cpuinfo-4.0.0.tar.gz (79 kB)
  Using cached py-cpuinfo-3.3.0.tar.gz (76 kB)
INFO: pip is looking at multiple versions of psutil to determine which version is compatible with other requirements. This could take a while.
Collecting psutil>=5.4.3
  Using cached psutil-5.7.3.tar.gz (465 kB)
INFO: pip is looking at multiple versions of py-cpuinfo to determine which version is compatible with other requirements. This could take a while.
  Using cached psutil-5.7.2.tar.gz (460 kB)
INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. If you want to abort this run, you can press Ctrl + C to do so. To improve how pip performs, tell us what happened here: https://pip.pypa.io/surveys/backtracking
  Using cached psutil-5.7.1.tar.gz (460 kB)
  Using cached psutil-5.7.0.tar.gz (449 kB)
  Using cached psutil-5.6.7.tar.gz (448 kB)
  Using cached psutil-5.6.6.tar.gz (447 kB)
  Using cached psutil-5.6.5.tar.gz (447 kB)
INFO: pip is looking at multiple versions of psutil to determine which version is compatible with other requirements. This could take a while.
  Using cached psutil-5.6.4.tar.gz (447 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
  Using cached psutil-5.6.3.tar.gz (435 kB)
  Using cached psutil-5.6.2.tar.gz (432 kB)
  Using cached psutil-5.6.1.tar.gz (427 kB)
  Using cached psutil-5.6.0.tar.gz (426 kB)
INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. If you want to abort this run, you can press Ctrl + C to do so. To improve how pip performs, tell us what happened here: https://pip.pypa.io/surveys/backtracking
  Using cached psutil-5.5.1.tar.gz (426 kB)
  Using cached psutil-5.5.0.tar.gz (425 kB)
  Using cached psutil-5.4.8.tar.gz (422 kB)
  Using cached psutil-5.4.7.tar.gz (420 kB)
  Using cached psutil-5.4.6.tar.gz (418 kB)
  Using cached psutil-5.4.5.tar.gz (418 kB)
  Using cached psutil-5.4.4.tar.gz (417 kB)
  Using cached psutil-5.4.3.tar.gz (412 kB)
INFO: pip is looking at multiple versions of proto-plus to determine which version is compatible with other requirements. This could take a while.
Collecting proto-plus>=1.10.0
  Using cached proto_plus-1.18.1-py3-none-any.whl (42 kB)
  Using cached proto_plus-1.18.0-py3-none-any.whl (42 kB)
  Using cached proto_plus-1.17.0-py3-none-any.whl (42 kB)
  Using cached proto_plus-1.16.0-py3-none-any.whl (42 kB)
  Using cached proto_plus-1.15.0-py3-none-any.whl (42 kB)
  Using cached proto_plus-1.14.2-py3-none-any.whl (42 kB)
  Using cached proto-plus-1.13.0.tar.gz (44 kB)
INFO: pip is looking at multiple versions of proto-plus to determine which version is compatible with other requirements. This could take a while.
  Using cached proto-plus-1.11.0.tar.gz (44 kB)
  Using cached proto-plus-1.10.2.tar.gz (42 kB)
  Using cached proto-plus-1.10.1.tar.gz (42 kB)
  Using cached proto-plus-1.10.0.tar.gz (24 kB)
INFO: pip is looking at multiple versions of packaging to determine which version is compatible with other requirements. This could take a while.
Collecting packaging>=14.3
  Using cached packaging-20.9-py2.py3-none-any.whl (40 kB)
INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. If you want to abort this run, you can press Ctrl + C to do so. To improve how pip performs, tell us what happened here: https://pip.pypa.io/surveys/backtracking
  Downloading packaging-20.8-py2.py3-none-any.whl (39 kB)
  Downloading packaging-20.7-py2.py3-none-any.whl (35 kB)
  Downloading packaging-20.5-py2.py3-none-any.whl (35 kB)
  Downloading packaging-20.4-py2.py3-none-any.whl (37 kB)
  Downloading packaging-20.3-py2.py3-none-any.whl (37 kB)
  Downloading packaging-20.2-py2.py3-none-any.whl (37 kB)
INFO: pip is looking at multiple versions of packaging to determine which version is compatible with other requirements. This could take a while.
  Downloading packaging-20.1-py2.py3-none-any.whl (36 kB)
  Downloading packaging-20.0-py2.py3-none-any.whl (36 kB)
  Downloading packaging-19.2-py2.py3-none-any.whl (30 kB)
  Downloading packaging-19.1-py2.py3-none-any.whl (30 kB)
Collecting attrs
  Downloading attrs-21.2.0-py2.py3-none-any.whl (53 kB)
     |████████████████████████████████| 53 kB 2.9 MB/s
Collecting packaging>=14.3
  Downloading packaging-19.0-py2.py3-none-any.whl (26 kB)
INFO: This is taking longer than usual. You might need to provide the dependency resolver with stricter constraints to reduce runtime. If you want to abort this run, you can press Ctrl + C to do so. To improve how pip performs, tell us what happened here: https://pip.pypa.io/surveys/backtracking
  Downloading packaging-18.0-py2.py3-none-any.whl (21 kB)
  Downloading packaging-17.1-py2.py3-none-any.whl (24 kB)
  Downloading packaging-17.0-py2.py3-none-any.whl (23 kB)
  Downloading packaging-16.8-py2.py3-none-any.whl (23 kB)
  Downloading packaging-16.7-py2.py3-none-any.whl (22 kB)
  Downloading packaging-16.6-py2.py3-none-any.whl (22 kB)
  Downloading packaging-16.5-py2.py3-none-any.whl (22 kB)
  Downloading packaging-16.4-py2.py3-none-any.whl (22 kB)
  Downloading packaging-16.3-py2.py3-none-any.whl (22 kB)
  Downloading packaging-16.2-py2.py3-none-any.whl (22 kB)
  Downloading packaging-16.1-py2.py3-none-any.whl (21 kB)
  Downloading packaging-16.0-py2.py3-none-any.whl (19 kB)
  Downloading packaging-15.3-py2.py3-none-any.whl (18 kB)
  Downloading packaging-15.2-py2.py3-none-any.whl (18 kB)
  Downloading packaging-15.1-py2.py3-none-any.whl (17 kB)
  Downloading packaging-15.0-py2.py3-none-any.whl (17 kB)
  Downloading packaging-14.5-py2.py3-none-any.whl (16 kB)
  Downloading packaging-14.4-py2.py3-none-any.whl (16 kB)
  Downloading packaging-14.3-py2.py3-none-any.whl (16 kB)
INFO: pip is looking at multiple versions of kaggle to determine which version is compatible with other requirements. This could take a while.
Collecting kaggle>=1.3.9
  Downloading kaggle-1.5.10.tar.gz (59 kB)
     |████████████████████████████████| 59 kB 2.4 MB/s
  Downloading kaggle-1.5.9.tar.gz (58 kB)
     |████████████████████████████████| 58 kB 1.4 MB/s
Collecting slugify
  Downloading slugify-0.0.1.tar.gz (1.2 kB)
ERROR: Exception:
Traceback (most recent call last):
  File "/home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 180, in _main
    status = self.run(options, args)
  File "/home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
    return func(self, options, args)
  File "/home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 318, in run
    requirement_set = resolver.resolve(
  File "/home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 127, in resolve
    result = self._result = resolver.resolve(
  File "/home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages/pip/_vendor/resolvelib/resolvers.py", line 473, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/home/labuser/anaconda3/envs/tf/lib/python3.8/site-packages/pip/_vendor/resolvelib/resolvers.py", line 384, in resolve
    raise ResolutionTooDeep(max_rounds)
pip._vendor.resolvelib.resolvers.ResolutionTooDeep: 2000000

It took multiple hours to time out. However, it worked the next time I ran the installation command, and only took a minute. I would recommend just letting it go through the dependencies until it works out, as pip recommends 25.


Question:
train_data = object_detector.DataLoader.from_pascal_voc("/content/drive/MyDrive/10ImagesTesting/Train10imagesXML", “/content/drive/MyDrive/10ImagesTesting/Train10imagesXML”, label_map= {1: “Circle K Donut”, 2: “Chocolate Heart”, 3: “Chocolate Heart With Sprinkles”, 4: “Chocolate Ring”,5: “Chocolate Ring With Sprinkles”, 6: “Apple Turnover”, 7: “Red Velvet Cake”, 8: “Chocolate Old Fashioned”,8: “Chocolate Old Fashioned”, 9: “Concha”, 10: “Crumb Cake”, 11: “Strawberry Heart With Sprinkles promo”,12: “Blueberry Fritter”, 13: “Apple Fritter”, 14: “Cinnamon Roll”, 15: “Frosted Cinnamon Roll”,16: “Butter Croissant”, 17: “Raspberry Filled”, 18: “Boston cream shell”, 19: “Cotton Candy Ring Promo”,20: “Glazed Ring”, 21: “Sugared Ring”, 22: “Glazed Twist”, 23: “Sugared Twist”,24: “Glazed Pull Apart”, 25: “Sprinkled Pull Apart”, 26: “Strawberry Ring With Sprinkles”, 27: “Death by Chocolate”, 28: “Boston Cream Bar”, 29: “Jelly Filled Bar”, 30: “Brownie Batter Bar”, 31: “Chocolate Bar”,32: “Maple Bar”})
ERROR
/usr/local/lib/python3.7/dist-packages/tensorflow_examples/lite/model_maker/third_party/efficientdet/dataset/create_pascal_tfrecord.py in dict_to_tf_example(data, images_dir, label_map_dict, unique_id, ignore_difficult_instances, ann_json_dict)
172       area.append((xmax[-1] - xmin[-1]) * (ymax[-1] - ymin[-1]))
173       classes_text.append(obj[‘name’].encode(‘utf8’))
 → 174       classes.append(label_map_dict[obj[‘name’]])
175       truncated.append(int(obj[‘truncated’]))
176       poses.append(obj[‘pose’].encode(‘utf8’))
KeyError: '23

Context:
I’m having the same issue. Any luck?
Edit: Just figured it out myself, in the xml files, some files were missing the  field. I just added <pose>Undefined</pose> after </name> and got it to work.


Question:
Hello guys,
I’d like to ask if there is some info, examples, sample code or recent benchmarking data for XLA/tfcompile for inference of float and quantized models?
I’d like to find out and compare tflite vs. XLA/AOT.
Thank you

Context:
/cc: @battery
Could you shed some light on this?


Drawing skeleton with movenet on p5js with movenet +Tensorflow.js ( Poses are detected and working)

Question:
Hi,  I have been trying to run movenet with p5js. I have managed to get the detector working and can log out the poses. However , I am trying to draw a skeleton on top of the connected circle for vizualization purposes. I have looked into posenet as it has similar 17 keypoints. However, I noticed that some functions such as posenet.getAdjacentKeypoints are not implemented in movenet. I tried to look into the TFJS models  -->src-->demo but could not get my head around how to implement the skeleton. My sample trial code is below.
let detector;
let poses;
let video;
async function init() {
  const detectorConfig = {
    modelType: poseDetection.movenet.modelType.SINGLEPOSE_LIGHTNING,
  };
  detector = await poseDetection.createDetector(
    poseDetection.SupportedModels.MoveNet,
    detectorConfig
  );
}

async function videoReady() {
  console.log("video ready");
  await getPoses();
}

async function setup() {
  createCanvas(640, 480);
  video = createCapture(VIDEO, videoReady);
  video.hide();

  await init();
  //createButton('pose').mousePressed(getPoses)
}

async function getPoses() {
  poses = await detector.estimatePoses(video.elt);
  setTimeout(getPoses, 0);
}

function draw() {
  background(220);
  image(video, 0, 0);
  if (poses && poses.length > 0) {
    //console.log(poses[0].keypoints.length)
    //console.log(poses[0].keypoints[0].x);
    for (let kp of poses[0].keypoints) {
      const { x, y, score } = kp;
      console.log(kp);
      if (score > 0.5) {
        fill(255);
        stroke(0);
        strokeWeight(4);
        circle(x, y, 16);
       }

    }

    for (let i = 0; i < poses[0].keypoints.length ; i ++)
      {
        // Get adjacent keypoints (Start with nose and left_eye)
        let x = poses[0].keypoints.length.nose

      }

  }

}

If i understand the line functions needs both the x1,x2 and y1,y2 co-ordinates to effectively  join the points. I was wondering if anyone has managed to overlay the skeleton

Context: @Jason might be able to help here


Question:
Hello. I’m new to NLP and I’m trying to follow Tensorflow’s tutorial on Image Captioning (Image captioning with visual attention  |  TensorFlow Core 1), but I ran into an problem when trying to preprocess the images with InceptionV3. As said in the tutorial, I have a preprocessing function
def load_image(image_path):
    img = tf.io.read_file(image_path)
    img = tf.image.decode_jpeg(img, channels=3)
    img = tf.image.resize(img, (299, 299))
    img = tf.keras.applications.inception_v3.preprocess_input(img)
    return img, image_path

Then I use it to get a BatchDataset (I get a <BatchDataset shapes: ((None, 299, 299, 3), (None,)), types: (tf.float32, tf.string)>)
# Get unique images
encode_train = sorted(set(img_name_vector))
# Feel free to change batch_size according to your system configuration
image_dataset = tf.data.Dataset.from_tensor_slices(encode_train)
image_dataset = image_dataset.map(load_image, num_parallel_calls=tf.data.experimental.AUTOTUNE).batch(16)

Up to this point, everything works, but then when I try
for img, path in image_dataset:
    #Do something

Either nothing happens or the kernel dies. Is there a way to fix or circumvent that issue?

Context:
Hi,
I’ve just tried the colab you linked to and it passed the part you mentioned (and finished fine).
Is your runtime configured to use GPU?
When the kernel dies might be an out of memory issue, did you notice that on the RAM bar on the top right corner?


AttributeError: ‘Tensor’ object has no attribute ‘numpy’

Question:
import numpy as np
import pandas as pd
import tensorflow as tf
import tensorflow_datasets as tfds
from tensorflow import keras
from tensorflow.keras.applications.resnet50 import ResNet50
from tensorflow.keras.models import Model
(stl_train, stl_test, stl_unlabelled), ds_info = tfds.load('stl10',split=['train','test','unlabelled'],shuffle_files=True,as_supervised=True,with_info=True)
base_model = ResNet50(input_shape=ds_info.features['image'].shape,weights=None)
def reshapeImage(image, label):
  return tf.reshape(image, (1,96,96,3)), tf.convert_to_tensor(onehot_encoded[label.numpy()])
stl_train = stl_train.map(reshapeImage, num_parallel_calls=tf.data.experimental.AUTOTUNE)

The labels are tf.Tensor(4, shape=(), dtype=int64) ,I want the 4, in this example, which I will be using to convert into one-hot encoded labels, but I am unable to do so

Context: Have you tried to use set_shape in your reshapeImage function?


Error: The shape of dict[‘input_tensor’] provided in model.execute(dict) must be [1,-1,-1,3]

Question:
Hi, I converted my saved model to model json using tensorflowjs_converter
    tensorflowjs_converter \
    --input_format=tf_saved_model \
    --output_format=tfjs_graph_model \
    --saved_model_tags=serve \
    --signature_name=serving_default \
    /saved_model \
   /json-model

model.predict({input_tensor: inputTensor});
throws the following errors
Error: The shape of dict['input_tensor'] provided in model.execute(dict) must be [1,-1,-1,3], but was [1,600,800,4]
    at Object.assert (/object-detection/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:337:15)
    at /object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:7478:28
    at Array.forEach (<anonymous>)
    at GraphExecutor.checkInputShapeAndType (/object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:7470:29)
    at GraphExecutor.<anonymous> (/object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:7272:34)
    at step (/object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:81:23)
    at Object.next (/object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:62:53)
    at /object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:55:71
    at new Promise (<anonymous>)
    at __awaiter (/object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:51:12)

If I add ----control_flow_v2=True  to do the conversion, it will fail to loadGraphModel.
I'm running @tensorflow/tfjs-node v 3.7.0 and I'm still getting this error "Cannot read property 'outputs' of undefined" when tried to load model json that was converted from saved model using tensorflowjs_converter.
When I changed to @tensorflow/tfjs-node@next, it would throw "Cannot read property 'children' of undefined"

model = await tf.loadGraphModel(modelPath);

2021-07-10 13:26:00.618147: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.

TypeError: Cannot read property 'outputs' of undefined
at /object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:3851:31
at Array.forEach ()
at /object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:3848:29
at Array.forEach ()
at OperationMapper.mapFunction (/object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:3846:18)
at /object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:3679:56
at Array.reduce ()
at OperationMapper.transformGraph (/object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:3678:48)
at GraphModel.loadSync (/object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:7763:68)
at GraphModel. (/object-detection/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:7737:52)

Context: If this is an image model are you loading RGBA when it expects RGB? That would maybe explain the 4 vs 3 error you have in the first case?


Parsed source code - a text classification problem?

Question:
Hi, I’m new to machine learning, so excuse me if this is a foolish question. I’m working on a data science project in R, where I attempt to predict whether a Swift code sample is correct or not. The data comes from IBM’s Project CodeNet 1, which has 14 million code samples from code problem websites (6000 of which are in Swift). Each code sample is annotated with whether it was accepted or rejected.
I was thinking of parsing all of the code samples into their Abstract Syntax Tree 1 (in this case the Swift Abstract Syntax Tree 1), which is basically an ultra-labelled version of the source code, and then passing the parsed AST into a neural net, so that it can learn how to predict whether a code sample is right or wrong.
Is this a text classification problem? The Abstract Syntax Tree is all text, and I’m trying to classify it into accepted / rejected, but it’s also extremely structured. So can I consider it like one, or is there some other tool which would be better suited for this situation?

Context: As I’ve been looking around, I’ve come to the realisation that this is a supervised binary graph classification problem – so a graph convolutional network using the stellargraph library 3 should do the trick. Let me know if you think I’m totally wrong about this!


Question:
I am working with a small team of amateur radio astronomers in the UK (British Astronomical Association | Supporting amateur astronomers since 1890 1) to set up a citizen-science scheme to record meteors. This is achieved using radio reflections off the plasma tails left by meteors entering the Earth’s atmosphere. Currently analysing these reflections is pretty manual and we would like to automate some of this, possibly using ML. There are two problems we would like to overcome. 1) Counting actual meteor hits 2) Rejecting aircraft echos.
The latter is one of the main challenges and is currently been done manually, as well as on a zoo basis.
I am sure, looking at the work others (and myself) have done with ML in Tensaflow that certainly the aircraft echos could be identified, and hopefully the actual meteors too. Here is a link to some of the data we are collecting with what we are looking for. Zooniverse 2
My questions is: 1) Do you think this would be possible? 2) are there any of you who may be interested in helping out on the project?

Context:
Nice initiative!

I think it would certainly be possible to have a classification task, given that you already have quite a lot of data. To reject the aircraft echos, I was thinking about anomaly detection using auto-encoders, again given the fact that you probably have a lot of data on actual meteor reflections.
Either way, I think there are several ways to tackle this project


Question:
Hello, I’m trying to load cifar dataset
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
import pandas as pd
from tensorflow.keras import datasets, layers
from glob import glob
from tensorflow.keras.preprocessing.image import ImageDataGenerator

train_paths = glob('dataset/cifar/train/*.png')
test_paths = glob('dataset/cifar/train/*.png')

def get_label_name (path):
    lbl_name = path.split('_')[-1].replace('.png','')
    return lbl_name

classes = np.unique([get_label_name (path) for path in train_paths])

def onehot_encoding(label_name):
    onehot_encoding = tf.cast(classes == label_name, tf.uint8)
    return onehot_encoding

def read_dataset(path):
    gfile = tf.io.read_file(path)
    image = tf.io.decode_image(gfile)

class_name = get_label_name(path)
label = onehot_encoding(class_name)
return image, label

train_dataset = tf.data.Dataset.from_tensor_slices(train_paths)
train_dataset = train_dataset.map(read_dataset)
train_dataset = train_dataset.batch(batch_size=32)
train_dataset = train_dataset.shuffle(buffer_size=len(train_paths))
train_dataset = train_dataset.repeat()

However, error message ’ AttributeError: ‘Tensor’ object has no attribute ‘split’’ comes out.
Is there any way to solve this problem?
I am looking forward to see an help. Thanks in advance.
Kind regards,
Yoon Ho

Context:
Issue with this line class_name = get_label_name(path), you are trying to get the class_name but its giving Tensor value. It should be list of classes.
Find the below working code,

import os
os.environ[‘TF_CPP_MIN_LOG_LEVEL’] = ‘2’
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
import pandas as pd
from tensorflow.keras import datasets, layers
from glob import glob
from tensorflow.keras.preprocessing.image import ImageDataGenerator
train_paths = glob(‘dataset/cifar/train/.png’)
test_paths = glob('dataset/cifar/train/.png’)
def get_label_name (path):
lbl_name = path.split(’/’)[-1].replace(’.png’,’’)
return lbl_name
classes = np.unique([get_label_name (path) for path in train_paths])
classes
def onehot_encoding(label_name):
onehot_encoding = tf.cast(classes == label_name, tf.uint8)
return onehot_encoding
def read_dataset(path):
gfile = tf.io.read_file(path)
image = tf.io.decode_image(gfile)
    class_name = [get_label_name (path) for path in train_paths]
    label = onehot_encoding(class_name)
    return image, label

train_dataset = tf.data.Dataset.from_tensor_slices(train_paths)
train_dataset = train_dataset.map(read_dataset)
train_dataset = train_dataset.batch(batch_size=32)
train_dataset = train_dataset.shuffle(buffer_size=len(train_paths))
train_dataset = train_dataset.repeat()


Question:
Hi folks.
If you are a beginner in Machine Learning, it might be hard for you to brainstorm project ideas to supplement your learning. At least, I have faced this challenge and to some extent, I still face it. This is why I put together some points I feel to be important and may be of help:

      docs.google.com

YFP - Sayak 19

Sayak Paul | Deep Learning Associate at PyImageSearch DSC WOW December 07, 2020 Hello everyone. I am Sayak. I am a Deep Learning Associate at PyImageSearch where I work on computer vision with deep learning. Your first machine learning project

Let me know what you think. I also open to adding more relevant pointers to the above deck.

Context:
Hi,
I am also learning Machine learning 9 and i am working on my Live project now!!!


Question:
I tried to convert my Pytorch models to TensorFlow Lite with ONNX. But my inference time from TensorFlow Lite is twice as slow as Tensorflow and Pytorch. I run TensorFlow Lite model in google colab and this is my first time using TensorFlow Lite.
Here is my code to convert from Tensorflow to TensorFlow Lite:
converter = tf.lite.TFLiteConverter.from_saved_model("model/")
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.target_spec.supported_types = [tf.float16]
model_lite = converter.convert()

with open('model.tflite', 'wb') as f:
    f.write(model_lite)

I  used time module from Python to measure the latency of frameworks. I don’t know why my Lite version is slower than the others. Any suggestions will help me a lot.

Context:
TFLite is not meant to perform good on the commodity hardware actually. It’s opset is optimized to run faster primarily on mobile hardware. However, if you build TFLite for your platform (preferably with XNNPACK enabled) then you may get some benefits.
Here’s some more information:

      TensorFlow

Build TensorFlow Lite with CMake 7


Question:
I converted a keras model to tflite which includes batch normalization layer.
Opening the tflite file in Netron, the batch normalization operation is separated into 2 operations of multiplication and addition.
When doing inference on a couple of test samples with tflite , the values are not just multiplied and added in batch normalization layer. There seems to be more operations than just a simple multiplication and addition.
Does anyone know if tensorflow lite is applying any operation besides that when doing batch normalization?

Context: It’s usually removed and expanded. Here 69 you can find a non-exhaustive list of all such operations for which this behavior is applied.


Problems runnning tflite Hello World example on Arduino

Question:
Dear all,
I am trying to compile the Hello World example sketch included in the Tensorflow Lite library which can be installed within the Arduino IDE. I experienced some problems.

On the first try it gave me an error, saying that a cmsis_gcc.h was missing in some directory. I added this file manually from the ARM github.

After this another error occured. This seems to do with a missing bracket “}”. The last “if()” statement seems to be missing the brackets {}. If I improve on this syntax error, the compiler will still give the error about “}” or just crash. It does not matter how many "}"s I add, it will still give this error.

Is this a well known problem? I am not posting the code here since it is simply the built-in HelloWorld example.
For anybody who can comment on this, you have my gratitude!
Owen

Context:
Hi @Owen_Huisman
Can you share the link of this Hello World example?


Question:
Should @tf.function only be used during training, or should it also be used during inference?
The function I use during inference calls the model, sends the output to a softmax. and then calls argmax. Adding @tf.function to this function works well, but does it provide any benefits?

Context:
@tf.function provides some nice performance benefits and I can’t think of any particular reason not to use it at inference unless your input shapes change often or for some reason your inference logic forces recompilation.
It’s a requirement to use tf.function to even export models to the SavedModel format, so I think it makes sense: Better performance with tf.function  |  TensorFlow Core 2


Saving tensorflow model in PB and PBTXT format

Question: Can anyone share the process to save the Tensorflow model in PB and pbtxt format

Context:
Hi Ragu,
here are some resources to help you:

Save and load models  |  TensorFlow Core 9
Using the SavedModel format  |  TensorFlow Core 3


Question:
I am trying to build TF with ASAN flag enabled , using the command :
bazel build --config=dbg --config=asan --copt -fsanitize=address --linkopt -fsanitize=address //tensorflow/tools/pip_package:build_pip_package --verbose_failures

but this would give me an error about the third party library:
ERROR: /home/user/.cache/bazel/_bazel_user/7562dd0a46bcb6cada6ae19650738275/external/libjpeg_turbo/BUILD.bazel:238:8: Executing genrule @libjpeg_turbo//:simd_x86_64_assemblage23 failed (Exit 1): bash failed: error executing command
  (cd /home/user/.cache/bazel/_bazel_user/7562dd0a46bcb6cada6ae19650738275/execroot/org_tensorflow && \
  exec env - \
    LD_LIBRARY_PATH=/usr/local/cuda-11.3/lib64 \
    PATH=/home/user/bin:/usr/local/cuda-11.3/bin:/home/user/anaconda3/envs/tfenv/bin:/home/user/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin \
  /bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; for out in bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jccolor-avx2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jccolor-sse2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jcgray-avx2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jcgray-sse2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jchuff-sse2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jcphuff-sse2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jcsample-avx2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jcsample-sse2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jdcolor-avx2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jdcolor-sse2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jdmerge-avx2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jdmerge-sse2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jdsample-avx2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jdsample-sse2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jfdctflt-sse.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jfdctfst-sse2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jfdctint-avx2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jfdctint-sse2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jidctflt-sse2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jidctfst-sse2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jidctint-avx2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jidctint-sse2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jidctred-sse2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jquantf-sse2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jquanti-avx2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jquanti-sse2.o bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/simd/x86_64/jsimdcpu.o; do
  bazel-out/k8-dbg/bin/external/nasm/nasm -f elf64    -DELF -DPIC -D__x86_64__    -I $(dirname bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/jconfig.h)/    -I $(dirname bazel-out/k8-opt-exec-50AE0418/bin/external/libjpeg_turbo/jconfigint.h)/    -I $(dirname external/libjpeg_turbo/simd/nasm/jsimdcfg.inc.h)/    -I $(dirname external/libjpeg_turbo/simd/x86_64/jccolext-sse2.asm)/    -o $out    $(dirname external/libjpeg_turbo/simd/x86_64/jccolext-sse2.asm)/$(basename ${out%.o}.asm)
done')
Execution platform: @local_execution_config_platform//:platform

=================================================================
==479927==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 5888 byte(s) in 32 object(s) allocated from:
    #0 0x7f0adb6bcbc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
    #1 0x55d56e9d76d1 in nasm_malloc (/home/user/.cache/bazel/_bazel_user/7562dd0a46bcb6cada6ae19650738275/execroot/org_tensorflow/bazel-out/k8-dbg/bin/external/nasm/nasm+0x1d96d1)
    #2 0x55d56e9b9c2e in do_directive (/home/user/.cache/bazel/_bazel_user/7562dd0a46bcb6cada6ae19650738275/execroot/org_tensorflow/bazel-out/k8-dbg/bin/external/nasm/nasm+0x1bbc2e)
    #3 0x55d56e9c5d60 in pp_getline (/home/user/.cache/bazel/_bazel_user/7562dd0a46bcb6cada6ae19650738275/execroot/org_tensorflow/bazel-out/k8-dbg/bin/external/nasm/nasm+0x1c7d60)
    #4 0x55d56e99d13f in assemble_file.constprop.8 (/home/user/.cache/bazel/_bazel_user/7562dd0a46bcb6cada6ae19650738275/execroot/org_tensorflow/bazel-out/k8-dbg/bin/external/nasm/nasm+0x19f13f)
    #5 0x55d56e97b275 in main (/home/user/.cache/bazel/_bazel_user/7562dd0a46bcb6cada6ae19650738275/execroot/org_tensorflow/bazel-out/k8-dbg/bin/external/nasm/nasm+0x17d275)
    #6 0x7f0adb2020b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)

Direct leak of 768 byte(s) in 192 object(s) allocated from:
    #0 0x7f0adb6bcbc8 in malloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10dbc8)
    #1 0x55d56e9d76d1 in nasm_malloc (/home/user/.cache/bazel/_bazel_user/7562dd0a46bcb6cada6ae19650738275/execroot/org_tensorflow/bazel-out/k8-dbg/bin/external/nasm/nasm+0x1d96d1)
    #2 0x55d56e9ac010 in new_Token.constprop.9 (/home/user/.cache/bazel/_bazel_user/7562dd0a46bcb6cada6ae19650738275/execroot/org_tensorflow/bazel-out/k8-dbg/bin/external/nasm/nasm+0x1ae010)
    #3 0x55d56e9c706d in pp_getline (/home/user/.cache/bazel/_bazel_user/7562dd0a46bcb6cada6ae19650738275/execroot/org_tensorflow/bazel-out/k8-dbg/bin/external/nasm/nasm+0x1c906d)
    #4 0x55d56e99d13f in assemble_file.constprop.8 (/home/user/.cache/bazel/_bazel_user/7562dd0a46bcb6cada6ae19650738275/execroot/org_tensorflow/bazel-out/k8-dbg/bin/external/nasm/nasm+0x19f13f)
    #5 0x55d56e97b275 in main (/home/user/.cache/bazel/_bazel_user/7562dd0a46bcb6cada6ae19650738275/execroot/org_tensorflow/bazel-out/k8-dbg/bin/external/nasm/nasm+0x17d275)
    #6 0x7f0adb2020b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)

So I tried to add the following to the  third_party/jpec/BUILD.bazel :
# line 238
genrule(
    name = "simd_x86_64_assemblage23",
+    tags = [
+       "noasan",
+        "no_cuda_asan",
+       "nomsan",
+        "notsan",
+    ],

This still does not help.
Is there tips of how to deal with this?

Context:
Just to link your ticket to the thread:

      github.com/tensorflow/tensorflow

      Tensorflow could not build with `config=asan`  flag 8

        opened

        Jul 22, 2021

          Stonepia

        type:build/install

    Please make sure that this is a build/installation issue. As per our [GitHub… Policy](https://github.com/tensorflow/tensorflow/blob/master/ISSUES.md), we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:build_template

**System information**

OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 20.04
Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
TensorFlow installed from (source or binary): source
TensorFlow version: master
Python version: 3.8.8
Installed using virtualenv? pip? conda?: cinda
Bazel version (if compiling from source): 3.7.2
GCC/Compiler version (if compiling from source): clang-11
CUDA/cuDNN version: CUDA 11.3, CuDNN 8
GPU model and memory: GTX 1080 Ti

**Describe the problem**

**Provide the exact sequence of commands / steps that you executed before running into the problem**

I am trying to build TF with Address Sanitizer enabled.

TF could not built with the flag `--config asan`.

I tried to use the following command:

```Batch
CC=/usr/lib/llvm-11/bin/clang TMP=~/tmp bazel build --config asan --config=dbg --per_file_copt=//tensorflow/core/grappler/./.*\.cc@-g //tensorflow/tools/pip_package:build_pip_package --verbose_failures
```
and it failed with the following

```Log
tensorflow git:(master) ✗ CC=/usr/lib/llvm-11/bin/clang TMP=~/tmp bazel build --config asan --config=dbg --per_file_copt=//tensorflow/core/grappler/./.*\.cc@-g //tensorflow/tools/pip_package:build_pip_package --verbose_failures
WARNING: The following configs were expanded more than once: [cuda_clang, cuda]. For repeatable flags, repeats are counted twice and may lead to unexpected behavior.
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=149
INFO: Reading rc options for 'build' from /home/user/tensorflow/.bazelrc:
  Inherited 'common' options: --experimental_repo_remote_exec
INFO: Reading rc options for 'build' from /home/user/tensorflow/.bazelrc:
  'build' options: --define framework_shared_object=true --java_toolchain=@tf_toolchains//toolchains/java:tf_java_toolchain --host_java_toolchain=@tf_toolchains//toolchains/java:tf_java_toolchain --define=use_fast_cpp_protos=true --define=allow_oversize_protos=true --spawn_strategy=standalone -c opt --announce_rc --define=grpc_no_ares=true --noincompatible_remove_legacy_whole_archive --enable_platform_specific_config --define=with_xla_support=true --config=short_logs --config=v2 --define=no_aws_support=true --define=no_hdfs_support=true
INFO: Reading rc options for 'build' from /home/user/tensorflow/.tf_configure.bazelrc:
  'build' options: --action_env PYTHON_BIN_PATH=/home/user/anaconda3/envs/tfenv/bin/python3 --action_env PYTHON_LIB_PATH=/home/user/anaconda3/envs/tfenv/lib/python3.8/site-packages --python_path=/home/user/anaconda3/envs/tfenv/bin/python3 --action_env CUDA_TOOLKIT_PATH=/usr/local/cuda-11.3 --action_env TF_CUDA_COMPUTE_CAPABILITIES=6.1,6.1,6.1,6.1 --action_env LD_LIBRARY_PATH=/usr/local/cuda-11.3/lib64 --config=cuda_clang --action_env CLANG_CUDA_COMPILER_PATH=/usr/lib/llvm-11/bin/clang --config=cuda_clang
INFO: Reading rc options for 'build' from /home/user/tensorflow/.bazelrc:
  'build' options: --verbose_failures
INFO: Found applicable config definition build:short_logs in file /home/user/tensorflow/.bazelrc: --output_filter=DONT_MATCH_ANYTHING
INFO: Found applicable config definition build:v2 in file /home/user/tensorflow/.bazelrc: --define=tf_api_version=2 --action_env=TF2_BEHAVIOR=1
INFO: Found applicable config definition build:cuda_clang in file /home/user/tensorflow/.bazelrc: --config=cuda --repo_env TF_CUDA_CLANG=1 --@local_config_cuda//:cuda_compiler=clang
INFO: Found applicable config definition build:cuda in file /home/user/tensorflow/.bazelrc: --repo_env TF_NEED_CUDA=1 --crosstool_top=@local_config_cuda//crosstool:toolchain --@local_config_cuda//:enable_cuda
INFO: Found applicable config definition build:cuda_clang in file /home/user/tensorflow/.bazelrc: --config=cuda --repo_env TF_CUDA_CLANG=1 --@local_config_cuda//:cuda_compiler=clang
INFO: Found applicable config definition build:cuda in file /home/user/tensorflow/.bazelrc: --repo_env TF_NEED_CUDA=1 --crosstool_top=@local_config_cuda//crosstool:toolchain --@local_config_cuda//:enable_cuda
INFO: Found applicable config definition build:asan in file /home/user/tensorflow/.bazelrc: --strip=never --copt -fsanitize=address --copt -DADDRESS_SANITIZER --copt -g --copt -O3 --copt -fno-omit-frame-pointer --linkopt -fsanitize=address
INFO: Found applicable config definition build:dbg in file /home/user/tensorflow/.bazelrc: -c dbg --per_file_copt=+.*,-tensorflow.*@-g0 --per_file_copt=+tensorflow/core/kernels.*@-g0 --cxxopt -DTF_LITE_DISABLE_X86_NEON --copt -DDEBUG_BUILD
INFO: Found applicable config definition build:linux in file /home/user/tensorflow/.bazelrc: --copt=-w --host_copt=-w --define=PREFIX=/usr --define=LIBDIR=$(PREFIX)/lib --define=INCLUDEDIR=$(PREFIX)/include --define=PROTOBUF_INCLUDE_PATH=$(PREFIX)/include --cxxopt=-std=c++14 --host_cxxopt=-std=c++14 --config=dynamic_kernels --distinct_host_configuration=false --experimental_guard_against_concurrent_changes
INFO: Found applicable config definition build:dynamic_kernels in file /home/user/tensorflow/.bazelrc: --define=dynamic_loaded_kernels=true --copt=-DAUTOLOAD_DYNAMIC_KERNELS
WARNING: Download from http://mirror.tensorflow.org/github.com/tensorflow/toolchains/archive/d781e89e2ee797ea7afd0c8391e761616fc5d50d.tar.gz failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
WARNING: Download from http://mirror.tensorflow.org/github.com/tensorflow/runtime/archive/c362c993e4cca885ba6afef155d864a2dfd21f85.tar.gz failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
WARNING: Download from https://storage.googleapis.com/mirror.tensorflow.org/github.com/llvm/llvm-project/archive/bcf6f641acdbeb208ea07a9e8ded37cd5b796d26.tar.gz failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException GET returned 404 Not Found
INFO: Analyzed target //tensorflow/tools/pip_package:build_pip_package (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: /home/user/.cache/bazel/_bazel_user/7562dd0a46bcb6cada6ae19650738275/external/highwayhash/BUILD.bazel:23:11: undeclared inclusion(s) in rule '@highwayhash//:arch_specific':
this rule is missing dependency declarations for the following files included by 'highwayhash/highwayhash/arch_specific.cc':
  '/usr/lib/llvm-11/lib/clang/11.1.0/share/asan_blacklist.txt'
Target //tensorflow/tools/pip_package:build_pip_package failed to build
INFO: Elapsed time: 0.680s, Critical Path: 0.40s
INFO: 17 processes: 17 internal.
FAILED: Build did NOT complete successfully
```

Also tried the command of `--copt -fsanitize=address --linkopt -fsanitize=address`:

```Batch
 CC=/usr/lib/llvm-11/bin/clang TMP=~/tmp bazel build --copt -fsanitize=address --linkopt -fsanitize=address --config=dbg --per_file_copt=//tensorflow/core/grappler/./.*\.cc@-g //tensorflow/tools/pip_package:build_pip_package --verbose_failures
```

and get the similar error.

**Any other info / logs**
Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

```Batch
$env
USER=user
LOGNAME=user
HOME=/home/user
PATH=/home/user/bin:/usr/local/cuda-11.3/bin:/home/user/anaconda3/envs/tfenv/bin:/home/user/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
SHELL=/usr/bin/zsh
TERM=xterm-256color
XDG_SESSION_ID=99
XDG_RUNTIME_DIR=/run/user/1000
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
XDG_SESSION_TYPE=tty
XDG_SESSION_CLASS=user
MOTD_SHOWN=pam
LANG=en_US.UTF-8
LC_NUMERIC=zh_CN.UTF-8
LC_TIME=zh_CN.UTF-8
LC_MONETARY=zh_CN.UTF-8
LC_PAPER=zh_CN.UTF-8
LC_NAME=zh_CN.UTF-8
LC_ADDRESS=zh_CN.UTF-8
LC_TELEPHONE=zh_CN.UTF-8
LC_MEASUREMENT=zh_CN.UTF-8
LC_IDENTIFICATION=zh_CN.UTF-8
SSH_CLIENT=10.249.174.114 49269 22
SSH_CONNECTION=10.249.174.114 49269 10.239.44.39 22
SSH_TTY=/dev/pts/3
SHLVL=1
PWD=/home/user/tensorflow
OLDPWD=/home/user
ZSH=/home/user/.oh-my-zsh
PAGER=less
LESS=-R
LSCOLORS=Gxfxcxdxbxegedabagacad
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
LD_PRELOAD=/home/user/anaconda3/envs/dlrm/lib/libiomp5.so
CONDA_EXE=/home/user/anaconda3/bin/conda
_CE_M=
_CE_CONDA=
CONDA_PYTHON_EXE=/home/user/anaconda3/bin/python
CONDA_SHLVL=2
CONDA_PREFIX=/home/user/anaconda3/envs/tfenv
CONDA_DEFAULT_ENV=tfenv
CONDA_PROMPT_MODIFIER=(tfenv)
LD_LIBRARY_PATH=/usr/local/cuda-11.3/lib64
CONDA_PREFIX_1=/home/user/anaconda3
_=/usr/bin/env
```


Is Depth_to_space function totally different to Pixelshuffle?

Question:
Hi all.
Currently, I am working on copying a trained pytorch model to tensorflow 2.3 platform.
For the Conv2d layers, the feature map output of pytorch and tensoflows are the same. Thus, the conversion for conv2d layers from pytorch to tf2 are all fine now.
However, when I add a Depth_to_space layer to the model, the output contains lots of mosaic, whereas the output of Pixelshuffle does not have this problem.
I am curious that is the mechanism of  Depth_to_space are different to Pixelshuffle?
Or is my code has some problem?
Here is part of my code.
Pytorch model
some linear mapping layer with nn.Conv2d
self.pslayers = [nn.Conv2d(d, 412,3 ,1, 3//2)]
self.pslayers.extend([nn.PixelShuffle(2)])
self.pslayers.extend([nn.Conv2d(12, 4num_channels,3 ,1, 3//2)])
self.pslayers.extend([nn.PixelShuffle(2)])
self.pslayers = nn.Sequential(*self.pslayers)
The TF2 model:
some linear mapping layer with Conv2d
x = Conv2D(4*12, 3, padding=“same”)(x)
x = tf.nn.depth_to_space(x, 2, data_format=‘NHWC’)
x = Conv2D(4, 3, padding=“same”)(x)
out = tf.nn.depth_to_space(x, 2, data_format=‘NHWC’)
The conversion for Conv2d layer from torch weights to tf2:
onnx_1_w_num = onnx_l.weight.data.numpy().transpose(2, 3, 1, 0)
onnx_1_b_num = onnx_l.bias.data.numpy()
tf_l.set_weights([onnx_1_w_num,onnx_1_b_num])
I am struggling with this problem for a long while.
Very appreciate for those helping me!

Context:
Probably the organization of the channels in your code is problematic. You can refer to the following example for a proper usage:

      keras.io

Keras documentation: Image Super-Resolution using an Efficient Sub-Pixel CNN 25


Question:
I have found the official introduction example guides on the official site Tutorials  |  TensorFlow Core
But I could not find more example codes up until I have bumped in to: https://www.tensorflow.org/text/tutorials/ 2
So is there any other example full projects specialized on topics?
(I love their format and the added COLAB just makes it easier to learn it.)

Context:
keras.io

Keras documentation: Developer guides 1

      keras.io

Keras documentation: Code examples 2

      TensorFlow

Guide  |  TensorFlow Core 1

  Learn basic and advanced concepts of TensorFlow such as eager execution, Keras high-level APIs and flexible model building.


Question:
Hi!
I have trained my model using MobileNetV3 architecture
def get_training_model(trainable=False):
    # Load the MobileNetV3Small model but exclude the classification layers
    EXTRACTOR = MobileNetV3Small(weights="imagenet", include_top=False,
                    input_shape=(IMG_SIZE, IMG_SIZE, 3))
    # We will set it to both True and False
    EXTRACTOR.trainable = trainable
    # Construct the head of the model that will be placed on top of the
    # the base model
    class_head = EXTRACTOR.output
    class_head = GlobalAveragePooling2D()(class_head)
    class_head = Dense(1024, activation="relu")(class_head)
    class_head = Dense(512, activation="relu")(class_head)
    class_head = Dropout(0.5)(class_head)
    class_head = Dense(NUM_CLASSES, activation="softmax", dtype="float32")(class_head)

    # Create the new model
    classifier = tf.keras.Model(inputs=EXTRACTOR.input, outputs=class_head)

    # Compile and return the model
    classifier.compile(loss="sparse_categorical_crossentropy",
                          optimizer="adam",
                          metrics=["accuracy"])

    return classifier

But when I am doing Quantisation Aware Training it is giving me an error.

image1028×762 97 KB

Context:
Can you try without setting dtype to float as string? By default the dtype is set to float32

 Sayan_Nath:

class_head = Dense(NUM_CLASSES, activation="softmax")(class_head)

Also if you can provide a reproducible code example that will be great.


Error in TFX while training on winequality dataset

Question:
Getting this error always when I am performing training in the latest TFX version! Need some solution,working from past few weeks, found nothing!
I am trying to train my TFX model training pipeline on inequality dataset but getting this error always!

ValueError: Got non-flat/non-unique argument names for SavedModel signature ‘serving_default’: more than one argument to ‘__inference_signature_wrapper_3681’ was named ‘fixed acidity’. Signatures have one Tensor per named input, so to have predictable names Python functions used to generate these signatures should avoid *args and Tensors in nested structures unless unique names are specified for each. Use tf.TensorSpec(…, name=…) to provide a name for a Tensor input.

Context: maybe @Robert_Crowe can help here


Why apply G-Zip after pruning or weight clustering?

Question:
Why do we apply the standard compression algorithm after the pruning or weight clustering ?
To use the model, anyhow we need to unzip it, right ?
so what difference does it make ??

Context:
Hi Mohanish.
This is because the tflite model storing the pruned elements without changing their data type. But the modern compression algorithms pretty efficiently compresses the zero values, so it can reduce the model size after compression.
Yes, the compression might need to undo before the execution, however, considering the tflite is designed for mobile/ioT devices, the model is usually compressed while delivering and storing it to the device.  So it is meaningful to have reduced (compressed) model size.
hope this help, any more discussion is welcome!


Question:
Is there anyway to specify the cache folder for TF build, so that I don’t have to rebuilt everytime after the computer is rebooted?
I tried to set the TMP folder, but it does not help.
 TMP=~/tmp bazel build //tensorflow/tools/pip_package:build_pip_package

This seems does not work, the ~/tmp folder is empty all the time.

Context:
The default is ~/.cache/bazel so it is available after reboot.
You can add an extra cache with:
https://docs.bazel.build/versions/main/remote-caching.html#disk-cache 7
But you need to consider also the cache invalidation effect of large regular changes like this one:

    LLVM updates and bazel cache Build

    As we are updating LLVM two times at day I’ve tried to query bazel with:
bazel aquery  "rdeps(//tensorflow:*,//third_party/llvm:*)" --include_aspects 2>/dev/null | grep Compiling | wc -l
I am not a bazel ninja so probably the query could be wrong or improved but I currently see 9938 files on master (CPU only).
What is the effect of this bi-daily rolling update on the average community contributor compiling workflow/environment and his bazel cache?

More in general you could be interested in:

      github.com/tensorflow/build

      Provide Bazel cache for TensorFlow builds 6

        opened

        May 15, 2020

          angerson

    Providing a TensorFlow build cache could be very helpful to external developers,… and lower the barrier to entry of contributing to TF.

Some ideas for this we've discussed before are:

- Offer [Bazel RBE](https://docs.bazel.build/versions/master/remote-execution.html) resources on behalf of SIG Build. This service is in alpha on GCP.
- Provide a read-only [build cache](https://docs.bazel.build/versions/master/remote-caching.html#google-cloud-storage) in a GCP bucket.
- Provide `devel_cache` Docker images containing a build cache (these could be very large)
- Provide code-and-cache volumes for the docker `devel` images.

See also:

- https://github.com/tensorflow/tensorflow/issues/39560
- https://github.com/tensorflow/tensorflow/issues/4116
- https://github.com/tensorflow/addons/issues/1414


How to set Dataset Cardinality of a dataset created using tf.data.Dataset.from_generator()?

Question:
I am currently working on a project which uses huggingface. I created the huggingface datasets and converted it to tensorflow. The method of conversion is not from_tensor_slices(), the one shown in their documentation but using from_generator(). I found this method a lot faster but at the time of training using TFTrainer(), I encounter an error:
ValueError: The training dataset must have an asserted cardinality
I checked and found the reason was from_generator(). Inorder to verify this, I created a very basic dataset using from_generator() method and checked its cardinality:
dumm_ds = tf.data.Dataset.from_generator(lambda: [tf.constant(1)]*1000, output_signature=tf.TensorSpec(shape=[None], dtype=tf.int64))
tf.data.experimental.cardinality(dumm_ds)

Output:
<tf.Tensor: shape=(), dtype=int64, numpy=-2>
where, ‘-2’ mean UNKNOWN_CARDINALITY.
I would like to know whether this is a bug or not? and If not then, how can I change the cardinality?

Context:
Check

    TypeError: dataset length is unknown tensorflow General Discussion

    Just to extend the official example in the documentation
import tensorflow as tf
def gen():
  ragged_tensor = tf.ragged.constant([[1, 2], [3]])
  yield 42, ragged_tensor

dataset = tf.data.Dataset.from_generator(
     gen,
     output_signature=(
         tf.TensorSpec(shape=(), dtype=tf.int32),
         tf.RaggedTensorSpec(shape=(2, None), dtype=tf.int32)))
print(dataset.cardinality())

You will see that cardinality is -2 that is tf.data.experimental.UNKNOWN_CARDINALITY.
So it can’t quickly e…


TensorFlow.js announces new model: MoveNet - super fast, and accurate pose estimation

Question:
Yep, the holiday season came early for TensorFlow.js devs with this new model from a collaboration with Google Research that have created a super fast native TensorFlow.js model (like 120 FPS fast on my modern desktop at peak) for body pose estimation that runs in your web browser. What will you make?

810×480

I am sure you want to try it out and learn more so without further ado here is what you need to know:

Read more and learn about MoveNet: Next-Generation Pose Detection with MoveNet and TensorFlow.js — The TensorFlow Blog 65

Try the demo: https://storage.googleapis.com/tfjs-models/demos/pose-detection/index.html?model=movenet 51

Try the first community made demo that uses movenet already in a game - just 2 days after launch - amazing! You will have a lot of fun with this one:  https://twitter.com/devdevcharlie/status/1395102385387843584 46

Context: Does this model can be used in nodejs and how ?


Date Parsing as a Model Layer in Tensorflow-Keras

Question:
Basically, training my model after some feature engineering from the raw data. The feature engineering includes converting an Order_date column (from a pandas dataframe having dtype: Object) to four separate features, i.e. date in month, month, year and weekday. See the following screenshot.

It is a simple task using pandas functionalities, but recently, I read from some keras and tensorflow documentation that the best models are end to end, i.e. take the raw data, then implement all feature engineering as layers before the neural network. So trying to adhere to that philosophy, but being somewhat noob in tensorflow api, not sure if this is possible here. I also looked up the tf.data pipelines and methods available tf.feature_column, but seems they do not fit my use case. So any help regarding the cleanest way to achieve it while sticking with tensorflow layer philosophy?
I can potentially use a custom layer subclassing from the base layer class which takes a batch of yyyy-mm-dd strings and spits out the four features as output, using pandas timestamp (which I want to avoid) and actually have not implemented that yet. There should still be a cleaner way using tf APIs.

Context:
I think you want something like the second bullet point in:

      github.com/tensorflow/transform

      Transforming date values 11

        opened

        Apr 23, 2019

          Malonl

        stat:awaiting tensorflower
        type:feature

    Hi.

I have a use case where I want to use date features as input values for a… predictive model. I need to transform the date features to be useful.

Examples I would like to be able to do:
- Given two date columns, generate a new column with the difference between them in days. The days can be days, weeks, or even years apart
- From a column with dates, create three different columns with extracted data, one for day, one for month, one for year

If we could use some python library (datetime for example), it would be trivial. Without the library, we would need to implement the knowledge about the calendar (number of days in each month etc)
I believe we cannot use a conventional python library because if we use it, the transformation would not be written to the graph, and thus we would not be able to have it at serving time.

My question is if it is possible to do this within TF Transform and if not, is this a feature that is coming up?
If there is no way such operations to the graph, we would need to implement a piece of pipeline transforming the data both before training and before serving, outside of the graph.

Thanks in advance!

PS: For transparancy, I have asked this question on [tensorflow/tensorflow](https://github.com/tensorflow/tensorflow/issues/27893#issuecomment-484983991) and [tensorflow/tfx](https://github.com/tensorflow/tfx/issues/41#issuecomment-485289180) as well, but have been redirected to this forum.


AttributeError: ‘tensorflow.python.framework.ops.EagerTensor’ object has no attribute ‘_keras_history’

Question:
Hi everyone,
I’m trying to implement a simple feed-forward neural network with a modification based on this paper arxiv:2007.11207 2 (See figure 3b).
Basically the inputs (x) are scaled by a vector, e.g.,  (1,2,3) producing new inputs (1x, 2x, 3x). These are then passed into 3 sub-networks that are independent of each other. The outputs of these networks are then summed together at the end to produce an output.
I have the following TF2 code below but when I try to plot the model using tf.keras.utils.plot_model(model) I get the following error.
AttributeError: 'tensorflow.python.framework.ops.EagerTensor' object has no attribute '_keras_history'

The code I am using to build the model is:
(for simplicity the sub-networks just have a single layer)
import tensorflow as tf

def build_model():
    input_shape = 1
    output_shape = 1
    units = 128
    scales = tf.convert_to_tensor([[1],[2],[3]], dtype=tf.float32)

    input_layer = tf.keras.Input(shape=(input_shape,))

    # create sub-networks
    xs = []
    for scale in scales:
        scaled_input = tf.keras.layers.multiply([input_layer, scale])
        xs.append(tf.keras.layers.Dense(units, activation='relu')(scaled_input))

    # add the outputs of each sub-network
    output_layer = tf.keras.layers.add([x for x in xs])
    output_layer = tf.keras.layers.Dense(output_shape, activation="linear")(output_layer)

    model = tf.keras.models.Model(inputs=input_layer, outputs=output_layer)

    return model

model = build_model()

# then the following throws the error.
tf.keras.utils.plot_model(model)

Thanks in advance for any help!

Context:
Hi all,
I think I managed to track down the problem to this line:
scaled_input = tf.keras.layers.multiply([input_layer, scale])

TF2 doesn’t like this multiplication. Is it because scale is not a layer?
I guess to fix this I could make a new layer or use a Lambda layer that does the multiplication between the inputs and a scalar.
Thanks!


Pruning a trained Object Detection SavedModel

Question:
Hello,
I was wondering if it is possible in any way to perform optimizations, such as pruning, on a trained TF2 Object-Detection SavedModel?
Thanks,
Ahmad

Context: It’s not easy to apply pruning in PTQ fashion, so I’d say pruning should be there from the training phase.


Question:
getting started. so all the niave questions come out.
Can I embed TF in my C program using the C API and not have to deal with Python at all?

Context:
The C API is very minimal:

      TensorFlow

Install TensorFlow for C 4

What is your use case?


Question:
Let’s say I have an array (final) of shape (2048, 128). I have got another array called indices of shape (2048, 1).
If I wanted to scatter a value of 1 in final w.r.t indices, how will I do that?
What I have tried:
indices = tf.constant(np.random.randint(1000, size=(2048, 1)))
output = tf.scatter_nd(indices, 1, [2048, 128])

Results into:
InvalidArgumentError: Updates shape must have rank at least one. Found:[] [Op:ScatterNd]

What is the recommended solution?

Context:
Oh, I guess I can just do:
indices = tf.constant(np.random.randint(1000, size=(2048, 1)))
output = tf.one_hot(indices, 128)


TFDF Custom metrics logging during training

Question:
How to log AUC score/ custom metrics at every tree? I tried with:
model = tfdf.keras.GradientBoostedTreesModel(num_trees=3000,features=all_features, exclude_non_specified_features=True,
                                    early_stopping_num_trees_look_ahead=30, task=tfdf.keras.Task.CLASSIFICATION,
                                    verbose=True, apply_link_function=False)

model.compile(metrics=tf.keras.metrics.AUC())

Though, when calling model.make_inspector().training_logs(), only loss and accuracy are logged (for classification task).

Context:
Maybe try passing it as a list
metrics=[tf.keras.metrics.AUC()]


How to converting tflite model output float aray to text- Text Recognition

Question:
I am working on a text recognition app from images.for that  i am using a ‘tflite’ model(lite-model_east-text-detector_dr_1.tflite). After processing the input image I got a Tensor buffer that contains a float array.
How can I convert this output float array to text?
Is there any better ‘tflite’ model for text recognition from images?

Context:
Hi @Nison_Sunny ,
This float array indicates the position of inputs in a text file. Check the project you have for .txt file. Inside there you will see an input for every position.
Check this project at specific line 15
Regards


Question: Please help me to convert .pb file to .tflite format. I can’t convert again after new update in TensorFlow

Context: Some more info? Version of TensorFlow that conversion worked and code snippet?


Question:
Hi everybody,
I’d like to discuss the correctness of the ResNet and ResNetV2 implementations, recently
I noticed a few flaws in the Keras applications implementation, starting with this. Now I want to discuss the identity mappings, it seems like they make a huge difference, according to the ResnetV2 paper.
The way ResNetV1 is implemented, the skip connections are not Identity at all, there are BN and activations in the way, which defeats the idea in which ResNets were designed.
ResNetV2 tries to correct those issues, but I still see some MaxPooling layers in the skip connections.
I have compared my results training a binary classifier with ResNetV1, ResNetV2 and a modified ResNetV1 with all identity mappings. The modified ResNetV1 is providing me the best results. My dataset contains images with a high number of channels, which impedes the usage of Imagenet weights.
See results here (scroll image to the right to see ResnetV2): ResNet_test/networks_precision_recall.png at main · ririya/ResNet_test · GitHub 2

Context: Sorry all, my current forum member level does not allow me to embed pictures and only allows me to share two urls, that’s why I had to create a single image.


Question:
I’m trying to deploy my image classification model on streamlit but I encounter this warning message when I trying to make inferences using the app.

image949×157 62.3 KB

image943×144 63 KB

Context:
The first image is just showing information about your platform. You can pretty much safely ignore them.
About the second image…Your inference function is a tf.function which constructs, optimizes, and compiles a static graph at runtime (by “tracing” the annotated function, outside the scope of this answer).  The warning is telling you that each call to your predict function has to reconstruct, optimize, and compile a new graph. That ends up being really expensive, and you miss out on the performance benefits of tf.function.
To break it down, here’s what it’s telling you could be happening:

creating @tf.function repeatedly in a loop

while True:
  my_predict_function = lambda x: x * x
  my_tf_predict_function = tf.function(func=my_predict_function) # uh oh, this gets called every loop iteration
  my_tf_predict_function(tf.random.uniform((2, 2)))

If you’re not defining / redefining your model or predict function in a loop, this is unlikely to be the case.

passing tensors with different shapes

my_predict_function = lambda x: x * x
my_tf_predict_function = tf.function(func=my_predict_function)
my_tf_predict_function(tf.random.uniform((2, 2)))
my_tf_predict_function(tf.random.uniform((3, 2))) # different shapes, our graph was previously optimized on a shape of (2, 2)

If you’re passing images of different dimensions, this is likely the case.

passing Python objects instead of tensors

my_predict_function = lambda x, flag: x * x if flag else x
my_tf_predict_function = tf.function(func=my_predict_function)
input = tf.random.uniform((2, 2))
my_tf_predict_function(input, True) # the graph compiled is x * x
my_tf_predict_function(input, False) # we have to recompile because it takes a different path based on flag!

Notice how the graph changes based on flag which is a Python object and not a tensor. So even though the shapes are the same, the graph is different. If you control your model with some hyperparameters which are Python scalars or other Python objects, then it will need to recompile the graph every time you change a parameter.


Generating Embeddings from One hot vectors

Question: Are there any ways get embeddings from one-hot vectors ? As far as I know, embedding layers only accept integer tokens. But, is there a way to input one-hot vectors and get embeddings ?

Context:
Is there a reason you need to use one-hot vectors? If there’s no explicit constraint, you can just convert the vectors to integer tokens:
import tensorflow as tf
from tensorflow.keras import backend as K

# Create random integer tensor, 128 tokens with vocab size of 100
integer_embed = tf.random.uniform((32, 128), minval=0, maxval=100, dtype=tf.int64)
# Create one-hot encoding
one_hot = tf.keras.utils.to_categorical(integer_embed)

model = tf.keras.layers.Embedding(100, 32, input_shape=(128,))
model(K.argmax(one_hot, axis=-1))

If you do have a constraint, here’s an example One-Hot Embedding using Layer subclassing (from: Is there anyway to pass one-hot binary vector as input and embed it? · Issue #2505 · keras-team/keras · GitHub 1):
class OnehotEmbedding(tf.keras.layers.Layer):
    def __init__(self, Nembeddings, **kwargs):
        self.Nembeddings = Nembeddings
        super(OnehotEmbedding, self).__init__(**kwargs)

    def build(self, input_shape):
        # Create a trainable weight variable for this layer.
        self.kernel = self.add_weight(name='kernel',
                                      shape=(input_shape[2], self.Nembeddings),
                                      initializer='uniform',
                                      trainable=True)
        super(OnehotEmbedding, self).build(input_shape)  # Be sure to call this at the end

    def call(self, x):
        return K.dot(x, self.kernel)

    def compute_output_shape(self, input_shape):
        return (input_shape[0], input_shape[1], self.Nembeddings)

model = OnehotEmbedding(32, input_shape=(32, 100, 128))
model(one_hot)


Question:
I was trying to implement YOLO with 5 anchor boxes. I wanted to use keras.backend.max as described here 1 but it’s not functioning properly or I am misunderstanding it.
The code looks something like this:
`
   from keras import backend as K

   with tf.compat.v1.Session() as test_a:
    example =  tf.random.normal([4, 4, 2, 2], mean=1, stddev=4, seed = 1)
    print(example.eval())
    # test = K.argmax(example, axis=-1)
    # print(test.eval())
    another_test = K.max(example, axis = -1)
    print(another_test.eval())
`

The output is this:
`
  [[[[-2.2452729   6.938395  ]
   [ 1.2613175  -8.770817  ]]

  [[ 1.3969936   3.3648973 ]
   [ 3.3712919  -7.4917183 ]]

  [[-1.8915889   0.7749185 ]
  [ 3.5741792  -0.05729628]]

  [[ 8.426533    3.2713668 ]
   [-0.5313436  -4.9413733 ]]]

 [[[ 6.0470843   0.8987757 ]
   [-0.05851877  7.131255  ]]

  [[-5.9719086  -0.7515718 ]
   [-1.26404     2.2826772 ]]

  [[ 5.531324   -8.113029  ]
    [ 2.9312482  -4.250835  ]]

  [[ 2.4274013  -5.9211335 ]
    [ 0.83932906  4.5986476 ]]]

 [[[-4.5223565   6.9258494 ]
   [ 0.01802081 -1.9305887 ]]

  [[ 0.21641421  1.2868321 ]
   [ 3.5319235  -5.284763  ]]

  [[ 6.317525   -3.693468  ]
   [ 1.1261784   2.9082098 ]]

  [[ 2.747768   -0.26723564]
   [-0.8030013  -6.2242627 ]]]

 [[[ 1.4995985  -2.0826168 ]
   [-1.9849663  -0.12781298]]

  [[-6.835262   -0.35044277]
   [ 5.1207933   7.053607  ]]

  [[ 1.9006321  -0.14264834]
   [ 2.0753016   7.984844  ]]

  [[ 4.695484   -7.2363987 ]
   [-0.25753224  5.841353  ]]]]
[[[-0.0205164   5.3679433 ]
  [ 3.9440122   4.684675  ]
  [ 4.1706614   1.3993862 ]
  [ 9.333472    3.0931065 ]]

 [[ 6.7779894   5.3317556 ]
  [-3.0122952  -1.5482914 ]
  [-0.5402719  -5.03914   ]
  [ 3.0354424   2.9042442 ]]

 [[ 4.730604    2.9970727 ]
  [ 3.8026135   0.04406112]
  [ 5.1083784   9.928441  ]
  [-1.8228705   1.4313807 ]]

 [[ 7.075215   -4.0160027 ]
  [ 2.046008    0.94906276]
  [ 0.6468721   1.6242697 ]
  [-0.2219665   5.4110713 ]]] `

As far as I can comprehend it should return the max value but what is it returning?

Context:
First thing to point out: while I’m not as well-versed in TF 1, I believe your example will end up evaluating the maximum of a completely different random tensor then the one you inspect because eval runs a the graph in a different session each time, e.g. tf.random.normal will get called again to evaluate the max. So (I think) you won’t be able to follow the results by inspecting them in this way.
Otherwise, this is the basically the result you should expect. keras.backend.max will return the maximum value along a specified axis/axes, effectively reducing the dimension away. Your examples starts by printing a (4, 4, 2, 2) tensor. After the call to keras.backend.max, with axis=-1 (which wraps to the last axis in the tensor), the result is a tensor with shape (4, 4, 2). That’s because you’re telling the function to “walk” the last axis and find the maximum value of the If you want the absolute maximum value of the entire tensor, axis should be set to None.
Here are some answers that demonstrate keras.backend.max with different axis arguments, and one with keepdims set to True:
with tf.compat.v1.Session() as test_a:
  example = tf.random.normal([4, 4, 2, 2], mean=1, stddev=4, seed = 1)
  # Print absolute maximum value (shape: ())
  abs_max = K.max(example, axis=None)
  print(abs_max.shape)

  # Print maximum values along axis 0, 2 (shape: (4, 2))
  max_axis_0_2 = K.max(example, axis=(0, 2,))
  print(max_axis_0_2.shape)

  # Print maximum values along axis 1 (shape: (4, 2, 2))
  max_axis_1 = K.max(example, axis=(1,))
  print(max_axis_1.shape)

  # Print maximum values along axis 0, 2, and keep reduced axes
  # reduced axes will be size 1
  max_axis_0_2_keep = K.max(example, axis=(0, 2,), keepdims=True)
  print(max_axis_0_2_keep.shape)


Help! I dont understand “input_shape” more

Question:
Hey there,
maybe some of you can help me to drop me off from misunderstanding list of input_shape.
I am using dataset to gen data.
The window is 10, and I divide x with size 5 and y with size 5.
Then the dataset will go ahead to the model, I just work with a simple Sequential one and give input_shape (3,1) to to first layer, fe. lstm.
I can fit the model.
I predict  random values from (1, 1) as input_shape to (10, 1) as input_shape.
So what does input_shape mean actually? I lost it so deeply…
Full code:
import numpy as np
import tensorflow as tf

data = np.random.randn(5000)
data = data[...,np.newaxis]

sp = int(len(data) * .5)
train_data = data[:sp]
valid_data = data[sp:]

def windowed_set(data):
  win_sz=10
  ds = tf.data.Dataset.from_tensor_slices(data)
  ds = ds.window(size=win_sz, shift=1, drop_remainder=True).flat_map(lambda w: w.batch(win_sz))
  ds = ds.shuffle(win_sz).map(lambda w: (w[:int(win_sz*0.5)], w[int(win_sz*0.5):]))
  ds = ds.batch(32).prefetch(1)
  return ds

train_set  = windowed_set(train_data)
valid_set = windowed_set(valid_data)

#Model definition
model = tf.keras.models.Sequential([
   tf.keras.layers.LSTM(32,
                        input_shape=[3, 1],
                        return_sequences=True),
   tf.keras.layers.Dense(1)
])

model.summary()
model.compile(loss=tf.keras.losses.Huber(),
              optimizer=tf.keras.optimizers.Adam())

#Training
model.fit(train_set,
          validation_data=valid_set,
          epochs=50,
          verbose=0)

#Prediction
for i in range(1, 11):
  print(f"prediction {i} bit:")
  pred_input = np.random.rand(i)
  pred_input = np.expand_dims(pred_input, axis=-1)
  print(pred_input.shape)
  pred = model.predict(np.reshape(pred_input, (1,) + pred_input.shape))
  print(pred)
  print()

Context:
Input shape is the dimension of the input data, for example in case you have image data a Keras model needs an input_shape of (height, width, num_channels) , if you are feeding a model with an input of (3, 1) the model will learn dependences of three consecutive elements. larger the window more information the model considers about the temporal dependences of observations in the sequence.
Sometimes you can have dynamic input shapes ex, images with variable height/width.  You can check more details here tf.keras.Input  |  TensorFlow Core v2.5.0 2


How to create dataset with real and virtual image

Question:
Hello.
I want to use Tensor Flow to classify parts using a camera.
So to create my dataset, to teach the CNN, I want to use 3D image.
I use a 3D generator to create image of all parts in many position. Taking pictures of all the parts in many position, that I want to classify is not possible because I have lot of differents parts.
My problem is when I use my CNN with real image, it did classify my parts.
What is the best way to classify real image with “virtual” image ?
I found lot of article, that explain the theory. I look for article about real exemple, and / or sample code.
Thanks for help.

Context:
To explore more in depth all the domain adaptation issues I suggest to take a look at:

      arXiv.org

Synthetic Data for Deep Learning 2

  Synthetic data is an increasingly popular tool for training deep learning
models, especially in computer vision but also in other areas. In this work, we
attempt to provide a comprehensive survey of the various directions in the
development and...

      arXiv.org

Unsupervised Domain Adaptation of Object Detectors: A Survey 1

  Recent advances in deep learning have led to the development of accurate and
efficient models for various computer vision applications such as
classification, segmentation, and detection. However, learning highly accurate
models relies on the...

Also if It Is a little bit old, if you want some reference implementations, check the sim2real challenge leaderboard:

      paperswithcode.com

Papers with Code - Syn2Real-C Benchmark (Synthetic-to-Real Translation) 1

  The current state-of-the-art on Syn2Real-C is DADA. See a full comparison of 6 papers with code.


TypeError(“dataset length is unknown.”) while reading tfrecord

Question:
Trying to read the tfrecord file and use it to train the model with .fit call but getting this error:
TypeError("dataset length is unknown.")

Here’s my tfrecord code:
FEATURE_DESCRIPTION = {
    'lr': tf.io.FixedLenFeature([], tf.string),
    'hr': tf.io.FixedLenFeature([], tf.string),
}

def parser(example_proto):
    parsed_example = tf.io.parse_single_example(example_proto, FEATURE_DESCRIPTION)
    lr = tf.io.decode_jpeg(parsed_example['lr'])
    hr = tf.io.decode_jpeg(parsed_example['hr'])
    return lr, hr

train_data = tf.data.TFRecordDataset(TFRECORD_PATH)\
                    .map(parser)\
                    .batch(BATCH_SIZE, drop_remainder = True)\
                    .prefetch(tf.data.AUTOTUNE)

And len(train_data) is giving error TypeError("dataset length is unknown.") because the cardinality is -2, or in other words the train_data is unable to capture the total number of samples because the dataset source is a file.
Is there any way we can tell the train_data how many samples/batches are there?

Context:
Check this thread:
https://discuss.tensorflow.org/t/typeerror-dataset-length-is-unknown-tensorflow/


Want to use TensorflowJS, Posenet in a React Native application

Question:
Hey there!
I want to achieve human pose estimation inside a react Native App but I can’t find any docs or resources on how to do it.
I know from this blog TensorFlow.js for React Native is here! — The TensorFlow Blog 35 that Tensorflow.js integration with React Native is possible and blog explains how to add " tensorflow-models/mobilenet" in a React Native app but I want to utilize tensorflow’s posenet model.
I was able to install the necessary dependencies for Tensorflow.js,  following the same blog and set up the development environment successfully.
I want to achieve something similar to what is showcased in the beginning of this blog.
I also found some example of posenet with  React that run on browser but nothing related to building an android app using React Native.
I am new to both Tensorflow and React native so I was hoping if anyone could provide my some docs or instructions specific to the integration of posenet model and tensorflow.js into a React Native app.

Context:
You may find this tutorial/write up useful:

      Medium – 13 May 20

Image Classification on React Native with TensorFlow.js and MobileNet 108

  Real-time, on-device image classification in a React Native app.

    Reading time: 7 min read


Functional and object-oriented models are not equivalent

Question:
I don’t quite understand why these two models defined with functional API:
inp = layers.Input((10,2))
x = layers.Flatten()(inp)
x = layers.Dense(5)(x)
m1 = keras.models.Model(inputs=inp, outputs=x)

and OO way:
class MyModel(tf.keras.Model):
    def __init__(self, inp_shape, out_size = 5):
        super(MyModel, self).__init__()
        self.inp = layers.InputLayer(input_shape=inp_shape)
        self.flatten = layers.Flatten()
        self.dense = layers.Dense(out_size)

    def call(self, a):
        x = self.inp(a)
        x = self.flatten(x)
        x = self.dense(x)
        return x
m2 = MyModel((10,2))
m2.build(input_shape = (10,2))

give different results:
> m1.summary()
Model: "functional_3"
_________________________________________________________________
Layer (type)                 Output Shape              Param #
=================================================================
input_17 (InputLayer)        [(None, 10, 2)]           0
_________________________________________________________________
flatten_19 (Flatten)         (None, 20)                0
_________________________________________________________________
dense_18 (Dense)             (None, 5)                 105
=================================================================
Total params: 105
Trainable params: 105
Non-trainable params: 0

> m2.summary()
Model: "my_model_9"
_________________________________________________________________
Layer (type)                 Output Shape              Param #
=================================================================
input_18 (InputLayer)        [(None, 10, 2)]           0
_________________________________________________________________
flatten_20 (Flatten)         multiple                  0
_________________________________________________________________
dense_19 (Dense)             multiple                  15
=================================================================
Total params: 15
Trainable params: 15
Non-trainable params: 0

When I test it with on some toy tensor, I get:
> tsta = np.random.randn(3,10,2)
> m1(tsta) # correct
> m2(tsta)
InvalidArgumentError: Matrix size-incompatible: In[0]: [3,20], In[1]: [2,5] [Op:MatMul]

What I want to achieve is to have exactly the same model as m1 but with subclassed API.

Context:
You could try my example:
import tensorflow as tf

tsta = tf.random.uniform([3,10,2])
tf.random.set_seed(111111)
inp = tf.keras.layers.Input((10,2))
x = tf.keras.layers.Flatten()(inp)
x = tf.keras.layers.Dense(5)(x)
m1 = tf.keras.Model(inputs=inp, outputs=x)
m1.build(input_shape = (3, 10, 2))
m1.summary()
print(m1(tsta))

tf.random.set_seed(111111)
class MyModel(tf.keras.Model):
   def __init__(self, out_size = 5):
       super(MyModel, self).__init__()
       self.flatten = tf.keras.layers.Flatten()
       self.dense = tf.keras.layers.Dense(out_size)

   def call(self, x):
       x = self.flatten(x)
       x = self.dense(x)
       return x
m2 = MyModel()
m2.build(input_shape = (3, 10, 2))
m2.summary()
print(m2(tsta))


Question:
Hey there,
I’ve created a simple model on teachablemachine. Could you please tell me how I can now loop this model so that I can upload a catalog of images into it and, at the exit, get a file for a spreadsheet where the results for each image will be.

      teachablemachine.withgoogle.com

Teachable Machine 2

  Train a computer to recognize your own images, sounds, & poses.
        A fast, easy way to create machine learning models for your sites, apps, and more – no expertise or coding required.

Thank you!

Context:
Hi @Yan_Mednis
Since you have it on a TFJS format, I think you might be able to do the loop using Javascript.
Do you want to just upload this batch of images from the catalogue or is it a service you are building?
for the output, I’d focus on generating a CSV with the data and then import it on Sheets, might be easier than using the Sheets api (if you don’t know that yet)
@Jason might have some much better insights than mine on this.


Question: Can anyone suggest a good example for one shot learning model ?

Context:
This will give you a good overview of the topic in different domains:

      arXiv.org

Generalizing from a Few Examples: A Survey on Few-Shot Learning 9

  Machine learning has been highly successful in data-intensive applications
but is often hampered when the data set is small. Recently, Few-Shot Learning
(FSL) is proposed to tackle this problem. Using prior knowledge, FSL can
rapidly generalize to...

Then probably you could find something more specific for your application target.