Example #1
0
def main():
    if len(sys.argv) < 2:
        print_usage()

    command = sys.argv[1]
    args = sys.argv[2:]

    if command in HELP_OPTIONS or command == 'help':
        if args:
            print_usage(command=args[0])
        else:
            print_usage()

    if command not in COMMANDS:
        print_usage(error="%s: unrecognized command" % command)

    mod = COMMANDS[command]

    try:
        options, args = parse_options(getattr(mod, 'OPTIONS', {}), args)

        if 'help' in options:
            print_usage(command=command)

        mod.command(options, args)
    except CommandInvocationError as exc:
        print_usage(command=command, error=str(exc))
    except CommandExecutionError as exc:
        print(str(exc))
Example #2
0
import tvm
from PIL import Image
from tvm import te
from tvm.contrib import graph_runtime
from tvm import relay
from tvm.runtime import container
from tvm.runtime import vm as vm_rt
from tvm.relay import testing
from tvm.relay import vm
from tvm.relay.op.contrib import arm_compute_lib
from tvm.contrib.download import download_testdata
from util import load_test_image, build_module, update_lib, get_cpu_op_count, download_model_zoo, parse_options, get_device_arch, get_device_attributes, get_device_type, get_tvm_target
import sys

argv = sys.argv[1:]
device = parse_options(argv)

model_dir = '/mobilenet_v2_1.0_224/'
model_name = 'mobilenet_v2_1.0_224.tflite'

model_dir = download_model_zoo(model_dir, model_name)

tflite_model_file = os.path.join(model_dir, model_name)
tflite_model_buf = open(tflite_model_file, "rb").read()

# Get TFLite model from buffer
try:
    import tflite
    tflite_model = tflite.Model.GetRootAsModel(tflite_model_buf, 0)
except AttributeError:
    import tflite.Model
import os
import file_io

import util


def convert_to_hdf5(data_folder, tgt=None):
    if tgt is None:
        tgt = os.path.join(data_folder, "scene.h5")

    scene = dict()
    scene["LF"] = file_io.read_lightfield(data_folder)
    params = file_io.read_parameters(data_folder)

    if params["category"] != "test":
        scene["disp_highres"] = file_io.read_disparity(data_folder, highres=True)
        scene["disp_lowres"] = file_io.read_disparity(data_folder, highres=False)
        scene["depth_highres"] = file_io.read_depth(data_folder, highres=True)
        scene["depth_lowres"] = file_io.read_depth(data_folder, highres=False)

    file_io.write_hdf5(scene, tgt)


if __name__ == '__main__':
    data_folders = util.parse_options()

    for data_folder in data_folders:
        print "converting: %s" % data_folder
        convert_to_hdf5(data_folder)