forked from RoyalSkye/Image-Caption
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_input_files.py
executable file
·28 lines (25 loc) · 1.54 KB
/
create_input_files.py
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
#!/usr/bin/env python3
from utils import create_input_files
import argparse
import os
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Image_Captioning')
parser.add_argument('--dataset', default="flickr8k", help='Default MSCOCO 14 Dataset.')
parser.add_argument('--karpathy_json_path', default="/kaggle/input/karpathy-splits/dataset_flickr8k.json",
help='path of captions dataset.')
parser.add_argument('--image_folder', default="/kaggle/input/flickr8k/Images", help='path of image dataset.')
parser.add_argument('--captions_per_image', type=int, default=5, help='How many captions each image has?')
parser.add_argument('--min_word_freq', type=int, default=5, help='the minimum frequency of words')
parser.add_argument('--output_folder', default='./dataset/generated_data', help='output filepath.')
parser.add_argument('--max_len', type=int, default=50, help='the maximum length of each caption.')
args = parser.parse_args()
if not (os.path.exists(args.output_folder) and os.path.isdir(args.output_folder)):
os.makedirs(args.output_folder)
# Create input files (along with word map)
create_input_files(dataset=args.dataset,
karpathy_json_path=args.karpathy_json_path,
image_folder=args.image_folder,
captions_per_image=args.captions_per_image,
min_word_freq=args.min_word_freq,
output_folder=args.output_folder,
max_len=args.max_len)