Giter Club home page Giter Club logo

ml-api's Introduction

ML API Template ๐Ÿš€

Hello everyone! In this repository, I (Kaenova, a mentor in Bangkit 2023 program) will provide you with a head start on creating an ML API. Please read every line and comment carefully.

I have included code examples for both text-based input and image-based input APIs. To run this server, make sure to install all the required libraries listed in requirements.txt by executing the command pip install -r requirements.txt. Then, use the command python main.py to run the server.

Machine Learning Setup

Please prepare your model in either the .h5 or saved model format. Place your model in the same folder as the main.py file. You will load your model in the code provided below. There are two options available: one for image-based input and another for text-based input. You need to complete either the def predict_text or def predict_image functions in main.py based on your model's input type.

Cloud Computing

You can check the endpoints used for the machine learning models in this API. The available endpoints are /predict_text for text-based input and /predict_image for image-based input.

For the /predict_text endpoint, you need to send a JSON payload with the following structure:

{
  "text": "your text"
}

For the /predict_image endpoint, you need to send a multipart-form with a field named "uploaded_file" containing the image file.

You can view the API documentation by accessing the /docs endpoint after running the server. Additionally, a Dockerfile is provided to facilitate modification and container image creation. By default, the server runs on port 8080, but you can customize the port by injecting the PORT environment variable.

Consultation

If you need any assistance or would like to schedule a consultation with me, feel free to reach out to me on Discord (kaenova#2859). We can discuss your requirements and arrange a consultation time.

Finally, I encourage you to share your capstone application with me! You can connect with me on the following platforms:

Now, you can start writing your deploying your model. Happy coding!


Usage

To get started, follow these steps:

  1. Clone the repository:
git clone https://github.com/your-username/your-repository.git
  1. Install the required libraries:
pip install -r requirements.txt
  1. Prepare your machine learning model:
  • If you have an .h5 model file, place it in the same folder as main.py.
  • If you have a saved model format, place it in a folder named my_model_folder in the same directory as main.py.
  1. Read the main.py file carefully

  2. Complete the predict_text or predict_image function in main.py

  3. Run the server:

python main.py

One More Thing

One thing i should mention. Many people still asking Who should deploy the model? Is it CC or is it ML?

Both parties need to collaborate. Cloud Computing (CC) may not be familiar with the contents of your .h5 file, and Machine Learning (ML) may not be familiar with HTTP POST and GET requests. Therefore, it is the responsibility of both parties to deploy the model.

ml-api's People

Contributors

foobar2016 avatar mokachaos 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.