Esempio n. 1
0
                                                     config,
                                                     reuse=True)
    if loss_type == 'g':
        return losses['g_loss']
    elif loss_type == 'd':
        return losses['d_loss']
    else:
        raise ValueError('loss type is not supported.')


if __name__ == "__main__":
    config = ng.Config('inpaint.yml')
    if config.GPU_ID != -1:
        ng.set_gpus(config.GPU_ID)
    else:
        ng.get_gpus(config.NUM_GPUS)
    # training data
    with open(config.DATA_FLIST[config.DATASET][0]) as f:
        fnames = f.read().splitlines()
    data = ng.data.DataFromFNames(fnames,
                                  config.IMG_SHAPES,
                                  random_crop=config.RANDOM_CROP)
    images = data.data_pipeline(config.BATCH_SIZE)
    # main model
    model = InpaintCAModel()
    g_vars, d_vars, losses = model.build_graph_with_losses(images,
                                                           config=config)
    # validation images
    if config.VAL:
        with open(config.DATA_FLIST[config.DATASET][1]) as f:
            val_fnames = f.read().splitlines()
                    default=None,
                    type=str,
                    help='filename list to use as dataset')
parser.add_argument('--height',
                    default=256,
                    type=int,
                    help='height of images in data flist')
parser.add_argument('--width',
                    default=256,
                    type=int,
                    help='width of images in data flist')
parser.add_argument('--blend', action='store_true')

if __name__ == "__main__":

    ng.get_gpus(1, dedicated=False)
    args = parser.parse_args()
    config = ng.Config(args.config)
    logger = logging.getLogger()
    invert_mask = str2bool(args.invert_mask)
    model = InpaintCAModel()

    if args.image is not None:
        image = cv2.imread(args.image)
        h, w, _ = image.shape
        assert image.shape == mask.shape
    else:
        if args.flist is None:
            flist = config.DATA_FLIST[config.DATASET][1]
            shapes = config.IMG_SHAPES
        else:
Esempio n. 3
0
    help='The height of images should be defined, otherwise batch mode is not'
    ' supported.')
parser.add_argument(
    '--image_width',
    default=-1,
    type=int,
    help='The width of images should be defined, otherwise batch mode is not'
    ' supported.')
parser.add_argument('--checkpoint_dir',
                    default='',
                    type=str,
                    help='The directory of tensorflow checkpoint.')

if __name__ == "__main__":
    FLAGS = ng.Config('inpaint.yml')
    ng.get_gpus(1)
    # os.environ['CUDA_VISIBLE_DEVICES'] =''
    args = parser.parse_args()

    sess_config = tf.ConfigProto()
    sess_config.gpu_options.allow_growth = True
    sess = tf.Session(config=sess_config)

    model = InpaintCAModel()
    input_image_ph = tf.placeholder(tf.float32,
                                    shape=(1, args.image_height,
                                           args.image_width * 2, 3))
    output = model.build_server_graph(FLAGS, input_image_ph)
    output = (output + 1.) * 127.5
    output = tf.reverse(output, [-1])
    output = tf.saturate_cast(output, tf.uint8)
Esempio n. 4
0
    core.seg_limit = 4000000  #// 10 # 보통 이게 더 큼
    core.compl_limit = 1000000  #// 10 #

    segnet_yml = 'segnet/seg48_4[553].yml'  # segnet configuration
    segnet_model_path = 'segnet/seg48_4[553].h5'  # saved segnet model

    complnet_ckpt_dir = 'v2_180923'  # saved complnets directory
    #--------------------------------------------
    # for segnet
    with open(segnet_yml, 'r') as f:
        config = yaml.load(f)

    # for complnet
    complnet = InpaintCAModel('v2')

    ng.get_gpus(1, False)  #TODO: 단 한 번만 호출할 것.
    #--------------------------------------------
    dilate_kernel = core.rect5

    if not os.path.isdir('./cleaned'):
        os.mkdir('./cleaned')
    app = QtWidgets.QApplication(sys.argv)
    screen = app.primaryScreen()
    print('Screen: %s' % screen.name())
    size = screen.size()
    print('Size: %d x %d' % (size.width(), size.height()))
    rect = screen.availableGeometry()
    print('Available: %d x %d' % (rect.width(), rect.height()))
    MainWindow = MyMainScreen()
    MainWindow.show()
    #app.exec_()