def run(self):
        from architecture.sub_model import load_sub_models
        sub_models = load_sub_models(self._weights_path, self._input_size)
        sub_model = sub_models[self._model_id]
        # sub_model.summary()

        flag = 0
        while True:
            if len(self._input_conn) == flag and flag != 0:
                print("{} conv is over".format(self._model_id))
                break

            if self._input_conn:
                # print("{} conv conn is not empty".format(self._model_id))
                # test_img = self._input_conn.get()
                test_img = self._input_conn[flag]

                # res_img = self.predict(sub_model, test_img)
                pre_tile_img_set = []
                for h in range(len(test_img)):
                    pre_tiles = []
                    for w in range(len(test_img[0])):
                        curr_tile = test_img[h][w]
                        pre_img = self.predict(sub_model, curr_tile)
                        pre_tiles.append(pre_img)
                    pre_tile_img_set.append(pre_tiles)

                self._output_conn.append(pre_tile_img_set)
                flag += 1
                self._start_flag.value -= 1
                self._next_flag.value += 1

            else:
                time.sleep(self._sleep_time)
    def run(self):
        from architecture.sub_model import load_sub_models
        sub_models = load_sub_models(self._weights_path, self._input_size)
        sub_model = sub_models[self._model_id]
        # sub_model.summary()

        flag = 0
        while True:
            if len(self._input_conn) == flag:
                print("queue is empty")
                break

            if self._input_conn:
                # test_img = self._input_conn.get()
                test_img = self._input_conn[flag]

                # res_img = self.predict(sub_model, test_img)
                pre_tile_img_set = []
                for h in range(len(test_img)):
                    pre_tiles = []
                    for w in range(len(test_img[0])):
                        curr_tile = test_img[h][w]
                        pre_img = self.predict(sub_model, curr_tile)
                        pre_tiles.append(pre_img)
                    pre_tile_img_set.append(pre_tiles)

                self._output_conn.append(pre_tile_img_set)
                flag += 1
                self._start_flag.value += 1
Example #3
0
    def run(self):
        from architecture.sub_model import load_sub_models
        sub_models = load_sub_models(self._weights_path, self._input_size)
        sub_model = sub_models[self._model_id]
        sub_model.summary()

        flag = 0
        while True:
            if self._start_flag.value:
                print("{} conv conn is not empty".format(self._model_id))
                # test_img = self._input_conn.get()
                test_img = self._input_conn[flag]

                # if ((self._input_conn.qsize()) == 0):
                if len(self._input_conn) == flag:
                    print ("queue is empty")
                    break

                res_img = self.predict(sub_model, test_img)
                print ("the shape of res img{}".format(res_img.shape))
                self._output_conn.append(res_img)
                flag += 1
                self._start_flag.value -= 1
                self._next_flag.value += 1

            else:
                if flag != 0:
                    print ("{} conv is over".format(self._model_id))
                    break
                else:
                    time.sleep(self._sleep_time)
                    print("{} conv is wating:{}".format(self._model_id, self._start_flag.value))
    def run(self):
        from architecture.sub_model import load_sub_models
        sub_models = load_sub_models(self._weights_path, self._input_size)
        sub_model = sub_models[self._model_id]
        # sub_model.summary()

        flag = 0
        while True:
            if len(self._input_conn) == flag and flag != 0:
                print("{} conv is over".format(self._model_id))
                break

            if self._start_flag.value:
                # test_img = self._input_conn.get()
                test_img = self._input_conn[flag]
                crop_part = self._crop_conn[flag]

                # res_img = self.predict(sub_model, test_img, crop_part)[0]
                pre_tile_img_set = []
                for h in range(len(test_img)):
                    pre_tiles = []
                    for w in range(len(test_img[0])):
                        curr_tile = test_img[h][w]
                        crop_tile = crop_part[h][w]
                        pre_img = self.predict(sub_model, curr_tile,
                                               crop_tile)[0]
                        pre_tiles.append(pre_img)
                    pre_tile_img_set.append(pre_tiles)

                res_img = self.tile_set2img(pre_tile_img_set, self._overlap_px)
                # print ("the shape of res img{}".format(res_img.shape))
                self.output_img(self._name_list[flag], res_img,
                                self._output_dir)
                self._output_conn.append(res_img)
                flag += 1
                self._start_flag.value -= 1

            else:
                if flag != 0:
                    print("{} conv is over".format(self._model_id))
                    break
                else:
                    time.sleep(self._sleep_time)
Example #5
0
    def run(self):
        from architecture.sub_model import load_sub_models
        sub_models = load_sub_models(self._weights_path,self._input_size)
        sub_model = sub_models[self._model_id]
        sub_model.summary()

        flag = 0
        while True:
            # test_img = self._input_conn.get()
            test_img = self._input_conn[flag]

            # if ((self._input_conn.qsize()) == 0):
            if len(self._input_conn) == flag+1:
                print ("queue is empty")
                break

            res_img = self.predict(sub_model, test_img)
            print("the shape of res img{}".format(res_img.shape))
            self._output_conn.append(res_img)
            flag += 1
            self._start_flag.value += 1
            print("{} ===== predict done".format(self._model_id))
        print ("===========================self._start_flag: {}".format(self._start_flag.value))