Code Monkey home page Code Monkey logo

ml4k-ai-extension's Introduction

ML4K AppInventor Extension

Use machine learning in AppInventor, with easy training using text, images, or numbers through the Machine Learning for Kids website.

Download (.aix)

Example

Text classification

ML4K Text Example

Image classification

ML4K Image Example

Note: The ClassifyImage block takes the path to an image, which you can get from the Selected property of an ImagePicker.

Numbers classification

ML4K Number Example

Live examples

See example .aia projects in the examples directory of this repo (Created by Joe Mazzone). Look at the code blocks for where to add your API key (API key is not included), they are set in the click method - though you can set it anywhere you choose as long as it is before the classification occurs.

Installation

Download the latest extension file (.aix) from the releases page and follow section "2. How to use extensions components" of this website to add the extension to your App Inventor project.

Guide


If you received this extension from the ML4K website, your API key will be set for you and you don't need the block to set it - skip to step 1 and 2.


  1. After installing the extension, you need to get an API key, which can be obtained from Machine Learning for Kids. This API Key is not the IBM Watson API keys used to create your Machine Learning for Kids account. This key is created by Machine Learning for Kids and is specific to your project. It can be found on the App Inventor project page in the unique URL for your project.

       Or, the key can be found on the Python project page.

      Do not use the keys displayed in the images above. Use the keys from your project pages.

  1. Copy and paste the API Key into the ML4K component’s “Key” property on the Designer screen or use the "set Key" block on the Blocks screen. Note: API Key must be set before you can use any of the ML4K extension blocks for classification. If you choose to set the key using the “set Key” block, be sure to set the key in the Screen.Initialize event or any time before you use a classification method (purple block).

Set Key

  1. Classify the text, image, or numbers:
    a. If classifying text, use the "ClassifyText" block with the text to classify.

    b. If classifying images, use the "ClassifyImage" block with the image path to classify.

    c. If classifying numbers, use the "ClassifyNumbers" block with a list of numbers to classify.

  2. Use the "GotClassification" event block to retrieve the classification once it is completed.

  3. Use the "GotError" event block to retrieve any errors which occur during classification.

  4. Add data to your machine learning project with code:
    a. To add data to a text project use the "AddTextTrainingData" block, identifying the text data to add and label to add it to.

    b. To add data to an image project use the "AddImageTrainingData" block, identifying the image file to add and label to add it to.

    c. To add data to a numbers project use the "AddNumbersTrainingData" block, identifying the list of numbers and label to add it to.

  5. Use the "GetModelStatus" block to see if your model is ready to use or still in the process of training.

  6. Use the "GotStatus" event block to retrieve the status of the model.

    • statusCode 2 - "Ready" - The model is trained and ready to use.
    • statusCode 1 - "Training in progress" - The model is still training and cannot be used.
    • statusCode 0 - Something went wrong (or there isn't a model) - the 'message' variable will contain information on the issue.
  7. Use the "TrainNewModel" block to train your Text or Numbers project with App Inventor.

    • Note: This block cannot be used for training Image projects. Only available for Text and Numbers.

Handling Errors

Upon an error, the "GotError" event block will be called with the error that occurred. Please use this event block fro debugging.

Building with preset API key

To build the extension, open a terminal and navigate to the release folder. Run the build_aix.py script, passing in the API key.

cd release
python build_aix.py <API KEY>

This will generate a ML4K.aix file which contains a preset API key.

To do this without the Python script, the file com.kylecorry.ml4k/assets/api.txt needs to be modified to have the API key in it. Then the whole folder (com.kylecorry.ml4k directory needs to be present in the top level of the zip file) needs to be zipped and renamed to have the .aix extension instead of .zip.

Building from source

Unix (Linux / Mac)

To build the extension from sources, you can use the makefile.

Requirements

  • make
  • ant
  • git

Building

make

This will create a directory called _build/dist which will contain the .aix file (without an API key).

Windows

To build the extension from sources, you can use the build.bat.

Requirements

  • ant
  • git

Building

.\build.bat

This will create a directory called _build/dist which will contain the .aix file (without an API key).

FAQ

The extension crashes while using an emulator: See this issue

License

This project is licensed under the MIT License.

Featured projects

Here are some community contributed projects which demonstrate awesome uses of the ML4K extension. All credits belong to the creators of these projects:

Credits

Contribute

Please feel free to contribute to this extension, or if you find an issue be sure to report it under issues.

ml4k-ai-extension's People

Contributors

dalelane avatar kylecorry31 avatar mrmazzone avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.