This project is a simple API built using Hapi.js that integrates with a TensorFlow.js machine learning model. It provides endpoints for loading the model and making predictions.
hapi-tfjs-api
├── src
│ ├── server.js # Entry point of the application
│ ├── routes
│ │ └── model.js # API routes for the TensorFlow model
│ ├── controllers
│ │ └── modelController.js # Controller for handling model requests
│ ├── services
│ │ └── tensorflowService.js # Service for TensorFlow model interactions
│ └── types
│ └── index.d.ts # TypeScript types and interfaces
├── package.json # NPM configuration file
└── README.md # Project documentation
-
Clone the repository:
git clone <repository-url> cd hapi-tfjs-api -
Install dependencies:
npm install
To start the server, run:
node src/server.js
The server will start and listen for incoming requests.
- Endpoint:
POST /model/load - Description: Loads the TensorFlow.js model.
- Request Body:
{ "modelPath": "path/to/model.json" } - Response:
{ "message": "Model loaded successfully" }
- Endpoint:
POST /model/predict - Description: Makes a prediction using the loaded model.
- Request Body:
{ "inputData": [1, 2, 3, 4] } - Response:
{ "prediction": [0.5, 0.2, 0.3] }
Feel free to submit issues or pull requests for improvements or bug fixes.
This project is licensed under the MIT License.