#WinML – Updated demo using Tiny YOLO V2 1.2, Windows 10 and YOLOV2 for Object Detection Series

Windows 10 and YOLOV2 for Object Detection Series


Hi!

There is a new Tiny YOLO V2 version in Azure AI Gallery

Tiny YOLOv2 1.2

I’ve updated my sample in GitHub to use this new version

https://github.com/elbruno/Blog/tree/master/20180806%20UwpMLNet%20TinyYoloV2%201.2

And it seems that Windows Insiders, are still having issues loading ONNXs models. My current build is 17730.1000

I1.png

Happy Coding!

Greetings @ Toronto

El Bruno

References

Advertisements

#WinML – Demo actualizada para utilizar Tiny YOLOv2 1.2, Windows 10 and YOLOV2 for Object Detection Series

Windows 10 and YOLOV2 for Object Detection Series


Buenas!

Ya tenemos disponible una nueva version de Tiny YOLO V2 en Azure AI Gallery

Tiny YOLOv2 1.2

Así que he actualizado el sample en GitHub para que utilice esta nueva version

https://github.com/elbruno/Blog/tree/master/20180806%20UwpMLNet%20TinyYoloV2%201.2

Y solo recordar que la carga de modelos ONNX parece que sigue sin funcionar en las versiones de Windows Insiders, en mi caso la build 17730.1000

I1.png

 

Happy Coding!

Saludos @ Toronto

El Bruno

References

#WinML – How to create a #Windows10 App and use #TinyYOLOV2 for object detection (the complete series)

Hi !

Windows 10 and TinyYOLOV2 for Object Detection Series

The complete example in GitHub

https://github.com/elbruno/Blog/tree/master/20180709%20UwpMLNet%20TinyYoloV3

Happy Coding!

Greetings @ Toronto

El Bruno

References

#WinML – How to convert Tiny-YoloV3 model in CoreML format to Onnx and use it in a #Windows10 App

Windows 10 and YOLOV2 for Object Detection Series


Hi!

In today’s post I’ll share some experience on how to download the latest version of Tiny-YoloV3 and use it in the UWP App that I created in previous posts. Important, the Tiny-YoloV2  model I’ve used in previous posts was in Onnx format, and it was downloaded from Azure AI Gallery.

We can download Tiny-YoloV3 from the official site, however I will work with a version that is already compiled in CoreML format, CoreML format is usually used in iOS apps (see References).

Well, to convert the model of CoreML To Onnx, we will use Visual Studio Tools For Ai. And the next set of software

Once all the software is installed, we can follow the step by step of [Ai Converting Models To ONNX] to convert our model. However, the road is not as simple as it seems. The 1st thing we can find are errors like the following

01 thanks Python

Problems with Python, in my case had several versions of Python installed, but the IDE had no marked as [Default]. From the panel [Pythin Environments] You can fix this

01 1 Python environments

Next Problem I need some configuration on my part, it was related to Prerequisites for conversion. It all starts with [Missing Package WinMLTools]

—————————

Error

—————————

Missing package WinMLTools, please check details in output window.

—————————

OK  

—————————

 

Traceback (most recent call last):

  File “C:\Users\<Bruno>\AppData\Local\Microsoft\VisualStudio\15.0_e5344afb\Extensions\kzqekf1z.44v\RuntimeSDK\model\model_converter_cli.py”, line 76, in check_winmltools_installed

    import winmltools

ModuleNotFoundError: No module named ‘winmltools’

However After Of Investigate for a while, these are the 2 Packages I need to install

Microsoft ML Tool (winmltools)

pip3 install winmltools==0.1.0.5072

CoreML Tools

pip3 install “git+https://github.com/apple/coremltools@v0.8”

As always, 1st thing to do is update Python

03 upgrade pip.png

And now we can launch the conversion operation again

07 01 convert.png

And a few seconds later we already have our Tiny-YoloV3 in format Onnx

07 convert running

Because the model respects the Input/Output of the previous version, we only have to replace the file in our solution. I have added the new Onnx Just to have a little more control over the example.

08 Sol Onnx.png

As I have always updated the complete example in GitHub

https://github.com/elbruno/Blog/tree/master/20180709%20UwpMLNet%20TinyYoloV3

Happy Coding!

Greetings @ Toronto

El Bruno

References

