Ejemplo n.º 1
0
def selfie2anime():
    img_id = os.environ['id']
    result_id = os.environ['result']
    

    parser = get_parser()
    args = parser.parse_args("--phase test".split())

    with tf.Session(config=tf.ConfigProto(allow_soft_placement=True)) as sess:
        #sess.reuse_variables()
        gan = UGATIT(sess, args)

        # build graph
        gan.build_model()

        # download target img
        download_path = os.path.join(img_path, img_id)

        download_image(images_bucket, img_id, dest=download_path)
        dataset_tool.create_from_images(record_path, img_path, True)
        # os.remove(del_record)
        
        img = gan.infer(download_path)

        image_url = upload_image(img, result_id)

    return download_path, img
Ejemplo n.º 2
0
 def test_default_argment(self):
     parser = main.get_parser().parse_args()
     self.assertEqual(parser.epoch, 100)
     self.assertEqual(parser.learning_rate, 0.0001)
     self.assertEqual(parser.train_rate, 0.8)
     self.assertEqual(parser.batch_size, 20)
     self.assertEqual(parser.l2, 0.05)
Ejemplo n.º 3
0
def main():
    name = sys.argv[1]
    t = sys.argv[2]
    value = float(sys.argv[3])
    is_int = bool(sys.argv[4])
    training_data, testing_data, validation_data = load_data(
        "data4students.mat")

    #if is_int:
    #   rand = np.random.random_integers(low, high, samples)
    #else:
    print("Testing param values for {}={}".format(name, value))

    #if is_int:
    #    params_in = [str(np.random.randint(2000)) for i in range(value)]
    #else:
    # params_in = [str(value)]

    parser = get_parser()
    params = parser.parse_args([
        "--timestamp",
        str(t), "--lr_scheduler", name, "--decay_rate",
        str(value)
    ])
    #params = parser.parse_args(["--timestamp", str(t), "--{}".format(name), str(value)])
    train_and_report(training_data, validation_data, params)
Ejemplo n.º 4
0
def main():
    if len(sys.argv) != 2:
        print("Please specify a path to a .mat file containing the testing data")
        return

    data = load_data(sys.argv[1])

    parser = get_parser()
    params = parser.parse_args([])

    model = Model(None, None, params)
    model.build()
    model.model.load_weights('trained_model.h5')

    predictions = test_network(model.model, data.data)

    print(predictions)
    correct = 0

    for i, datum in enumerate(data.targets):
        datum = list(datum).index(1)

        print('Prediction for image ' + str(i) + ': ' + str(predictions[i]) + ', expected ' + str(datum))
        correct += 1 if predictions[i] == datum else 0

    print('Overall CR: ' + str(correct / len(predictions) * 100) + '%')
Ejemplo n.º 5
0
def get_parameter():
    parser = entry.get_parser()
    parser.add_argument('--old', type=str, default='')
    parser.add_argument('--new', type=str, default='')
    parser.add_argument('--mapping_from', '--mf', type=str, default='')
    parser.add_argument('--mapping_to', '--mt', type=str, default='')
    parser.add_argument('--verbose_list', default='ratio,sep', type=str)
    args = parser.parse_args()
    if isinstance(args.verbose_list, str):
        args.verbose_list = [x.strip() for x in args.verbose_list.split(',')]
    if isinstance(args.keyword, str):
        args.keyword = [x.strip() for x in args.keyword.split(',')]
    return args
Ejemplo n.º 6
0
def test_command_sqs():
    parser = get_parser()
    args = parser.parse_args('sqs --queues queue1 queue2'.split())
    assert args.func == start_sqs
    assert args.queues == ['queue1', 'queue2']
Ejemplo n.º 7
0
def test_command_sqs():
    parser = get_parser()
    args = parser.parse_args('es --ip ip_add --domain foo'.split())
    assert args.func == start_es
    assert args.ip == 'ip_add'
    assert args.domain == 'foo'