Beispiel #1
0
    def __init__(self, FLAGS, darknet=None):
        self.ntrain = 0
        if isinstance(FLAGS, dict):
            defaultSettings = {"binary": "./bin/", "config": "./cfg/", "batch": 16, "threshold": 0.1, "train": False,
                               "verbalise": False, "gpu": 0.0}
            defaultSettings.update(FLAGS)
            FLAGS = dotdict(defaultSettings)

        if darknet is None:
            darknet = Darknet(FLAGS)
            self.ntrain = len(darknet.layers)
        # self.ntrain = 1

        self.darknet = darknet
        args = [darknet.meta, FLAGS]
        self.num_layer = len(darknet.layers)
        self.framework = create_framework(*args)

        self.meta = darknet.meta
        self.FLAGS = FLAGS

        self.say('\nBuilding net ...')
        start = time.time()
        self.graph = tf.Graph()
        with self.graph.as_default() as g:
            self.build_forward()
            self.setup_meta_ops()
        self.say('Finished in {}s\n'.format(
            time.time() - start))
Beispiel #2
0
    def __init__(self, FLAGS, darknet=None):
        if darknet is None: darknet = Darknet(FLAGS)
        self.framework = create_framework(darknet.meta['type'])
        self.meta = self.framework.metaprocess(darknet.meta)
        self.darknet = darknet
        self.FLAGS = FLAGS

        self.say('\nCompiling net & fill in parameters...')
        start = time.time()
        self.graph = tf.Graph()
        with self.graph.as_default() as g:
            self.build_forward()
            self.setup_meta_ops()
        self.say('Finished in {}s\n'.format(time.time() - start))
Beispiel #3
0
    def __init__(self, FLAGS, darknet=None):
        self.ntrain = 0
        if darknet is None:
            darknet = Darknet(FLAGS)
            self.ntrain = len(darknet.layers)

        self.darknet = darknet
        args = [darknet.meta, FLAGS]
        self.num_layer = len(darknet.layers)
        self.framework = create_framework(*args)

        self.meta = darknet.meta
        self.FLAGS = FLAGS

        self.say('\nBuilding net ...')
        start = time.time()
        self.graph = tf.Graph()
        with self.graph.as_default() as g:
            self.build_forward()
            self.setup_meta_ops()
        self.say('Finished in {}s\n'.format(time.time() - start))
Beispiel #4
0
    def __init__(self, FLAGS, darknet=None):
        self.ntrain = 0
        if isinstance(FLAGS, dict):
            defaultSettings = {
                "binary": "./bin/",
                "config": "./cfg/",
                "batch": 16,
                "threshold": 0.1,
                "threshold_max": 1.0,
                "train": False,
                "verbalise": False,
                "gpu": 0.0,
                "log": "",
                "use_gpu_num": "",
                "show_device_info": False,
                "test_output": "",
                "pred_grasp": False
            }
            defaultSettings.update(FLAGS)
            FLAGS = dotdict(defaultSettings)

        if darknet is None:
            darknet = Darknet(FLAGS)
            self.ntrain = len(darknet.layers)
            #self.ntrain = 1
        self.FLAGS = FLAGS
        if self.FLAGS.use_gpu_num != "":
            with tf.device("/gpu:" + self.FLAGS.use_gpu_num):
                self.darknet = darknet
                args = [darknet.meta, FLAGS]
                self.num_layer = len(darknet.layers)
                self.framework = create_framework(*args)
                self.meta = darknet.meta
                self.say('\nBuilding net ...')
                start = time.time()
                self.graph = tf.Graph()
        else:
            self.darknet = darknet
            args = [darknet.meta, FLAGS]
            self.num_layer = len(darknet.layers)
            self.framework = create_framework(*args)
            self.meta = darknet.meta
            self.say('\nBuilding net ...')
            start = time.time()
            self.graph = tf.Graph()

        if self.FLAGS.log != "":
            self.setup_log()

        with self.graph.as_default() as g:
            if self.FLAGS.use_gpu_num != "":
                with tf.device("/gpu:" + self.FLAGS.use_gpu_num):
                    self.build_forward()
                    self.setup_meta_ops()
            else:
                self.build_forward()
                self.setup_meta_ops()

        self.pred_grasp = False
        if self.FLAGS.pred_grasp and self.FLAGS.train != True:
            path = self.FLAGS.grasp_backup
            name = self.FLAGS.grasp_net_name
            self.GraspPredictNet = GraspWithYolo(path, name)
            self.pred_grasp = True

        self.say('Finished in {}s\n'.format(time.time() - start))