text
stringlengths
1
93.6k
def validate(subnet, train_loader, valid_loader, test_meter):
# BN calibration
subnet.eval()
logger.info("Calibrating BN running statistics.")
subnet.reset_running_stats_for_calibration()
for cur_iter, (inputs, _) in enumerate(train_loader):
if cur_iter >= cfg.BIGNAS.POST_BN_CALIBRATION_BATCH_NUM:
break
inputs = inputs.cuda()
subnet(inputs) # forward only
top1_err, top5_err = test_epoch(subnet, valid_loader, test_meter)
return top1_err, top5_err
def test_epoch(subnet, test_loader, test_meter):
subnet.eval()
test_meter.reset(True)
test_meter.iter_tic()
for cur_iter, (inputs, labels) in enumerate(test_loader):
inputs, labels = inputs.cuda(), labels.cuda(non_blocking=True)
preds = subnet(inputs)
top1_err, top5_err = meter.topk_errors(preds, labels, [1, 5])
top1_err, top5_err = top1_err.item(), top5_err.item()
test_meter.iter_toc()
test_meter.update_stats(top1_err, top5_err, inputs.size(0) * cfg.NUM_GPUS)
test_meter.log_iter_stats(0, cur_iter)
test_meter.iter_tic()
top1_err = test_meter.mb_top1_err.get_win_avg()
top5_err = test_meter.mb_top5_err.get_win_avg()
# self.writer.add_scalar('val/top1_error', test_meter.mb_top1_err.get_win_avg(), cur_epoch)
# self.writer.add_scalar('val/top5_error', test_meter.mb_top5_err.get_win_avg(), cur_epoch)
# Log epoch stats
test_meter.log_epoch_stats(0)
# test_meter.reset()
return top1_err, top5_err
if __name__ == "__main__":
main()
# <FILESEP>
import os
import fontforge
import psMat;
FONTNAME = 'vscode-adjusted-icons'
DIR = './icons'
if __name__ == '__main__':
font = fontforge.font()
font.fontname = FONTNAME
font.familyname = FONTNAME
font.copyright = 'Some of symbols are imported from FontAwesome SVGs'
font.fullname = FONTNAME
try:
for svg_file in os.listdir(DIR):
if svg_file.find('.svg') == -1: # is not a svg file
continue
g = font.createChar(int(svg_file.split('-')[0], base=16))
print(svg_file)
g.importOutlines(
os.path.join(DIR, svg_file), ('removeoverlap', 'correctdir'))
g.removeOverlap()
move_mat = psMat.translate( -100,0 )
g.transform(move_mat)
scale_mat = psMat.scale(1.1)
g.transform(scale_mat)
except ValueError:
print('"%s" is not a valid file name.' % svg_file)
print('File name should be in format "hexnumber-name.svg". e.g. "ff5a-search.svg"')
except Exception as e:
raise e
font.generate('%s.ttf' % FONTNAME)
# <FILESEP>
#!/usr/bin/env python
#
# Copyright 2020 Doug Blanding (dblanding@gmail.com)
#
# This file is part of cadViewer.
# The latest version of this file can be found at:
# //https://github.com/dblanding/cadviewer
#
# cadViewer is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# cadViewer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# if not, write to the Free Software Foundation, Inc.