text
stringlengths
1
93.6k
vqa_result = evaluation(model_without_ddp, test_loader, device, config)
result_file = save_result(vqa_result, args.result_dir, 'vqa_result', client=client)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--config', default='./configs/vqa.yaml')
parser.add_argument('--output_dir', default='output/VQA')
parser.add_argument('--evaluate', action='store_true')
parser.add_argument('--device', default='cuda')
parser.add_argument('--seed', default=42, type=int)
parser.add_argument('--world_size', default=1, type=int, help='number of distributed processes')
parser.add_argument('--dist_url', default='env://', help='url used to set up distributed training')
parser.add_argument('--distributed', default=True, type=bool)
parser.add_argument('--use_ceph', action='store_true')
parser.add_argument('--pretrained', default='pretrained/model_base_vqa_capfilt_large.pth', type=str)
parser.add_argument('--w_sp_attn', default=1.44e-2, type=float, help='regularization coefficient for attn')
parser.add_argument('--w_sp_mlp', default=5e-4, type=float, help='regularization coefficient for mlp')
parser.add_argument('--epoch', default=5, type=int, help='number of epoches')
parser.add_argument('--p', default=0.5, type=float, help='total compression ratio')
parser.add_argument('--amp', action='store_true')
args = parser.parse_args()
config = yaml.load(open(args.config, 'r'), Loader=yaml.Loader)
args.result_dir = os.path.join(args.output_dir, 'result')
if not args.use_ceph:
Path(args.output_dir).mkdir(parents=True, exist_ok=True)
Path(args.result_dir).mkdir(parents=True, exist_ok=True)
yaml.dump(config, open(os.path.join(args.output_dir, 'config.yaml'), 'w'))
client=None
else:
client = Client('~/petreloss.conf', enable_mc=True)
client.put(os.path.join('s3://BucketName/ProjectName', args.output_dir, 'config.yaml'), yaml.dump(config))
main(args, config, client)
# <FILESEP>
import os
import re
from urllib.request import urlopen
import youtube_dl
# SETTINGS
# Lynda.com LOGIN details
USERNAME = 'your-username'
PASSWORD = 'your-password'
# Location of the list of course URLs
LINKS = 'links.txt'
# Location of archive file
ARCHIVE = '../archive.txt'
# Download subtitles of the videos
SUBTITLES = True
# Download accelerator
EXTERNAL_DL = 'aria2c'
HOME_DIR = os.getcwd()
def move_to_course_directory(title):
"""Check if current directory is home directory. If not, change to it.
Make a course directory and move to it.
If course directory already exists, just move to it.
If everything fails break the program.
"""
# Move to home directory if we are somewhere else (e.g. course subdir)
if os.getcwd() != HOME_DIR:
os.chdir(HOME_DIR)
try:
# Make a directory with course name
os.mkdir(title)
os.chdir(title)
except FileExistsError:
# Position yourself in course directory
os.chdir(title)
except:
print('Could not create subdirectory for the course: {}'.format(title))
def get_title(url):
""" Get course title for creation of the video folder.
"""
try:
# REGEX pattern for URL and Course name
pattern = re.compile(r'(http[s]?://?[^/\s]+/[^/\s]+/)(.*)/(.*)')
# Get the COURSE NAME for new folder
title = pattern.search(url).group(2)
return (title)
except:
print('Could not parse the course URL.')