Applications


Installing TensorFlow 2 Object detection on Ubuntu 18.04 LTS 1

Following are some rough notes on Installing TensorFlow 2 Object detection on Ubuntu 18.04 LTS.
We were following this guide (https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html) so we will be skipping some steps.

We had conda installed already from an older attempt so the following steps worked just fine.

conda create -n tensorflow pip python=3.8;
conda activate tensorflow;

We got an error with the following command so we used pip3 instead of pip.

pip install --ignore-installed --upgrade tensorflow==2.2.0;
Command 'pip' not found, but there are 18 similar ones.
pip3 install --ignore-installed --upgrade tensorflow==2.2.0;

Executing the above gave us another error:

Collecting tensorflow==2.2.0
Could not find a version that satisfies the requirement tensorflow==2.2.0 (from versions: 0.12.1, 1.0.0, 1.0.1, 1.1.0rc0, 1.1.0rc1, 1.1.0rc2, 1.1.0, 1.2.0rc0, 1.2.0rc1, 1.2.0rc2, 1.2.0, 1.2.1, 1.3.0rc0, 1.3.0rc1, 1.3.0rc2, 1.3.0, 1.4.0rc0, 1.4.0rc1, 1.4.0, 1.4.1, 1.5.0rc0, 1.5.0rc1, 1.5.0, 1.5.1, 1.6.0rc0, 1.6.0rc1, 1.6.0, 1.7.0rc0, 1.7.0rc1, 1.7.0, 1.7.1, 1.8.0rc0, 1.8.0rc1, 1.8.0, 1.9.0rc0, 1.9.0rc1, 1.9.0rc2, 1.9.0, 1.10.0rc0, 1.10.0rc1, 1.10.0, 1.10.1, 1.11.0rc0, 1.11.0rc1, 1.11.0rc2, 1.11.0, 1.12.0rc0, 1.12.0rc1, 1.12.0rc2, 1.12.0, 1.12.2, 1.12.3, 1.13.0rc0, 1.13.0rc1, 1.13.0rc2, 1.13.1, 1.13.2, 1.14.0rc0, 1.14.0rc1, 1.14.0, 2.0.0a0, 2.0.0b0, 2.0.0b1)
No matching distribution found for tensorflow==2.2.0

To fix it we upgraded pip using the following command.

python3 -m pip install --upgrade pip;

Then we tried again, which installed most packets but gave a new error:

pip3 install --ignore-installed --upgrade tensorflow==2.2.0;
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
launchpadlib 1.10.6 requires testresources, which is not installed.
Successfully installed absl-py-0.11.0 astunparse-1.6.3 cachetools-4.2.1 certifi-2020.12.5 chardet-4.0.0 gast-0.3.3 google-auth-1.27.0 google-auth-oauthlib-0.4.2 google-pasta-0.2.0 grpcio-1.35.0 h5py-2.10.0 idna-2.10 importlib-metadata-3.4.0 keras-preprocessing-1.1.2 markdown-3.3.3 numpy-1.19.5 oauthlib-3.1.0 opt-einsum-3.3.0 protobuf-3.14.0 pyasn1-0.4.8 pyasn1-modules-0.2.8 requests-2.25.1 requests-oauthlib-1.3.0 rsa-4.7.1 scipy-1.4.1 setuptools-53.0.0 six-1.15.0 tensorboard-2.2.2 tensorboard-plugin-wit-1.8.0 tensorflow-2.2.0 tensorflow-estimator-2.2.0 termcolor-1.1.0 typing-extensions-3.7.4.3 urllib3-1.26.3 werkzeug-1.0.1 wheel-0.36.2 wrapt-1.12.1 zipp-3.4.0

To fix this error we used:

sudo apt install python3-testresources;

Then tried again the pip installation with success.

