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?


  • jordimassaguerpla
    5 months 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
    5 months 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/mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite --labels models/inat_bird_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
    5 months 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
    5 months 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

Packaging libnvidia-containers and nvidia-container-runtime-hook by jordimassaguerpla

This is a follow up to

Finish Machine Learning introductory course by dmacvicar

I started [Standford's machine learning course]...

Artificial Intelligence playground for Data Scientist by afesta

Project here:

libuitest - a generic GUI testing library by dancermak

Testing GUIs is hard: unit tests require a ...