Skip to content

NEW! Windows 10 support for TPU

wb666greene edited this page Jul 7, 2020 · 3 revisions

Instructions for setting up Windows for TPU AI on Windows 10

Google only officially supports the TPU on Windows 10. Using it on an IOT class Linux box is preferred, but this is a way to try it.

  1. Download python from: https://www.python.org/downloads/windows/ Only 3.5, 3.6, and 3.7 are supported by the Google Coral TPU code. Run the downloaded python-*-amd64.exe to install Python (includes Idle & pip). I used python-3.7.1-amd64.exe

  2. Open a command window and run: pip install opencv-contrib-python requests pillow imutils paho-mqtt This installs the extra python modules that I used.

  3. Download mosquitto MQTT broker. I used the "quick install" from: http://www.steves-internet-guide.com/install-mosquitto-broker/ Basically just unzip the download and copy the mosquitto folder to a suitable place to install MQTT broker.

    • Start cmd window:

      cd to the mosquitto folder location and run:

      mosquitto

    • Ctrl-C to stop the broker.

    • Automatically starting it is beyond my Windows pay grade. But the steves-internet-guide site has instructions. I used v1.5.4, but v1.5.8 is current now.

  4. Download node js from: https://nodejs.org/en/download/ Run the downloaded node-*-x86.msi file to install nodejs and npm. Version node-v12.18.2-x86.msi was current when I installed on Win10.

    • If you just want to run the AI and look at detected images later, you can skip this step and the one below, start TPU.py with the --localSave command line option.
  5. Install node-red.

    • Open a command window and run:

      npm install node-onvif (only needed if you want to try my onvif_discover.js program to find camera snapshot URLS)

      npm install --global --production windows-build-tools (optional, I didn't do it)

      npm install -g --unsafe-perm node-red

    • Start node-red from the same command window with:

      node-red

    • Close the command windwow to exit node-red, this creates the .node-red directory.

    • Install a nodejs package that I use in a function node:

      cd .node-red

      npm install point-in-polygon

    • Edit: .node-red/settings.js to functionGlobalContext: {} add:

      insidePolygon:require('point-in-polygon')

    • Start node-red again from a new command window with:

      node-red

    • Open Chrome or Chromium (Edge probably works too) browser tab and connect to: http://localhost/1880

      1. From the "hamburger" menu dropdown choose: Manage Pallet
      2. Click the "Install" tab
      3. In the search modules box, enter
        • node-red-node-base64 and click the install button that pops up
        • node-red-dashboard and click the install on the one that exactly matches the search string
        • node-red-node-email and click the install on the one that exactly matches the search string
      4. Open the Win10_AI_Controller.json file from the AI distribution in your text editor and copy the contents to the clipboard
      5. From the node-red menu choose: Import
        • paste the clipboard into the dialog that pops up
        • press the Import to "current flow" button
        • press the red Import button
        • position the graphics and and click, then press the red Deploy button next to the menu
        • if you get "successfully deployed" there is still configuration to be done, but it should be a starting point.
      6. Open a new browser tab and connect to: http: localhost:1880/ui This views the "dashboard" which does the basic functions like setting the notification mode, viewing a camera, etc. But nothing will work yet until the AI code is started.
  6. Install the Google Coral TPU drivers and python interface.

At this point TPU.py should be ready to go after you've created the cameraURL.txt file for your camera snapshot URLs or a cameraURL.rtsp for RTSP camera streams.

Simply open a command window, cd to the AI directory and run:

python TPU.py

Some performance tests with Windows 10 running on an i3-4025U

  • 5 Onvif 720p cams : ~32.9 fps, probably limited by the rate Onvif snapshots can be had by HTTP requests.
  • 4 RTSP HD (1080p) : ~11.8 fps, rtsp streams from the DVR are set for 3 fps each.
  • 4 RTSP UHD (4K) : ~12.4 fps, rtsp streams from 4K DVR are set for 3 fps each.
  • 5 Onvif, 4 HD (1080p) : ~28.1 fps.
  • 4 HD and 4 UHD : ~15.7 fps, this is clearly overloaded.
  • 8 HD rtsp streams : ~23.9 fps, basically every frame, much better with HD than UHD streams.

More info about node-red on Windows is here:

If not familar with using node-red, start here:

Being a "graphical programming environment" its a bit hard to describe using only text. Another good set of tutorials, especially to help understand the "dashboard" is:

If you learn by watching videos this is a good place to start:

I gave up on Windows when Win8 came out, so you are on your own for the usability features like automatically starting the whole shebang on boot, purging AI detection images older than a certain date, integrating with your home automation system, etc.

If you've made everything automatically start on boot, please contribute the instructions to this Wiki!