pip3 install --ignore-installed --upgrade tensorflow==2.2.0;
Successfully installed absl-py-0.11.0 astunparse-1.6.3 cachetools-4.2.1 certifi-2020.12.5 chardet-4.0.0 gast-0.3.3 google-auth-1.27.0 google-auth-oauthlib-0.4.2 google-pasta-0.2.0 grpcio-1.35.0 h5py-2.10.0 idna-2.10 importlib-metadata-3.4.0 keras-preprocessing-1.1.2 markdown-3.3.3 numpy-1.19.5 oauthlib-3.1.0 opt-einsum-3.3.0 protobuf-3.14.0 pyasn1-0.4.8 pyasn1-modules-0.2.8 requests-2.25.1 requests-oauthlib-1.3.0 rsa-4.7.1 scipy-1.4.1 setuptools-53.0.0 six-1.15.0 tensorboard-2.2.2 tensorboard-plugin-wit-1.8.0 tensorflow-2.2.0 tensorflow-estimator-2.2.0 termcolor-1.1.0 typing-extensions-3.7.4.3 urllib3-1.26.3 werkzeug-1.0.1 wheel-0.36.2 wrapt-1.12.1 zipp-3.4.0

We then executed the following to test the installation:

python3 -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))";

Then we proceeded to get the TensorFlow models:

mkdir ~/TensorFlow;
cd ~/TensorFlow;
git clone https://github.com/tensorflow/models;

We then downloaded protobufs and extracted them to our home directory.
To test the installation we did the following.

