https://github.com/dicodingacademy/simple-api-tensorflowjs
Repository ini digunakan untuk demo Bangkit 2023 H2 Guest Speaker Session mengenai tutorial membuat API untuk menangani inference machine learning.
https://github.com/dicodingacademy/simple-api-tensorflowjs
Last synced: about 1 year ago
JSON representation
Repository ini digunakan untuk demo Bangkit 2023 H2 Guest Speaker Session mengenai tutorial membuat API untuk menangani inference machine learning.
- Host: GitHub
- URL: https://github.com/dicodingacademy/simple-api-tensorflowjs
- Owner: dicodingacademy
- Created: 2023-11-01T06:09:59.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-05T16:09:28.000Z (over 2 years ago)
- Last Synced: 2024-12-28T19:03:06.836Z (over 1 year ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# About this repo
This repo is used for demo Bangkit Guest Speaker Session H2.
The topic is about how to create API for machine learning inference.
# Dependencies Project (main branch)
1. Hapi Framework
2. Tensorflow.js
# Machine Learning Model
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.
```python
from tensorflow.keras.models import load_model
import tensorflowjs as tfjs
model_path = load_model("")
output_path = ""
tfjs.converters.save_keras_model(model_path, output_path)
```
Or you can use bash.
```bash
tensorflowjs_converter --input_format=keras
```
# Installation
If you want to try this project,
1. Clone this project
```bash
git clone https://github.com/dicodingacademy/simple-api-tensorflowjs.git
```
2. Install dependencies
```bash
npm i
```
3. Run development script
```
npm run dev
```
# Deploy to Compute Engine Instance
Follow this step to deploy the apps to Compute Engine Instance
1. Set firewall rule
Set the firewall rule for port 3000 (because this server is running on port 3000).
2. Create your instance
Create your instance based on your preference and apply the firewall rule via [target tags](https://cloud.google.com/vpc/docs/add-remove-network-tags).
3. Connect to the instance via SSH.
4. Install [Nodejs](https://nodejs.org/en/download/package-manager#nvm)
5. Follow the installation steps.