Пример #1
0
def setup_ssd_server(tmpdir):
    """
        Downloads and Setup the SSD model server.
    :return: None
    """
    # Download the files required for SSD model in temp folder.
    _download_file(
        tmpdir,
        "https://s3.amazonaws.com/model-server/models/resnet50_ssd/resnet50_ssd_model-symbol.json"
    )
    _download_file(
        tmpdir,
        "https://s3.amazonaws.com/model-server/models/resnet50_ssd/resnet50_ssd_model-0000.params"
    )
    _download_file(
        tmpdir,
        "https://s3.amazonaws.com/model-server/models/resnet50_ssd/synset.txt")
    _download_file(
        tmpdir,
        "https://s3.amazonaws.com/model-server/models/resnet50_ssd/signature.json"
    )
    _download_file(
        tmpdir,
        "https://s3.amazonaws.com/model-server/models/resnet50_ssd/ssd_service.py"
    )

    # Download input image.
    _download_file(
        tmpdir,
        "https://s3.amazonaws.com/model-server/models/resnet50_ssd/street.jpg")

    # Export the model.
    print("Exporting the mxnet model server model...")
    sys.argv = ['mxnet-model-export']
    sys.argv.append("--model-name")
    sys.argv.append("{}/resnet50_ssd_model".format(tmpdir))
    sys.argv.append("--model-path")
    sys.argv.append(tmpdir)
    sys.argv.append("--service-file-path")
    sys.argv.append("{}/ssd_service.py".format(tmpdir))
    export_model.export()

    # Start the mxnet model server for SSD
    print("Starting SSD MXNet Model Server for test..")

    # Set argv parameters
    sys.argv = ['mxnet-model-server']
    sys.argv.append("--models")
    sys.argv.append("SSD={}/resnet50_ssd_model.model".format(tmpdir))
    sys.argv.append("--service")
    sys.argv.append("{}/ssd_service.py".format(tmpdir))
    mxnet_model_server.start_serving()
def setup_onnx_integ(tmpdir):
    """
        Downloads and Setup the onnx integration tests.
    :return: None
    """
    # Download the files required for onnx integ tests.
    _download_file(
        tmpdir,
        "https://s3.amazonaws.com/model-server/models/onnx-squeezenet/squeezenet.onnx"
    )
    _download_file(
        tmpdir,
        "https://s3.amazonaws.com/model-server/models/onnx-squeezenet/signature.json"
    )
    _download_file(
        tmpdir,
        "https://s3.amazonaws.com/model-server/models/onnx-squeezenet/synset.txt"
    )

    # Download input image.
    _download_file(
        tmpdir,
        "https://upload.wikimedia.org/wikipedia/commons/8/8f/Cute-kittens-12929201-1600-1200.jpg"
    )

    # Export the model.
    print("Exporting the mxnet model server model...")
    sys.argv = ['mxnet-model-export']
    sys.argv.append("--model-name")
    sys.argv.append("{}/squeezenet".format(tmpdir))
    sys.argv.append("--model-path")
    sys.argv.append(tmpdir)
    export_model.export()

    # Start the mxnet model server for onnx integ tests.
    print("Starting MXNet Model Server for onnx integ test..")

    # Set argv parameters
    sys.argv = ['mxnet-model-server']
    sys.argv.append("--models")
    sys.argv.append("squeezenet={}/squeezenet.model".format(tmpdir))
    mxnet_model_server.start_serving()