•  
  •  

Most Recent FAQs

Most Viewed FAQs

9 faqs found.
  • The model files can be shared in any of the following ways

     

    Github - Upload all the required files to a GitHub public repository and share the repo link as the inference source location

     

    Google Drive - Go to the root directory (where inference.py exists), select all the required files, compress them into an inference.zip file. Upload it to Google Drive. Right-click on inference.zip in the drive, select ‘Get Link’, choose ‘Anyone with the link’ to give public view access, and provide the link as the inference source location

     

    Other

    Any other URL which can be used to download the inference.zip file with a simple http request can also be provided as the inference source location (Eg: AWS S3)

  • Once the model is deployed, anyone with the inference URL page link can use the model for inference. Based on the model type, the formats of input given to the model and the output received changes. The test data URL provided by the model owner is displayed on the inference URL page and can be used for reference.

    Structured Data Predictions
    Input is a CSV file with the target/test data and the output is a CSV file of predictions obtained.

    Image Classification
    Input is an image (jpg/png) and the output is a text.

    Object Detection
    Input is an image (jpg/png) and the output is also an image displayed  in the browser which contains bounding boxes or predictions

    Text Classification
    Input is a text provided by the user and the output is also a text which is the prediction received.

    Entity Recognition
    Input is a text provided by the user and the output is also a text which displays the entities recognized in the input.
  • The following files can be used as a reference for text classification inference - Sample Text Classification Inference - Cluzters Vault and Google Docs - Cluzter Model Guidelines


    Guidelines

    Inference.zip Folder structure:

    requirements.txt

    Trained Model file

    inference.py

    Other files and folders used


    Inference.py file format:

    Import Statements

    Onetime executable operations

    {Ex: Loading the Model, label encoding  etc.}

    def predict(Input arguments as per the use-case)

    {

    Data Preprocessing

    Inference

    Return output based on the use-case

    }

    *Do not change the naming convention for the entities marked inblue
    • inference.py and requirements.txt are mandatory files
    • inference.py should contain a function predict which takes one argument - a string (an input text). The return value should be also be a string (the output/prediction text).


    Sample inference.py
    from tensorflow.keras.models import load_model import numpy as np labels = ["positive", "negative", "neutral"] model = load_model("model.h5") def predict(input_text): #preprocessing yhat = model.predict(input_text) yhat = np.array(yhat) indices = np.argmax(yhat, axis=1) scores = yhat[np.arange(len(yhat)), indices] predicted_categories = [labels[i] for i in indices] output = predicted_categories[0] return output​​

    requirements.txt
    tensorflow==2.4 numpy ​ ​


  • After training the model, prepare your inference files as per the following guidelines and examples
    FAQ - Structured Data Prediction Reference 
    FAQ - Object Detection Reference 
    FAQ - Image Classification Reference 
    FAQ - Text Classification Reference 
    Google Doc - Cluzter Model Guidelines 

    Upload the code to Github or Google Drive or other location as per the guidelines (Refer: FAQ - Share Model Files for Deployment )

    Go to https://www.cluzters.ai/Model-Hub/manage and select 'Post a New Model' (or click here ). Fill in all the required details to create the use case. Go to the Deployment tab and click 'Deploy' to trigger the deployment procedure
  • The following files can be used as a reference for  Object Detection Inference - Hardhat Detection and Google Docs - Cluzter Model Guidelines


    Guidelines

    Inference.zip Folder structure:

    requirements.txt

    Trained Model file

    inference.py

    Other files and folders used


    Inference.py file format:

    Import Statements

    Onetime executable operations

    {Ex: Loading the Model, label encoding  etc.}

    def predict(Input arguments as per the use-case)

    {

    Data Preprocessing

    Inference

    Return output based on the use-case

    }

    *Do not change the naming convention for the entities marked inblue
    • inference.py and requirements.txt are mandatory files
    • inference.py should contain a predict function which takes 2 arguments.
      First arg(string): img path to read the input image from
      Second arg(string): Directory to save the output image. For example if the 2nd argument is variable output_dir, the image can be saved as output_dir+’image.jpg’
    • The return value of the predict function should be the file location where output image is saved


    Sample inference.py
    import os, sys import cv2 import numpy as np import tensorflow as tf #load the model and any other custom defined functions/variables detection_model = tf.saved_model.load('saved_model') def predict(img, output_directory): #mandatory function: First arg: img path to read from, Second arg: Dir to save the output image img = cv2.imread(img) #code for predictions #........ #......... output_file = output_directory + "image.jpg" cv2.imwrite(output_file,image_np_with_detections) return output_file​

    Sample requirements.txt
    tensorflow==2.4.1 numpy​ opencv-python-headless​
  • Generally, a model deployment takes around 15-20 minutes but it may vary. For example, if there are many packages in the requirements.txt, it will take more time to install the pip packages.
  • Model Hub is a place to showcase the research and publications solving various industry problems leveraging A.I. Cluzters gives its members a unique opportunity to deploy their ML models for free and even monetize them. Research content is restricted to data science and related fields. Members are encouraged to publish only their original content, Plagiarism may lead to the deactivation of the user account.
  • The following files can be used as a reference for structured data inference -Iris Inference - Cluzters Vault and Google Docs - Cluzter Model Guidelines


    Guidelines

    Inference.zip Folder structure:

    requirements.txt

    Trained Model file

    inference.py

    Other files and folders used


    Inference.py file format:

    Import Statements

    Onetime executable operations

    {Ex: Loading the Model, label encoding  etc.}

    def predict(Input arguments as per the use-case)

    {

    Data Preprocessing

    Inference

    Return output based on the use-case

    }

    *Do not change the naming convention for the entities marked inblue

    • inference.py and requirements.txt are mandatory files
    • inference.py should contain a function predict which takes one argument - a pandas dataframe. The return value should be a list of strings. For example, if the dataframe consists of 100 rows, the return value should be a list of 100 predictions (strings)


    Sample inference.py
    import pickle import numpy as np import pandas as pd model = pickle.load(open('model.pkl', 'rb')) class_names = ['setosa', 'versicolor', 'virginica'] def predict(df): #argument df is a pandas dataframe df = df[["SepalLengthCm", "SepalWidthCm", "PetalLengthCm", "PetalWidthCm"]] numpy_array = df.to_numpy() # Predict predictions = model.predict(numpy_array) output = [class_names[class_predicted] for class_predicted in predictions] return output #return will be a list of strings  ​

    Sample requirements.txt
    sklearn==0.0 numpy pandas ​​


  • The following files can be used as a reference for Image Classification inference - Pneumonia Prediction - Cluzters Vault and Google Docs - Cluzter Model Guidelines


    Guidelines

    Inference.zip Folder structure:

    requirements.txt

    Trained Model file

    inference.py

    Other files and folders used


    Inference.py file format:

    Import Statements

    Onetime executable operations

    {Ex: Loading the Model, label encoding  etc.}

    def predict(Input arguments as per the use-case)

    {

    Data Preprocessing

    Inference

    Return output based on the use-case

    }

    *Do not change the naming convention for the entities marked inblue
    • inference.py and requirements.txt are mandatory files
    • inference.py should contain a function predict which takes one argument - a string (image path). The return value should be a string(prediction text displayed to the user).


    Sample inference.py
      import numpy as np from tensorflow.keras.preprocessing.image import load_img from tensorflow.keras.applications.vgg16 import preprocess_input from tensorflow.keras.preprocessing.image import array_to_img, img_to_array from tensorflow.keras.models import load_model classes = ["person", "car", "truck"] model = load_model("model.h5") def predict(img_path): #mandatory: function name should be predict and it accepts a string which is image location image = load_img(img_path, target_size=(224, 224)) image = img_to_array(image) image = image.reshape((1, image.shape[0], image.shape[1], image.shape[2])) image = preprocess_input(image) yhat = model.predict(image) yhat = np.array(yhat) indices = np.argmax(yhat, axis=1) scores = yhat[np.arange(len(yhat)), indices] predicted_categories = [classes[i] for i in indices] output = predicted_categories[0] return output #mandatory: the return should be a string​​​

    Sample requirements.txt
    tensorflow==2.4 numpy pillow​ ​​