Spaces:
Runtime error
Runtime error
File size: 1,033 Bytes
67d65ce |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# -*- coding: utf-8 -*-
"""
@author: Van Duc <vvduc03@gmail.com>
"""
"""Import necessary packages"""
import torch
from torchvision import transforms
# Image and caption root
train = 'data/train'
val = 'data/val'
test = 'data/test'
# Image and caption path
captions = 'captions.json'
images = 'image'
# Log path and save path
log_path = 'logdir'
save_path = 'savedir'
# Device
device = 'cuda' if torch.cuda.is_available() else 'cpu'
# All Parameters you can tune
lr = 3e-4
epochs = 100
embed_size = 256
hidden_size = 256
num_layer = 1
num_workers = 4
batch_size = 16
# Save, load model
load_model = True
save_model = True
# Compose transform image
transform = transforms.Compose(
[
transforms.Resize((224, 224)),
transforms.RandomHorizontalFlip(0.5),
transforms.RandomGrayscale(0.05),
transforms.ToTensor(),
transforms.Normalize((0.485, 0.456, 0.406), (0.229, 0.224, 0.225)),
# transforms.Normalize((0.5, 0.5, 0.5), (1., 1., 1.)),
]
) |