# -*- coding: utf-8 -*-
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
#
# Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import argparse

import cv2
import megengine as mge
import megengine.data.dataset as dataset
import megengine.jit as jit
import numpy as np

from megengine.utils.http_download import download_from_url
from official.vision.segmentation.deeplabv3plus import DeepLabV3Plus


class Config:
    NUM_CLASSES = 21
    IMG_SIZE = 512
    IMG_MEAN = [103.530, 116.280, 123.675]
    IMG_STD = [57.375, 57.120, 58.395]


cfg = Config()


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--image_path", type=str, default=None, help="inference image")
    parser.add_argument("--model_path", type=str, default=None, help="inference model")
    args = parser.parse_args()

    net = load_model(args.model_path)
    if args.image_path is None:
        download_from_url("https://data.megengine.org.cn/images/cat.jpg", "test.jpg")
        img = cv2.imread("test.jpg")
    else:
        img = cv2.imread(args.image_path)
    pred = inference(img, net)
    cv2.imwrite("out.jpg", pred)


def load_model(model_path):
    model_dict = 
mge.load(model_path)