#WinML – Tutorial para convertir YoloV3 de CoreML a Onnx para utilizarlo en una #Windows10 App

Crear una Windows 10 UWP App y utilizar YoloV2 para reconocer objetos


Buenas !

En el post de hoy comentare como descargar la última versión de Tiny-YoloV3 y utilizarla en la UWP App que cree en post anteriores. Solo como reminder, la versión que utilice era Tiny-YoloV2 que es la que esta disponible en formato Onnx para descargar desde Azure AI Gallery.

Podemos descargar Tiny-YoloV3 desde su página oficial, sin embargo yo trabajare con una versión que ya está compilada en formato CoreML, que el formato de ML que se suele utilizar en apps iOS (ver referencias).

Pues bien, para convertir el modelo de CoreML a Onnx, utilizaremos Visual Studio Tools for AI, y el siguiente conjunto de software

Una vez instalado todo el software, podemos seguir el paso a paso de [AI Converting models to ONNX] para convertir nuestro modelo. Sin embargo, el camino no es tan simple como parece. Lo 1ro que nos podemos encontrar son errores como el siguiente

01 thanks Python

Problemas con Python, en mi caso tenia varias versiones de Python instaladas, pero el IDE no tenia ninguna marcada como [Default]. Desde el panel [Pythin Environments] se puede solucionar esto

01 1 Python environments

El siguiente problema que necesito un poco de configuración de mi parte, estaba relacionado con prerequisitos para la conversión. Todo comienza con [Missing package WinMLTools]

—————————

Error

—————————

Missing package WinMLTools, please check details in output window.

—————————

OK  

—————————

 

Traceback (most recent call last):

  File “C:\Users\<Bruno>\AppData\Local\Microsoft\VisualStudio\15.0_e5344afb\Extensions\kzqekf1z.44v\RuntimeSDK\model\model_converter_cli.py”, line 76, in check_winmltools_installed

    import winmltools

ModuleNotFoundError: No module named ‘winmltools’

Sin embargo, despues de investigar un rato, estas son los 2 packages que necesito instalar

Microsoft ML Tool (winmltools)

pip3 install winmltools==0.1.0.5072

CoreML Tools

pip3 install “git+https://github.com/apple/coremltools@v0.8”

Claro, antes hay que actualizar Python

03 upgrade pip.png

Y ya podemos lanzar nuevamente la operación de conversión

07 01 convert.png

Y pocos segundos después ya tenemos nuestro Tiny-YoloV3 en formato Onnx

07 convert running

Como el modelo respeta el Input / Output de la versión anterior, solo debemos reemplazar el archivo en nuestra solución. Yo he agregado el nuevo Onnx solo para tener un poco mas de control sobre el ejemplo.

08 Sol Onnx.png

Como siempre he actualizado el ejemplo completo en GitHub

https://github.com/elbruno/Blog/tree/master/20180709%20UwpMLNet%20TinyYoloV3

 

Happy Coding!

Saludos @ Burlington

El Bruno

References

#WinML – Problems With ONNX and Machine Learning.Net in the latest versions of #Windows10 Insiders

Hi!

After writing a step by step on how to use YoloV2 in a Windows App 10, I find that in the latest versions of Windows Insider, WinML It’s not working properly.

Windows 10 and YOLOV2 for Object Detection Series

 

I’ve reported the problem here Https://aka.ms/AA1sy9u And in my particular case in my Device With the version [17711.1000] as something fails in the UWPs App that use ONNX.

01

On another machine with version [17134.1] and it works properly

Happy Coding!

Greetings @ Toronto

El Bruno

References

#WinML – Problemas con ONNX y Machine Learning.Net en las versions de #Windows10 Insiders

Buenas!

Después de escribir un paso a paso sobre como utilizar YoloV2 en una App Windows 10, me encuentro con que en las ultimas versiones de Windows Insider, WinML no funciona correctamente.

Crear una Windows 10 UWP App y utilizar YoloV2 para reconocer objetos

He reportado el problema aquí https://aka.ms/AA1sy9u y en mi caso particular en mi device con la versión [17711.1000] pues algo falla en las UWPs app que utilizan ONNX.

01.png

En otra máquina con versión [17134.1] funciona correctamente

Happy Coding!

Saludos @ Toronto

El Bruno

References

#WinML – How to create a #Windows10 App using #YOLO for object detection (4 of 4)

