4.1.1 A quick review of FV input and output interface

    Modify main.py

    Before After
    load dataset from local
    load weights from local
    validating
    save result at local
    load dataset from os.environ["INPUT_PATH"] # step 2
    load model weights from os.environ["WEIGHT_PATH"] # step 2
    validating
    Prepare an output dictionary # step 1
    save the output dictionary to os.environ["LOCAL_MODEL_PATH"] # step 2

    We will step-by-step elaborate each modifications in detail. The below image is a part of an example. Note that the modified

    Input Interface

    • INPUT_PATH with examples
    Before After
    # import cv2
    img = cv2.imread("./dataset/img1.jpg")
    # import cv2
    img = cv2.imread(os.environ["INPUT_PATH"]+"/dataset/img1.jpg")
    # import pandas as pd
    df = pd.read_csv("./data.csv")
    # import pandas as pd
    df = pd.read_csv(os.environ["INPUT_PATH"]+"/data.csv")
    • WEIGHT_PATH: Load pre-trained weights from the path into the model.
    • OUTPUT_PATH: Save the prepared dictionary as $OUTPUT_PATH/result.json. Remember to import json in advance.

    Output Interface

    • metadata: dict
      • dataSize: int      # MUST. It is the number of the validation data.
    • results: dict
      The categories are all OPTIONAL. If len(tables) is 3, you will see 3 tables on the dashboard. Each instance in a category is passed by a dict. e.g. tables["title"] means the title of the table.
      • tables: list[dict] # It's 1-D table, so input 1-D column name and value. 
        • title: str
        • labels: list[str]
        • values: list[num]
      • bars: list[dict]
        • title: str
        • labels: list[str]      # e.g. names of M categories
        • y-axis: str
        • values: list[num] # e.g. values of M categories
      • heatmaps: list[dict]
        • title: str
        • x-axis: str
        • y-axis: str
        • x-labels: list[str]
        • y-labels: list[str]
        • values: list[list[num]]
      • plots: list[dict]
        • title: str
        • x-axis: str
        • y-axis: str
        • x-values: list[list[str]] # e.g. M*N means M categories with each N time series points
        • y-values: list[list[str]] # e.g. M*N means M categories with each N time series points
        • labels: list[str]           # e.g. Must be M categories as above 
      • images: list[dict]
        • title: str
        • filename: str # The image name saved in OUTPUT_PATH

    Taiwan AI Labs (AILabs.tw) Copyright © 2023Powered by Bludit