This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for x, y in zip(*[iter(line1)] * 2): | |
#line1(x0,y0,x1,y1) | |
#line1 -> (x0, y0), (x1, y1) | |
#. zip(*[iter(line1)] * 2) | |
#->zip(<tuple_iterator object at 0x10dafdb00>, <tuple_iterator object at 0x10dafdb00>) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bb_intersection_over_union(boxA, boxB): | |
# determine the (x, y)-coordinates of the intersection rectangle | |
xA = max(boxA[0], boxB[0]) | |
yA = max(boxA[1], boxB[1]) | |
xB = min(boxA[2], boxB[2]) | |
yB = min(boxA[3], boxB[3]) | |
# compute the area of intersection rectangle | |
interArea = max(0, xB - xA + 1) * max(0, yB - yA + 1) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cProfile | |
cProfile.runctx("yolo_data[13]", globals(), None) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cProfile, pstats | |
from pstats import SortKey | |
sortby = SortKey.CUMULATIVE | |
with cProfile.Profile() as pr: | |
# your code here | |
ps = pstats.Stats(pr).sort_stats(sortby) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _make_blocks(self, block_nums, layer_num, stride=2, block=RiRBlock): | |
layers = nn.Sequential() | |
in_channel = self.base | |
for block in range(block_nums): | |
layers.add_module("RiR_Block{}".format(block), RiRBlock(in_channel, self.base, layer_num, stride)) | |
in_channel = self.base | |
self.base *= 2 | |
return layers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def compute_mean_std(cifar100_dataset): | |
"""compute the mean and std of cifar100 dataset | |
Args: | |
cifar100_training_dataset or cifar100_test_dataset | |
witch derived from class torch.utils.data | |
Returns: | |
a tuple contains mean, std value of entire dataset | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function, absolute_import | |
__all__ = ['accuracy'] | |
def accuracy(output, target, topk=(1,)): | |
"""Computes the precision@k for the specified values of k""" | |
maxk = max(topk) | |
batch_size = target.size(0) | |
_, pred = output.topk(maxk, 1, True, True) |