<< return to Vizycam.com

User Tools

Site Tools


wiki:object_detector_app_2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
wiki:object_detector_app_2 [2023/01/06 08:11]
vizycam [Using a phone or camera to capture training images]
wiki:object_detector_app_2 [2023/01/19 12:48]
vizycam
Line 54: Line 54:
 ==== Configuring Google services ==== ==== Configuring Google services ====
  
-Your Vizy can upload pictures to Google ​Photos ​and interact with Google'​s Colab servers so you can train your own custom CNN's. In order for these things to happen, you'll want to [[wiki:​google_cloud_setup3|set up Google services]]. ​+Your Vizy can upload pictures to Google ​Photo and interact with Google'​s Colab servers so you can train your own custom CNN'​s. ​ You can also export projects to share with other Vizy users. ​ You won't need to configure Google Services to import projects, however.  ​In order for these things to happen, you'll want to [[wiki:​google_cloud_setup3|set up Google services]]. ​
  
 Once you've set this up, other Vizy applications will have access to Google cloud services such as Photos, Gmail, Sheets, Colab, and Google Drive. Once you've set this up, other Vizy applications will have access to Google cloud services such as Photos, Gmail, Sheets, Colab, and Google Drive.
Line 105: Line 105:
 From the **File** menu select **New...** to bring up the **New project** dialog.  ​ From the **File** menu select **New...** to bring up the **New project** dialog.  ​
  
-{{wiki:​image_1378.jpg}}+{{wiki:​image_1378.jpg?300}}
  
 Type the name of the project into the text box and click on **Save**. ​ For demonstration purposes, we'll create a network to detect rock, paper, and scissors hand gestures. Type the name of the project into the text box and click on **Save**. ​ For demonstration purposes, we'll create a network to detect rock, paper, and scissors hand gestures.
Line 162: Line 162:
 {{wiki:​image_1339.jpg}} {{wiki:​image_1339.jpg}}
  
