For my 40th birthday I got from my friends a very special present, an USB Accelerator that brings machine learning inferencing to existing systems:

From its website:

The on-board Edge TPU coprocessor is capable of performing 4 trillion operations (tera-operations) per second (TOPS), using 0.5 watts for each TOPS (2 TOPS per watt). For example, it can execute state-of-the-art mobile vision models such as MobileNet v2 at 400 FPS, in a power efficient manner. See more performance benchmarks.

So I am going to connect this through the USB port to my NAS system:

Then, using the container station:

I will install this container:

So that I will have a jupyter notebook available to run on the TPU this Machine Learning algorithm:

From its webpage:

Simply put, the mission of this project is to colorize and restore old images and film footage.

And finally, I have some old photos from "la Selva del Camp" that I would like to colorify.

Sounds fun, doesn't it?

Looking for hackers with the skills:


This project is part of:

Hack Week 19


  • over 4 years ago: jordimassaguerpla started this project.
  • over 4 years ago: jordimassaguerpla added keyword "machinelearning" to this project.
  • over 4 years ago: jordimassaguerpla originated this project.

  • Comments

    • jordimassaguerpla
      over 4 years ago by jordimassaguerpla | Reply

      How to run the container:

      docker run -d --privileged -p 2222:22 -p 3333:8080 -p 4444:8888 -e PASSWORD=secret --restart unless-stopped -v /dev/bus/usb:/dev/bus/usb lemariva/raspbian-edgetpu

    • jordimassaguerpla
      over 4 years ago by jordimassaguerpla | Reply

      How to test it works

      ssh -p 2222 root@NAS password: root mkdir tmp cd tmp && git clone cd tflite/python/examples/classification ./ python3 --model models/mobilenetv21.0224inatbirdquantedgetpu.tflite --labels models/inatbird_labels.txt --input images/parrot.jpg

      And you should see

      INFO: Initialized TensorFlow Lite runtime.

      Otherwise, if you see

      ValueError: Failed to load delegate from

      Means the USB is either not connected or not detected.

    • jordimassaguerpla
      over 4 years ago by jordimassaguerpla | Reply

      Next step, connect to the jupyter notebook at:

      then, as a test, I uploaded the classification files and created a new jupyter notebook based on the classify_image example.

    • jordimassaguerpla
      over 4 years ago by jordimassaguerpla | Reply

      After a day compiling python native extensions for arm or PyTorch and other math python extensions, cause the NAS has an arm processor, I was able to have all dependencies installed and try to run the ImageColorizer notebook.

      Unfortunately, I got this error message

      RuntimeError: [enforce fail at CPUAllocator.cpp:64] . DefaultCPUAllocator: can't allocate memory: you tried to allocate 37632 bytes. Error code 12 (Cannot allocate memory)

      So, not enough memory in my NAS to run this algorithm :(

      I also suspect that PyTorch is not using the TPU, as the TPU works with tensorflow lite libraries...

      Thus, I will try to run this algorithm on a workstation with an nvidia card ... and for this project... we can considered it done :(

    Similar Projects

    AI frontend to Bugzilla by paolodepa

    Project Description

    Over the years, our b...