This repo is used for demo Bangkit Guest Speaker Session H2. The topic is about how to create API for machine learning inference.
- Hapi Framework
- Tensorflow.js
The model was made from course "Belajar Machine Learning untuk Pemula" and exported as Keras Model (.h5). After that, because this demo is use tensorflowjs, the model should be convert to tensorflow.js model.
Here is the code in Python how to convert keras model (.h5) to tensorflow.js model. Make sure your tensorflow.js already installed on your local computer.
from tensorflow.keras.models import load_model
import tensorflowjs as tfjs
model_path = load_model("<Path to your model>")
output_path = "<Output path after your model is converted>"
tfjs.converters.save_keras_model(model_path, output_path)
Or you can use bash.
tensorflowjs_converter --input_format=keras <path to your model> <output_path>
If you want to try this project,
- Clone this project
git clone https://github.com/dicodingacademy/simple-api-tensorflowjs.git
- Install dependencies
npm i
- Run development script
npm run dev
Follow this step to deploy the apps to Compute Engine Instance
- Set firewall rule
Set the firewall rule for port 3000 (because this server is running on port 3000).
- Create your instance
Create your instance based on your preference and apply the firewall rule via target tags.
- Connect to the instance via SSH.
- Install Nodejs
- Follow the installation steps.