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