예제 #1
0
                except Exception as e:
                    print(e)
                    sys.exit()

                average_elapsed_time = np.sum(elapsed_times) / (TEST_TRIAL *
                                                                batch_num)
                result[lr][node] = average_elapsed_time

                print(
                    '[Resolution: Size ({}x{}), OutputNode: {}] / Inference time per frame(sec) {} / Max-Min(sec) {}'
                    .format(
                        t_w, t_h, node, round(average_elapsed_time, 4),
                        round(
                            np.max(elapsed_times) - np.min(elapsed_times), 4)))

        for node in self.output_nodes:
            log = ''
            log += '{}\t'.format(node)
            for lr in self.node2res[node]:
                log += '{}\t'.format(round(result[lr][node], 4))
            summary_logger.info(log)


if __name__ == "__main__":
    model = MultiNetwork(template.get_nas_config(opt.quality))
    dataset = DatasetForDASH(opt)
    evaluator = Tester(opt, model, dataset)
    #evaluator.evaluate_quality()
    evaluator.evaluate_runtime()
예제 #2
0
        for i in range(idx):
            res = self.body[i](res)
        res = self.body_end(res)
        res += x

        if self.scale > 1:
            x = self.upscale(res)
        else:
            x = res

        x = self.tail(x)

        return x

if __name__ == "__main__":
    """Simple test code for model"""
    model = MultiNetwork(template.get_nas_config('low')).to('cuda:0')
    model.setTargetScale(4)
    dataset = DatasetForDASH(opt)
    dataset.setTargetLR(240)
    dataset.setDatasetType('train')
    #print(len(dataset))
    #print(model.getOutputNodes(4))
    dataloader = data.DataLoader(dataset=dataset, num_workers=opt.num_thread, batch_size=opt.num_batch, pin_memory=True, shuffle=True)

    for iteration, batch in enumerate(dataloader):
        batch[0] = batch[0].cuda()
        output = model(batch[0])
        print(batch[0].size(), output.size())
        break