#Event – Webinar: Getting Started with ML.NET and Windows Machine Learning, Today with the GLUG .Net User Group

giphy-downsized

Hi !

Another virtual event about Windows ML and Machine Learning .Net, and this time with my good friends from Okemos, MI. The event will be

Getting Started with ML.NET and Windows Machine Learning

One more time, we have new features and improvements on the platform since the previous event, so it’s time for me to review and prepare new content. In example, use TensorFlow and ML.Net !!!

Description  

Machine Learning has moved out of the lab and into production systems. Understanding how to work with this technology is one of the essential skills for developers today. In this session, you will learn the basics of machine learning, how to use existing models and services in your apps, and how to get started with creating your own simple models.

In other words, if you are a .NET developer, this session is for you! We will cover the basics of ML.NET, a complete machine learning framework to work with C#, F# or any other .NET Core language.

Online Register https://www.meetup.com/GLUGnet/events/qkmgpkyzdbcc/

Happy Coding!

Greetings @ Burlington

El Bruno

Advertisements

#Event – Resources used on my session at the largest Canada makeathon: @MakeUofT [How a PoC at home can scale to Enterprise Level using #CustomVision APIs]

2019 02 16 MakeUofT Custom Vision Bruno

Hi !

What an amazing time at the Canadian Largest Makeathon: MakeUofT (https://ieee.utoronto.ca/makeuoft/). The event, people and ideas are great. And now it’s time to share some of the materials used during my session

How a PoC at home can scale to Enterprise Level using Custom Vision APIs

It all started with a DIY project to use Computer Vision for security cameras at home. A custom Machine Learning model is the core component used to analyze pictures to detect people, animals and more in a house environment. The AI processing is performed at the edge, in dedicated hardware and the collected information is stored in the cloud.

The same idea can be applied to several CCTV scenarios, like parking lots, train stations, malls and more. However, moving this into enterprise scale brings a set of challenges, which are going to be described and explained in this session.

These are the slides I’ve used

And the source code is available here

https://github.com/elbruno/events/tree/master/2019%2002%2016%20MakeUofT%20Custom%20Vision

In the source code you can find the console and Windows 10 app samples I’ve coded live and also the exported images of my custom vision demo project in windows, linux and raspberry pi flavors. The 3rd one is where I spent some time updating the original linux one to work on the small device.

And as usual a couple of interesting links

Greetings @ Toronto

El Bruno

#VS2019 – Visual Studio Launch event on the next April 2nd, 9:00am PT

 

visual studio 2019 launch event

Hi !

You may want to get your 2nd monitor ready on the next April 2nd, 9:00am PT, because is the official launch of Visual Studio 2019 !

Scott Hanselman and other amazing set of speakers will host a 7 hour session introducing the latest version of Visual Studio. So, go to https://visualstudio.microsoft.com/vs2019-launch/ , add the reminder to your calendar and get ready also for some local launch events !

Greetings @ Burlington

El Bruno

#Docker – About ports, IPs and more to access a container hosted in a #RaspberryPi

Hi !

So, my CustomVision.ai image is build and running in a container in my Raspberry Pi 3. It’s time to see if I can use it from other devices in the same network. When I run my image I defined IP and Port, but if you want to know these information, the following command is very useful

sudo docker port <CONTAINER ID>

01 docker port

So, my container is listening at 127.0.0.1 in port 80. That’s cool for local processing, however I want to access my container from other devices in the same network. In order to do this, I’ll run my image with the following command (I’m not defining the IP, just the port 80)

sudo docker run -p 80:80 -d <IMAGE ID>

02 docker port 80 and success run

The container is using the port 80, and docker is taking over this port in my device. My Raspberry PI device IP is [192.168.1.58], so I can go back and make some tests using Postman to analyze images in the device.

03 docker image analysis from postman

That’s cool. A small CustomVision image analyzer server for less than $30 !

Happy coding!

Greetings @ Toronto

El Bruno

References

My Posts

  1. Object recognition with Custom Vision and ONNX in Windows applications using WinML
  2. Object recognition with Custom Vision and ONNX in Windows applications using WinML
  3. Object recognition with Custom Vision and ONNX in Windows applications using Windows ML, drawing frames
  4. Object recognition with Custom Vision and ONNX in Windows applications using Windows ML, calculate FPS
  5. Can’t install Docker on Windows 10 Home, need Pro or Enterprise
  6. Running a Custom Vision project in a local Docker Container
  7. Analyzing images in a Console App using a Custom Vision project in a Docker Container
  8. Analyzing images using PostMan from a Custom Vision project hosted in a Docker Container
  9. Building the CustomVision.ai project in Docker in a RaspberryPi
  10. Container dies immediately upon successful start in a RaspberryPi. Of course, it’s all about TensorFlow dependencies

Windows 10 and YOLOV2 for Object Detection Series

#Docker – Container dies immediately upon successful start in a #RaspberryPi. Of course, it’s all about #TensorFlow dependencies

Hi !

Creating Docker images is a fun process. When I created the CustomVision.ai custom image to be executed in my Raspberry Pi, I faced a couple of errors, so now it’s time to save / share some lessons learned.

One of the most frustrating steps was after my 15 min wait time to build an image to find that the image was successfully built, however it dies after I run the image with a command like this one

sudo docker run -p 127.0.0.1:8080:80 -d <IMAGE ID>

There are a couple of options to understand what’s happen here. I decided to launch and trace the live events from Docker with the command

sudo docker events&

01 docker events

This windows is a full buffer of Docker events, after a while I detected that after I tried to start my docker image I got 2 messages similar to this one

2019-02-12T07:34:46.195722938-05:00 container start cdcdcc410518db46e09967412bd583c33cff6f4e8eee0f10e8baeec860f9c9a2 (image=295, io.balena.architecture=armv7hf, io.balena.device-type=raspberry-pi2, io.balena.qemu.version=3.0.0+resin-arm, name=musing_zhukovsky)

2019-02-12T07:34:46.195722938-05:00 container die cdcdcc410518db46e09967412bd583c33cff6f4e8eee0f10e8baeec860f9c9a2 (image=295, io.balena.architecture=armv7hf, io.balena.device-type=raspberry-pi2, io.balena.qemu.version=3.0.0+resin-arm, name=musing_zhukovsky)

As you probably detected (much faster than me!) the events were container start and container die. But the docker events does not display much more information with details of the event.

What we can use is the <LOG ID> included in the event line. And with the following command we can get more details of the event.

sudo docker logs cdcdcc410518db46e09967412bd583c33cff6f4e8eee0f10e8baeec860f9c9a2

02 docker event details

This is much better! Now I know that we can’t import a Python module named PIL on the file [app.py], in the line 10. When I open the file, it all makes sense.

03 app python details

So now it’s time to check the dependencies and tools required to use TensorFlow in a Raspberry Pi. I’ll write more about this tomorrow 😀

Happy coding!

Greetings @ Toronto

El Bruno

References

My Posts

  1. Object recognition with Custom Vision and ONNX in Windows applications using WinML
  2. Object recognition with Custom Vision and ONNX in Windows applications using WinML
  3. Object recognition with Custom Vision and ONNX in Windows applications using Windows ML, drawing frames
  4. Object recognition with Custom Vision and ONNX in Windows applications using Windows ML, calculate FPS
  5. Can’t install Docker on Windows 10 Home, need Pro or Enterprise
  6. Running a Custom Vision project in a local Docker Container
  7. Analyzing images in a Console App using a Custom Vision project in a Docker Container
  8. Analyzing images using PostMan from a Custom Vision project hosted in a Docker Container
  9. Building the CustomVision.ai project in Docker in a RaspberryPi

Windows 10 and YOLOV2 for Object Detection Series

#CustomVision – Building the CustomVision project in #Docker in a #RaspberryPi

Hi !

So my next step in my build process is to host the CustomVision.ai exported model in a RaspberryPi (RPI). RPI supports docker, so it should be easy to work with the exported Linux image.

So let’s take a look at the original [DockerFile] in the Linux export

FROM python:3.5

ADD app /app

RUN pip install --upgrade pip
RUN pip install -r /app/requirements.txt

# Expose the port
EXPOSE 80

# Set the working directory
WORKDIR /app

# Run the flask server for the endpoints
CMD python app.py

This file uses a standard python 3.5 linux image as base. However browsing in the docker community, I found a specific set of base image for RaspberryPi in the Docker Hub from Balena (link), see references.

So, using this base image and some resources from [Custom Vision + Azure IoT Edge on a Raspberry Pi 3] I make some changes to the DockerFile to create a running image for RPI.

FROM balenalib/raspberrypi3

RUN apt-get update &&  apt-get install -y \
        python3 \
        python3-pip \
        build-essential \
        python3-dev \
        libopenjp2-7-dev \
        libtiff5-dev \
        zlib1g-dev \
        libjpeg-dev \
        libatlas-base-dev \
        wget 

RUN pip3 install --upgrade pip 
RUN pip3 install pillow numpy flask tensorflow

RUN pip3 install flask 
RUN pip3 install pillow
RUN pip3 install numpy
RUN pip3 install tensorflow

ADD app /app

EXPOSE 80

WORKDIR /app

CMD python3 app.py

The full build process takes a couple of minutes, so you may want to have a coffee or a tea during the build process.

01 docker raspberry pi build

Once the process is complete, we can find the built and run the image from the docker image list

02 docker raspberry pi image built

Next step is to try the remote container with a single cURL command and done!

01 raspberry pi docker image analyzed

Happy coding!

Greetings @ Toronto

El Bruno

References

My Posts

  1. Object recognition with Custom Vision and ONNX in Windows applications using WinML
  2. Object recognition with Custom Vision and ONNX in Windows applications using WinML
  3. Object recognition with Custom Vision and ONNX in Windows applications using Windows ML, drawing frames
  4. Object recognition with Custom Vision and ONNX in Windows applications using Windows ML, calculate FPS
  5. Can’t install Docker on Windows 10 Home, need Pro or Enterprise
  6. Running a Custom Vision project in a local Docker Container
  7. Analyzing images in a Console App using a Custom Vision project in a Docker Container
  8. Analyzing images using PostMan from a Custom Vision project hosted in a Docker Container

Windows 10 and YOLOV2 for Object Detection Series

#CustomVision – Analyzing images using PostMan from a #CustomVision project hosted in a #Docker Container

Hi !

Today’s post is a simple one that I’ll use for sure in the future:

How to make an HTTP Post Request using Postman to analyze an image using a Custom Vision project hosted in a docker container.

In my previous posts I share the necessary steps to export a CustomVision.ai project and run the project in docker. I also show how to send images for analysis from a .NetCore Console App.

Today I’ll use another popular tool to perform the Http call to the docker container: Postman. This is one of the most popular tools in the web development world, and for sure is a good one if even myself knows how to use it!

So, once we have our session in Postman the container URL and POST are very straightforward. We are going to send an image, so we need to add a header with the Content-Type as image/jpg.

01 postman header image jpg

The image will be sent as binary content in the body. With 2 clicks we can select the file to use for testing.

02 postman body raw file

And finally, the result is an amazing JSON that we can analyze and see how our model performs

03 postman json results

And as a bonus, once we have a test defined in PostMan, we can easily export the test as code in different programming languages like C#, Java, Go or Python.

04 postman generate code

Here is a sample of the generated python code

Happy coding!

Greetings @ Toronto

El Bruno

References

My Posts

Windows 10 and YOLOV2 for Object Detection Series

#CustomVision – Analyzing images in a Console App using a #CustomVision project in a #Docker Container

Hi !

This is a special post. It’s the 1st one I write completely in my MacBook, so I’m sure that Javier (@jsuarezruiz), Yeray (@JosueYeray), Braulio (@braulio_sl), Luis, Sara, Roberto and other mac users will be proud of me 😀

So, I build and run my Custom Vision Marvel project in Docker for Mac. Smooth build and also a fast one!

docker build -t elbruno/cvmarvel:3.0 .

01 doker build on mac

Then get the image id and run the image

03 docker list images and run image

Final step is to play around with curl in bash to post the image (the file name with @ prefix took me some bing searches). Iron Fist detected !

curl -X POST http://127.0.0.1:8080/image -F imageData=@img1.jpg 

05 docker bash ls image analyzed and source image.png

Ok, the environment is working, so it’s time to create a .NetCore Console App to test this using amazing C# code. I have all my code in Azure Dev Ops, so I sync my repo and  added a new project in my current solution

06 new netcore project in visual studio for mac

Some C# lines in my console app and I was able to analyze a local picture using the Custom Vision Model in a container

07 console app in vs for mac detected image

The source code is very simple

Happy coding!

Greetings @ Toronto

El Bruno

References

My Posts

Windows 10 and YOLOV2 for Object Detection Series

#CustomVision – Running a Custom Vision project in a local #Docker Container

Hi !

So now that I have Docker running in Windows 10, it’s time to use a Custom Vision model in Windows hosted in Docker container.

There are 2 version available to export from CustomVision.ai for each one the projects: Linux or Windows

00 CV exported to docker

I could not sucessfully built the Windows version, so I’ll work with the Linux one. Once exported the zip file have a set of python files to tun the model, the model file (model.pb) and a Dockerfile to build the docker image.

FROM python:3.5

ADD app /app

RUN pip install –upgrade pip
RUN pip install -r /app/requirements.txt

# Expose the port
EXPOSE 80

# Set the working directory
WORKDIR /app

# Run the flask server for the endpoints
CMD python app.py

The image uses Python 3.5, and the build command is as simple as

docker build -t elbruno/cvmarvel:3.0 .

05 CV docker build image in windows

After a couple of seconds, the image is build in the local store

docker image ls

07 Docker local images

Once I have my IMAGE ID, it’s time to start the image. For this demo, I’ll use the port 8080

docker run -p 127.0.0.1:8080:80 -d ddd1623ee694

And then I can submit an image using Invoke-WebRequest and view the results directly in PowerShell

Invoke-WebRequest -uri “http://127.0.0.1:8080/image&#8221; -Method Post -Infile “D:\docker\test01.jpg” -ContentType ‘image/jpg’

06 CV running and testing an image on docker

In order to get the complete output of the POST request, I must add an OutFile into the PowerShell comand. And in the complete output we can see some Iron Fist and Venom results!

Invoke-WebRequest -uri “http://127.0.0.1:8080/image&#8221; -Method Post -Infile “D:\docker\test01.jpg” -Outfile “D:\docker\result.json” -ContentType ‘image/jpg’

08 docker results in visual studio code

Happy coding!

Greetings @ Toronto

El Bruno

References

My Posts

Windows 10 and YOLOV2 for Object Detection Series