export PATH="/home/bob/protoc-3.14.0-linux-x86_64:$PATH";
cd /home/bob/TensorFlow/models/research;
protoc object_detection/protos/*.proto --python_out=.;

Then we proceeded to the COCO installation:

pip3 install cython;

The above will solve the problem of:

gcc: error: pycocotools/_mask.c: No such file or directory
cd ~;
git clone https://github.com/cocodataset/cocoapi.git;
cd cocoapi/PythonAPI;
make;
cp -r pycocotools ~/TensorFlow/models/research/;

Finally we proceeded to Install the Object Detection API.

cd ~/TensorFlow/models/research/;
cp object_detection/packages/tf2/setup.py .;
python3 -m pip install .;

To test the installation we executed the following:

python3 object_detection/builders/model_builder_tf2_test.py;

We then downloaded the samples and executed the camera sample with success!!

To check against a video instead of a camera, we changed the following line from:

cap = cv2.VideoCapture(0)

to

cap = cv2.VideoCapture('/home/bob/Desktop/a2/A01_20210210164306.mp4')

How to see the isc2.org Webex Online Instructor-Led courses using your browser only

Recently, we registered for some online instructor-led courses in isc2.org.
We were using a Ubuntu GNU/Linux machine with the latest Firefox / Chromium and even Chrome versions.
There was something wrong with the meeting. When clicking on the Join button, instead of loading, it was trying to download a java applet configuration (CiscoWebExServlet).
After reading about those files and a lot of work, which included setting up a 32-bit version of Firefox with a 32-bit version of the Oracle JRE and installing IcedTea, we managed to connect to the meeting, but we had no audio.

When trying to connect to the meeting via phone, we got no voice.

When trying the mobile application, it required a password, which was never supplied.

So, we had to find another way in!

Using the Network tab of the Inspect Element menu, we clicked on the gear in the upper right corner and enabled the Persist Log option. Then we clicked on the Join button and logged all redirects with their parameters.

In isc2.org virtual class, the Join button has a custom link to https://www.cirqlive.com/, which is used to join the meetings.
Once you click on that button, the browser follows several redirects between webex.com and cirqlive.com, and it ends up on this page https://isc2training.webex.com/tc3300/webcomponents/docshow/meetingframe.do?siteurl=isc2training asking to download the servlet.

From the logged redirects of the above link, we got the request to https://isc2training.webex.com/tc3300/m.do where we got the meeting ID and password in the POST parameters.
Then went to https://signin.webex.com/join added the meeting ID, which led us to this page https://isc2training.webex.com/isc2training/e.php?AT=SI&From=GPS&MK=XXXXXXXX (using fake meeting ID)
We filled in the Session Password and clicked on Join by browser, and we could join as expected.


Using Nomenclature in TeXstudio

Recently, we were compiling a Latex document that was using the nomencl package to create a nomenclature list. The tool that we were using was TeXstudio. We noticed that the nomenclature was not in the final document and no error was generated to indicate so.

To fix the issue, we had to manually execute the makeindex command which would create the necessary meta-files. To avoid using a terminal each time we wanted to update the nomenclature, we defined a custom command in TeXstudio which would make the process a bit more easy for us.

In the following video you will see the following steps:

  1. Going to Options menu.
  2. From there selecting the Configure TeXstudio option.
  3. From the popup window, we switched to the Build tab by clicking on the appropriate button on the left side column.
  4. In the group User Commands we clicke on the + Add button which created a new entry for us.
  5. In the new entry we filled:
    1. The menu name of the command: user0: Make Nomenclature
    2. The actual command to build the files needed for the nomenclature: makeindex -s nomencl.ist -t %.nlg -o %.nls %.nlo
  6. Then we clicked on the OK button to close that window.
  7. To test that the command works as expected, we went to the Tools menu.
  8. From there to the sub-menu named User, where we found our new command listed as 1: Make Nomenclature.
    This command produced all files necessary for the makenomenclature command to work.
  9. Finally, we clicked on the Build & View button to verify that everything is OK.

Cloudflare Origin Server Certificate for IIS 10 Server on Windows Server 2016 to allow Full (strict) mode SSL/TLS encryption mode 8

Create a Certificate Request from your Windows Server

  1. Open Internet Information Services (IIS) Manager from the Windows Server 2016 through Control Panel -> Administrative Tools
  2. Select your server from the Connections and open Server Certificates
  1. From the Server Certificates Actions select Create Certificate Request
  1. Fill in the following form with your details:
Common name: [your domain]
Organization: [your organization name]
etc.
  1. Set the settings for the Cryptographic service provider of the certificate, the bigger the length of the certificate the better the security but it makes the server slower.
  1. Specify the filename of the txt file where you will save the certificate request

Create the certificate from Cloudflare using your own certificate request that you created from your Windows Server

  1. Open your Cloudflare account, select your domain, open SSL/TLS tab and click on Origin Server in order to create the certificate
  1. Select the option ‘I have my own private key and CSR’ where you will Copy-Paste the certificate you saved on the txt file from your Windows Server, fill in the hostnames, select the expiration years and press Next
  1. Copy-Paste in PEM key format the certificate in a text file and save the file

Add the public certificate from Cloudflare at your Windows Server

  1. Copy the file with the PEM certificate from Cloudflare at your Windows Server
  2. Select ‘Complete Certificate Request’ from the IIS Manager Server Certificates Actions
  1. Select the PEM certificate you copied at the server and add a friendly name (e.g. the domain it covers and the expiration date of it):
  1. The certificate will appear at the list of the Server Certificates with the Friendly name you added at the form before

Import Cloudflare Origin CA root certificate at your Windows server

  1. Copy the Cloudflare Origin CA — RSA Root certificate from Cloudflare website, save to a file and transfer it to your Windows Server
  2. Open the Certificates Microsoft Management Console (MMC) snap-in by typing mmc.exe at the command prompt (or at the run dialog that you can open by pressing the buttons Win+R)
  3. On the File menu, select Add/Remove Snap-in
  1. In the Add or Remove Snap-ins dialog box, select Certificates snap-in in the Available snap-ins list, click Add, and then select OK
  1. In the Certificates snap-in dialog-box, select Computer account, and then select Next
  1. In the Select computer dialog box, click on Finish
  1. In the Add or Remove Snap-ins dialog box, select OK
  1. In the Certificates MMC snap-in, expand Certificates, right-click Intermediate Certification Authorities, point to All Tasks, and then select Import
  1. In the Certificate Import Wizard, select Next
  1. In the File to Import page, select the file with the Cloudflare origin CA root certificate you saved before, and then select Next
  1. Select Next at the Certificate Import Wizard
  1. Select Finish at the Certificate Import Wizard
  1. The certificate will appear at the Certificates list

Use the newly created server origin certificate from Cloudflare for your website

  1. Select Bindings from the IIS Manager Web Site Actions
  1. Select the https binding and click Edit. If you do not have an https binding, press Add... to create one like in the second screen down
  1. At the SSL certificate dropdown list Select the new certificate and press OK

Force your website domain to pass through Cloudflare

  1. Open your Cloudflare account, select your domain, go to DNS option and change the Proxy status for your website from DNS only to Proxied by click it
  1. Enable Cloudflare full (strict) SSL TLS encryption mode in the SSL/TLS tab