Windows 10 and YOLOV2 for Object Detection Series


Hi!

Let me start from my previous post where I already coded a a real-time video camera feed process using with Tiny-YoloV2. The model returns results in a 416×416 size image, and that’s why the detected frame with the person looks kind of weird.

01

It’s not complicated to work with the output so it can be adapted to the size of the Webcam control, only a couple of lines of code.

And in this way, we can draw the frames with the right format. In the following image it is possible to see how a person is detected, with a low precision score and as well as one of the pictures on the wall it is detected as a monitor.

02

From here, it’s all about optimization, for example, take the value of the webcam control only when the app is resized.

In the final example, I have also added a visual indicator as a status bar, which shows the number of frames processed per second and the real size of the elements in the App.

03

The full code for the example can be downloaded from

https://github.com/elbruno/Blog/tree/master/20180704%20UwpMLNet%20TinyYoloV2

Happy Coding!

Greetings @ Toronto

El Bruno

References

#WinML – Creando una #Windows10 App con #YOLO para reconocer objetos (4 de 4)

Crear una Windows 10 UWP App y utilizar YoloV2 para reconocer objetos


Buenas!

Si retomamos el post anterior veremos que ya tenemos un proceso en tiempo real del video de la webcam analizado con Tiny-YoloV2. El modelo retorna resultados en una imagen de tamaño 416×416, y es por eso por lo que la imagen anterior el Frame de la persona se ve con un aspecto extraño.

01

El tratamiento para que el output se adapte al tamaño del control del WebCam puede solucionarse con 2 líneas de código.

 

 

Y de esta forma, ya podemos dibujar los Frames con el aspecto correcto. En la siguiente imagen es posible ver como se detecta una persona, con un bajo score de precisión y como además uno de los cuadros de la pared se lo detecta como un monitor.

02

A partir de aquí se pueden optimizar muchas cosas, por ejemplo, solo tomar el valor del tamaño

del canvas en el Resize de la App.

 

 

En el ejemplo final, he agregado además un indicador visual que muestra la cantidad de frames procesados por segundo y el tamanio real con el que se esta trabajando.

03

El código completo del ejemplo se puede descargar desde

https://github.com/elbruno/Blog/tree/master/20180704%20UwpMLNet%20TinyYoloV2

Happy Coding!

Saludos @ Mississauga

 

El Bruno

References

#WinML – How to create a #Windows10 App using #YOLO for object detection (3 of 4)

Windows 10 and YOLOV2 for Object Detection Series


Hi!

Today I start with the final UWP App running because much of the post will be code and more code. The expected output in a Windows 10 object recognition App with YoloV2 is similar to the following image

01

Following in the footsteps of my previous post, we were with the result of the process of our Webcam With YoloV2 and that is an array of 21125 Numbers Float. Well, this number is not trivial, as rereading the documentation of YOLOV2 we see that YOLO divides the image into a 13-by 13-cell grid:

02

Each of these Cells It is responsible for predicting 5 bounding boxes. A bounding box describes the rectangle that contains an object. and from here The number

13 * 13 * 125 = 21125

There are many posts that describe how Yolo works internally, I left some in the references if someone is interested in the details.

Well, in this scenario the next step was to start translating that Grid[21125] in C# objects to work with. As the internet is a very broad source of knowledge, instead of translating some of the Python classes that already exist, I saw that Rene Schulte It had between its GitHub repositories a Fork From another repo where you could see the following classes

  • YoloWinMLParser.cs
    • This class is a parser to convert the Grid In a collection of Frames with the size and location coordinates of the objects detected in the image.
  • YoloBoundingBox.cs
    • This class represents a Frame of detected object.

To show these frames, we add a Canvas About the control that shows the Feed of the camera.

03

The following code completes the example, with the following considerations

  • There are a number of private variables to work with the model, the collection of frames and the visual styles with which they are painted.
  • The frames of people are painted in green, the other objects in yellow

The only detail that remains to comment is that YoloV2 is designed to work with images of size 416 x 416. In this case you have to resize the control of Webcam and the Canvas To that Size So that the frames are displayed in the correct position.

In the next post I will share the final example, and also add some work of Rescaling To be able to support other definitions different from 416 x 416.

Happy Coding!

Greetings @ Toronto

El Bruno

References