-Click on **Upload training data**. ​ Vizy will then get busy zipping-up all of the images and copying them into Google Drive. ​ This will take some time, depending on how many images you have in the training set.  After it has finished, click on **Train**, which will bring up a Google Colab browser tab.  ​([[https://​research.google.com/​colaboratory/​faq.html|Google Colab]] is a Python notebook, similar to [[https://​jupyter.org|Jupyter]]. ​ It includes access to GPU resources for increased processing speed, especially for training CNN'​s. ​ It's free to use, and ideal for training our CNN. +Click on **Upload training data**. ​ Vizy will then get busy zipping-up all of the images and copying them into Google Drive. ​ This will take some time, depending on how many images you have in the training set.  After it has finished, click on **Train**, which will bring up a Google Colab browser tab.  ​Why do we need Google Colab and what is Google Colab? ​[[https://​research.google.com/​colaboratory/​faq.html|Google Colab]] is a Python notebook, similar to [[https://​jupyter.org|Jupyter]]. ​ It includes access to GPU resources for increased processing speed, especially for training CNN'​s. ​ It's free to use, and ideal for training our CNN.  ​Training CNNs is essentially a million-variable optimization problem. ​ This requires a huge amount of computation! ​ It's only recently that you can bring this level of computing to bear for free.  Previously, you would need to purchase a high-end GPU card or compute time on a GPU-equipped AWS server, both of which are pricey. ​
    
 Begin by selecting **Change runtime type** from the **Runtime** menu. Begin by selecting **Change runtime type** from the **Runtime** menu.
Line 296: Line 296:
   - **Create an album and copy these pictures into the album**. ​ This can be done from your phone via the [[https://​play.google.com/​store/​apps/​details?​id=com.google.android.apps.photos|Google Photos App]] or from your computer via a browser. ​   - **Create an album and copy these pictures into the album**. ​ This can be done from your phone via the [[https://​play.google.com/​store/​apps/​details?​id=com.google.android.apps.photos|Google Photos App]] or from your computer via a browser. ​
   - **Share the album with [[wiki:​google_cloud_setup3#​creating-a-google-account|Vizy'​s Google account]]**. ​ Similarly, you can do this from your phone via the [[https://​play.google.com/​store/​apps/​details?​id=com.google.android.apps.photos|Google Photos App]] or from your computer via a browser. ​ From the album you can click on **share** or click on the context menu to select **share**, then type in the Gmail address of the account you wish to share the album with.  You may need to type in the complete Gmail address associated with your Vizy camera for the account to show up.   - **Share the album with [[wiki:​google_cloud_setup3#​creating-a-google-account|Vizy'​s Google account]]**. ​ Similarly, you can do this from your phone via the [[https://​play.google.com/​store/​apps/​details?​id=com.google.android.apps.photos|Google Photos App]] or from your computer via a browser. ​ From the album you can click on **share** or click on the context menu to select **share**, then type in the Gmail address of the account you wish to share the album with.  You may need to type in the complete Gmail address associated with your Vizy camera for the account to show up.
-  - **Import album pictures into your Object Detector project**. ​ This will copy the images in the Google Photos album into the training set of the currently open project. ​ Start by selecting **Import photos...** from the **File** menu, then type the name of the album into the text box as shown below. ​ {{wiki:​image_1410.jpg}}+  - **Import album pictures into your Object Detector project**. ​ This will copy the images in the Google Photos album into the training set of the currently open project. ​ Start by selecting **Import photos...** from the **File** menu, then type the name of the album into the text box as shown below. ​\\ \\ {{wiki:​image_1410.jpg}} ​\\ \\ After clicking on **Import**, Vizy will locate the album, retrieve the images, and add them to the end of the training set.  So after it's done, go to the last page(s) of the training set to see the imported images. ​ Bear in mind that the album name is case-sensitive. ​ If Vizy has trouble finding the album, make sure you can see the album from the Google Photos page while logged in via Vizy's Google account. ​ Once the images are imported, you can [[wiki:​object_detector_app_3#​labeling|label them]] as before. ​ Easy-peasy! ​
  
-After clicking on **Import**, Vizy will locate the album, retrieve the images, and add them to the end of the training set.  So after it's done, go to the last page(s) of the training set to see the imported images. ​ Bear in mind that the album name is case-sensitive. ​ If Vizy has trouble finding the album, make sure you can see the album from the Google Photos page while logged in via your Vizy's Google account. ​ Once the images are imported, you can [[wiki:​object_detector_app_3#​labeling|label them]] as before. ​ Easy-peasy!  +===== Importing, ​Exporting, and sharing ​Object Detector ​projects =====
- +
-===== Exporting, importing, and sharing ​CNN projects =====+
  
 Through the powers of the Internet (and Google Drive), you can export your project and share your CNN efforts with others. ​ And they can import your project to evaluate, improve, and share it back with you and possibly others. ​ When exporting a project, all of the training set images, models, and settings are zipped up and uploaded to Google Drive. ​ (Note, the detection images are not included when you export a project.) Through the powers of the Internet (and Google Drive), you can export your project and share your CNN efforts with others. ​ And they can import your project to evaluate, improve, and share it back with you and possibly others. ​ When exporting a project, all of the training set images, models, and settings are zipped up and uploaded to Google Drive. ​ (Note, the detection images are not included when you export a project.)
  
-==== Exporting ​a project ====+==== Importing ​a project ====
  
-From the **File** menu select **Export ​project...** to bring up the export ​dialog.  ​Click the **Export** button. ​ Vizy will then get busy zipping up the project ​and copying it to Google Drive.  ​When it's finished it will present ​you will a **Copy share key** button+From the **File** menu select **Import ​project...** to bring up the import ​dialog.  ​Copy the share key into the text box and click the **Import** button. ​ Vizy will then get busy downloading ​the zip file, unzipping, ​and installing the project.  ​Easy!  Note, you don't need to have [[#​Configuring Google services|Google services]] configured to import projects 
  
-{{wiki:image_1412.jpg}}+{{wiki:image_1413.jpg}}
  
-Pressing this will copy the "share key" to your clipboard.  ​The share key is just a jumble of text.  You can save the key to a text file, email it, etc.  With this key, someone can import ​your project. ​+Below is a share key for our rock paper scissors project.  ​**Copy and paste it to give it try on your Vizy!**
  
-==== Importing a project ====+''​VWyJPRFBHIiwgInJvY2sgcGFwZXIgc2Npc3NvcnMiLCAiMXpDc2c4aVlIVkpaSk53a0xIeTlPdmJvcjJKaWFjYURlIl0=V''​
  
-From the **File** menu select **Import ​project...** to bring up the import dialog. ​ Copy the share key into the text box and click the **Import** button. ​ Vizy will then get busy downloading the zip file, unzipping, and installing the project. ​ Easy!+==== Exporting a project ​====
  
-{{wiki:​image_1413.jpg}}+From the **File** menu select **Export project...** to bring up the export dialog. ​ Click the **Export** button. ​ Vizy will then get busy zipping up the project and copying it to Google Drive. ​ When it's finished it will present you will a **Copy share key** button
  
 +{{wiki:​image_1412.jpg}}
 +
 +Pressing this will copy the "share key" to your clipboard. ​ The share key is just a jumble of text.  You can save the key to a text file, email it, etc.  With this key, someone can import your project. ​
  
 ===== Customized handlers ===== ===== Customized handlers =====
  
-For more advanced users who want to add their own custom features, the Object Detection application has handler code for various events and for text messages. ​ For example, Vizy could click a relay, turn on a light, trigger a sprinkler valve, etc. if it sees a particular object. The handler code is in ''/​home/​pi/​vizy/​apps/​object_detector/​handlers.py''​. ​ Note, you can bring up the handler code easily from [[wiki:​vizy_editor#​Text editor|Vizy'​s built-in text editor]] by clicking on the ☰ button in the text editor and selecting ''​handlers.py''​. ​ Note also, once you change ''​handlers.py''​ you can simply click reload/​refresh on your browser and Vizy will automatically restart the application and your code changes will take effect.+For more advanced users who want to add their own custom features, the Object Detection application has handler code for various events and for text messages. ​ For example, Vizy could click a relay, turn on a light, trigger a sprinkler valve, etc. if it sees a particular object ​or if it receives a specific text message The handler code is in ''/​home/​pi/​vizy/​apps/​object_detector/​handlers.py''​. ​ Note, you can bring up the handler code easily from [[wiki:​vizy_editor#​Text editor|Vizy'​s built-in text editor]] by clicking on the ☰ button in the text editor and selecting ''​handlers.py''​. ​ Note also, once you change ''​handlers.py''​ you can simply click reload/​refresh on your browser and Vizy will automatically restart the application and your code changes will take effect.
  
 {{wiki:​image_1213.jpg}} {{wiki:​image_1213.jpg}}
Line 359: Line 360:
 ===== Using custom CNN's in other programs ===== ===== Using custom CNN's in other programs =====
  
-The projects for Object Detector are located in ''/​home/​pi/​vizy/​etc/​object_detector/''​. ​ Within this directory are the project directories -- one for each project, and within each project directory are the two files: ''<​project name>​.tflite''​ and ''<​project name>​.json''​. ​ These files are the latest CNN model version for this project. ​ You can run these files on other generic Raspberry Pis, or you can export them to AI accelerators such as [[https://​coral.ai/​products/​|Coral]] or [[https://​www.canaan.io/​product/​kendryteai|Kendryte]] using a TensorFlow Lite compiler. ​ Or you can use them in other Vizy programs that use TensorFlow, like the Vizy Tflite example. ​ You would only need to change a single line of code (where the Tflite detector is instantiated) to use the desired CNN model instead of the default common objects model. ​+The projects for Object Detector are located in ''/​home/​pi/​vizy/​etc/​object_detector/''​. ​ Within this directory are the project directories -- one for each project, and within each project directory are the two files: ''<​project name>​.tflite''​ and ''<​project name>​.json''​. ​ These files are the latest CNN model version for this project. ​ You can run these files on other generic Raspberry Pis, or you can export them to AI accelerators such as [[https://​coral.ai/​products/​|Coral]] or [[https://​www.canaan.io/​product/​kendryteai|Kendryte]] using a TensorFlow Lite compiler. ​ Or you can use them in other Vizy programs that use TensorFlow, like the Vizy Tflite example. ​ You would only need to change a single line of code (where the Tflite detector is instantiated) to use the desired CNN model instead of the default common objects model, as shown below
    
 <sxh python; title: Tflite example main.py> <sxh python; title: Tflite example main.py>
wiki/object_detector_app_2.txt · Last modified: 2023/01/19 13:32 by vizycam