{"nwo":"CoinCheung\/BiSeNet","sha":"f9231b7c971413e6ebdfcd961fbea53417b18851","path":"lib\/models\/resnet.py","language":"python","identifier":"conv3x3","parameters":"(in_planes, out_planes, stride=1)","argument_list":"","return_statement":"return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride,\n padding=1, bias=False)","docstring":"3x3 convolution with padding","docstring_summary":"3x3 convolution with padding","docstring_tokens":["3x3","convolution","with","padding"],"function":"def conv3x3(in_planes, out_planes, stride=1):\n \"\"\"3x3 convolution with padding\"\"\"\n return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride,\n padding=1, bias=False)","function_tokens":["def","conv3x3","(","in_planes",",","out_planes",",","stride","=","1",")",":","return","nn",".","Conv2d","(","in_planes",",","out_planes",",","kernel_size","=","3",",","stride","=","stride",",","padding","=","1",",","bias","=","False",")"],"url":"https:\/\/github.com\/CoinCheung\/BiSeNet\/blob\/f9231b7c971413e6ebdfcd961fbea53417b18851\/lib\/models\/resnet.py#L14-L17"} {"nwo":"CoinCheung\/BiSeNet","sha":"f9231b7c971413e6ebdfcd961fbea53417b18851","path":"old\/resnet.py","language":"python","identifier":"conv3x3","parameters":"(in_planes, out_planes, stride=1)","argument_list":"","return_statement":"return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride,\n padding=1, bias=False)","docstring":"3x3 convolution with padding","docstring_summary":"3x3 convolution with padding","docstring_tokens":["3x3","convolution","with","padding"],"function":"def conv3x3(in_planes, out_planes, stride=1):\n \"\"\"3x3 convolution with padding\"\"\"\n return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride,\n padding=1, bias=False)","function_tokens":["def","conv3x3","(","in_planes",",","out_planes",",","stride","=","1",")",":","return","nn",".","Conv2d","(","in_planes",",","out_planes",",","kernel_size","=","3",",","stride","=","stride",",","padding","=","1",",","bias","=","False",")"],"url":"https:\/\/github.com\/CoinCheung\/BiSeNet\/blob\/f9231b7c971413e6ebdfcd961fbea53417b18851\/old\/resnet.py#L14-L17"} {"nwo":"CoinCheung\/BiSeNet","sha":"f9231b7c971413e6ebdfcd961fbea53417b18851","path":"old\/modules\/bn.py","language":"python","identifier":"ABN.__init__","parameters":"(self, num_features, eps=1e-5, momentum=0.1, affine=True, activation=\"leaky_relu\", slope=0.01)","argument_list":"","return_statement":"","docstring":"Creates an Activated Batch Normalization module\n\n Parameters\n ----------\n num_features : int\n Number of feature channels in the input and output.\n eps : float\n Small constant to prevent numerical issues.\n momentum : float\n Momentum factor applied to compute running statistics as.\n affine : bool\n If `True` apply learned scale and shift transformation after normalization.\n activation : str\n Name of the activation functions, one of: `leaky_relu`, `elu` or `none`.\n slope : float\n Negative slope for the `leaky_relu` activation.","docstring_summary":"Creates an Activated Batch Normalization module","docstring_tokens":["Creates","an","Activated","Batch","Normalization","module"],"function":"def __init__(self, num_features, eps=1e-5, momentum=0.1, affine=True, activation=\"leaky_relu\", slope=0.01):\n \"\"\"Creates an Activated Batch Normalization module\n\n Parameters\n ----------\n num_features : int\n Number of feature channels in the input and output.\n eps : float\n Small constant to prevent numerical issues.\n momentum : float\n Momentum factor applied to compute running statistics as.\n affine : bool\n If `True` apply learned scale and shift transformation after normalization.\n activation : str\n Name of the activation functions, one of: `leaky_relu`, `elu` or `none`.\n slope : float\n Negative slope for the `leaky_relu` activation.\n \"\"\"\n super(ABN, self).__init__()\n self.num_features = num_features\n self.affine = affine\n self.eps = eps\n self.momentum = momentum\n self.activation = activation\n self.slope = slope\n if self.affine:\n self.weight = nn.Parameter(torch.ones(num_features))\n self.bias = nn.Parameter(torch.zeros(num_features))\n else:\n self.register_parameter('weight', None)\n self.register_parameter('bias', None)\n self.register_buffer('running_mean', torch.zeros(num_features))\n self.register_buffer('running_var', torch.ones(num_features))\n self.reset_parameters()","function_tokens":["def","__init__","(","self",",","num_features",",","eps","=","1e-5",",","momentum","=","0.1",",","affine","=","True",",","activation","=","\"leaky_relu\"",",","slope","=","0.01",")",":","super","(","ABN",",","self",")",".","__init__","(",")","self",".","num_features","=","num_features","self",".","affine","=","affine","self",".","eps","=","eps","self",".","momentum","=","momentum","self",".","activation","=","activation","self",".","slope","=","slope","if","self",".","affine",":","self",".","weight","=","nn",".","Parameter","(","torch",".","ones","(","num_features",")",")","self",".","bias","=","nn",".","Parameter","(","torch",".","zeros","(","num_features",")",")","else",":","self",".","register_parameter","(","'weight'",",","None",")","self",".","register_parameter","(","'bias'",",","None",")","self",".","register_buffer","(","'running_mean'",",","torch",".","zeros","(","num_features",")",")","self",".","register_buffer","(","'running_var'",",","torch",".","ones","(","num_features",")",")","self",".","reset_parameters","(",")"],"url":"https:\/\/github.com\/CoinCheung\/BiSeNet\/blob\/f9231b7c971413e6ebdfcd961fbea53417b18851\/old\/modules\/bn.py#L19-L52"} {"nwo":"CoinCheung\/BiSeNet","sha":"f9231b7c971413e6ebdfcd961fbea53417b18851","path":"old\/modules\/bn.py","language":"python","identifier":"InPlaceABN.__init__","parameters":"(self, num_features, eps=1e-5, momentum=0.1, affine=True, activation=\"leaky_relu\", slope=0.01)","argument_list":"","return_statement":"","docstring":"Creates an InPlace Activated Batch Normalization module\n\n Parameters\n ----------\n num_features : int\n Number of feature channels in the input and output.\n eps : float\n Small constant to prevent numerical issues.\n momentum : float\n Momentum factor applied to compute running statistics as.\n affine : bool\n If `True` apply learned scale and shift transformation after normalization.\n activation : str\n Name of the activation functions, one of: `leaky_relu`, `elu` or `none`.\n slope : float\n Negative slope for the `leaky_relu` activation.","docstring_summary":"Creates an InPlace Activated Batch Normalization module","docstring_tokens":["Creates","an","InPlace","Activated","Batch","Normalization","module"],"function":"def __init__(self, num_features, eps=1e-5, momentum=0.1, affine=True, activation=\"leaky_relu\", slope=0.01):\n \"\"\"Creates an InPlace Activated Batch Normalization module\n\n Parameters\n ----------\n num_features : int\n Number of feature channels in the input and output.\n eps : float\n Small constant to prevent numerical issues.\n momentum : float\n Momentum factor applied to compute running statistics as.\n affine : bool\n If `True` apply learned scale and shift transformation after normalization.\n activation : str\n Name of the activation functions, one of: `leaky_relu`, `elu` or `none`.\n slope : float\n Negative slope for the `leaky_relu` activation.\n \"\"\"\n super(InPlaceABN, self).__init__(num_features, eps, momentum, affine, activation, slope)","function_tokens":["def","__init__","(","self",",","num_features",",","eps","=","1e-5",",","momentum","=","0.1",",","affine","=","True",",","activation","=","\"leaky_relu\"",",","slope","=","0.01",")",":","super","(","InPlaceABN",",","self",")",".","__init__","(","num_features",",","eps",",","momentum",",","affine",",","activation",",","slope",")"],"url":"https:\/\/github.com\/CoinCheung\/BiSeNet\/blob\/f9231b7c971413e6ebdfcd961fbea53417b18851\/old\/modules\/bn.py#L87-L105"} {"nwo":"CoinCheung\/BiSeNet","sha":"f9231b7c971413e6ebdfcd961fbea53417b18851","path":"old\/modules\/residual.py","language":"python","identifier":"IdentityResidualBlock.__init__","parameters":"(self,\n in_channels,\n channels,\n stride=1,\n dilation=1,\n groups=1,\n norm_act=ABN,\n dropout=None)","argument_list":"","return_statement":"","docstring":"Configurable identity-mapping residual block\n\n Parameters\n ----------\n in_channels : int\n Number of input channels.\n channels : list of int\n Number of channels in the internal feature maps. Can either have two or three elements: if three construct\n a residual block with two `3 x 3` convolutions, otherwise construct a bottleneck block with `1 x 1`, then\n `3 x 3` then `1 x 1` convolutions.\n stride : int\n Stride of the first `3 x 3` convolution\n dilation : int\n Dilation to apply to the `3 x 3` convolutions.\n groups : int\n Number of convolution groups. This is used to create ResNeXt-style blocks and is only compatible with\n bottleneck blocks.\n norm_act : callable\n Function to create normalization \/ activation Module.\n dropout: callable\n Function to create Dropout Module.","docstring_summary":"Configurable identity-mapping residual block","docstring_tokens":["Configurable","identity","-","mapping","residual","block"],"function":"def __init__(self,\n in_channels,\n channels,\n stride=1,\n dilation=1,\n groups=1,\n norm_act=ABN,\n dropout=None):\n \"\"\"Configurable identity-mapping residual block\n\n Parameters\n ----------\n in_channels : int\n Number of input channels.\n channels : list of int\n Number of channels in the internal feature maps. Can either have two or three elements: if three construct\n a residual block with two `3 x 3` convolutions, otherwise construct a bottleneck block with `1 x 1`, then\n `3 x 3` then `1 x 1` convolutions.\n stride : int\n Stride of the first `3 x 3` convolution\n dilation : int\n Dilation to apply to the `3 x 3` convolutions.\n groups : int\n Number of convolution groups. This is used to create ResNeXt-style blocks and is only compatible with\n bottleneck blocks.\n norm_act : callable\n Function to create normalization \/ activation Module.\n dropout: callable\n Function to create Dropout Module.\n \"\"\"\n super(IdentityResidualBlock, self).__init__()\n\n # Check parameters for inconsistencies\n if len(channels) != 2 and len(channels) != 3:\n raise ValueError(\"channels must contain either two or three values\")\n if len(channels) == 2 and groups != 1:\n raise ValueError(\"groups > 1 are only valid if len(channels) == 3\")\n\n is_bottleneck = len(channels) == 3\n need_proj_conv = stride != 1 or in_channels != channels[-1]\n\n self.bn1 = norm_act(in_channels)\n if not is_bottleneck:\n layers = [\n (\"conv1\", nn.Conv2d(in_channels, channels[0], 3, stride=stride, padding=dilation, bias=False,\n dilation=dilation)),\n (\"bn2\", norm_act(channels[0])),\n (\"conv2\", nn.Conv2d(channels[0], channels[1], 3, stride=1, padding=dilation, bias=False,\n dilation=dilation))\n ]\n if dropout is not None:\n layers = layers[0:2] + [(\"dropout\", dropout())] + layers[2:]\n else:\n layers = [\n (\"conv1\", nn.Conv2d(in_channels, channels[0], 1, stride=stride, padding=0, bias=False)),\n (\"bn2\", norm_act(channels[0])),\n (\"conv2\", nn.Conv2d(channels[0], channels[1], 3, stride=1, padding=dilation, bias=False,\n groups=groups, dilation=dilation)),\n (\"bn3\", norm_act(channels[1])),\n (\"conv3\", nn.Conv2d(channels[1], channels[2], 1, stride=1, padding=0, bias=False))\n ]\n if dropout is not None:\n layers = layers[0:4] + [(\"dropout\", dropout())] + layers[4:]\n self.convs = nn.Sequential(OrderedDict(layers))\n\n if need_proj_conv:\n self.proj_conv = nn.Conv2d(in_channels, channels[-1], 1, stride=stride, padding=0, bias=False)","function_tokens":["def","__init__","(","self",",","in_channels",",","channels",",","stride","=","1",",","dilation","=","1",",","groups","=","1",",","norm_act","=","ABN",",","dropout","=","None",")",":","super","(","IdentityResidualBlock",",","self",")",".","__init__","(",")","# Check parameters for inconsistencies","if","len","(","channels",")","!=","2","and","len","(","channels",")","!=","3",":","raise","ValueError","(","\"channels must contain either two or three values\"",")","if","len","(","channels",")","==","2","and","groups","!=","1",":","raise","ValueError","(","\"groups > 1 are only valid if len(channels) == 3\"",")","is_bottleneck","=","len","(","channels",")","==","3","need_proj_conv","=","stride","!=","1","or","in_channels","!=","channels","[","-","1","]","self",".","bn1","=","norm_act","(","in_channels",")","if","not","is_bottleneck",":","layers","=","[","(","\"conv1\"",",","nn",".","Conv2d","(","in_channels",",","channels","[","0","]",",","3",",","stride","=","stride",",","padding","=","dilation",",","bias","=","False",",","dilation","=","dilation",")",")",",","(","\"bn2\"",",","norm_act","(","channels","[","0","]",")",")",",","(","\"conv2\"",",","nn",".","Conv2d","(","channels","[","0","]",",","channels","[","1","]",",","3",",","stride","=","1",",","padding","=","dilation",",","bias","=","False",",","dilation","=","dilation",")",")","]","if","dropout","is","not","None",":","layers","=","layers","[","0",":","2","]","+","[","(","\"dropout\"",",","dropout","(",")",")","]","+","layers","[","2",":","]","else",":","layers","=","[","(","\"conv1\"",",","nn",".","Conv2d","(","in_channels",",","channels","[","0","]",",","1",",","stride","=","stride",",","padding","=","0",",","bias","=","False",")",")",",","(","\"bn2\"",",","norm_act","(","channels","[","0","]",")",")",",","(","\"conv2\"",",","nn",".","Conv2d","(","channels","[","0","]",",","channels","[","1","]",",","3",",","stride","=","1",",","padding","=","dilation",",","bias","=","False",",","groups","=","groups",",","dilation","=","dilation",")",")",",","(","\"bn3\"",",","norm_act","(","channels","[","1","]",")",")",",","(","\"conv3\"",",","nn",".","Conv2d","(","channels","[","1","]",",","channels","[","2","]",",","1",",","stride","=","1",",","padding","=","0",",","bias","=","False",")",")","]","if","dropout","is","not","None",":","layers","=","layers","[","0",":","4","]","+","[","(","\"dropout\"",",","dropout","(",")",")","]","+","layers","[","4",":","]","self",".","convs","=","nn",".","Sequential","(","OrderedDict","(","layers",")",")","if","need_proj_conv",":","self",".","proj_conv","=","nn",".","Conv2d","(","in_channels",",","channels","[","-","1","]",",","1",",","stride","=","stride",",","padding","=","0",",","bias","=","False",")"],"url":"https:\/\/github.com\/CoinCheung\/BiSeNet\/blob\/f9231b7c971413e6ebdfcd961fbea53417b18851\/old\/modules\/residual.py#L9-L75"} {"nwo":"CoinCheung\/BiSeNet","sha":"f9231b7c971413e6ebdfcd961fbea53417b18851","path":"old\/modules\/misc.py","language":"python","identifier":"GlobalAvgPool2d.__init__","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Global average pooling over the input's spatial dimensions","docstring_summary":"Global average pooling over the input's spatial dimensions","docstring_tokens":["Global","average","pooling","over","the","input","s","spatial","dimensions"],"function":"def __init__(self):\n \"\"\"Global average pooling over the input's spatial dimensions\"\"\"\n super(GlobalAvgPool2d, self).__init__()","function_tokens":["def","__init__","(","self",")",":","super","(","GlobalAvgPool2d",",","self",")",".","__init__","(",")"],"url":"https:\/\/github.com\/CoinCheung\/BiSeNet\/blob\/f9231b7c971413e6ebdfcd961fbea53417b18851\/old\/modules\/misc.py#L6-L8"} {"nwo":"CoinCheung\/BiSeNet","sha":"f9231b7c971413e6ebdfcd961fbea53417b18851","path":"old\/fp16\/resnet.py","language":"python","identifier":"conv3x3","parameters":"(in_planes, out_planes, stride=1)","argument_list":"","return_statement":"return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride,\n padding=1, bias=False)","docstring":"3x3 convolution with padding","docstring_summary":"3x3 convolution with padding","docstring_tokens":["3x3","convolution","with","padding"],"function":"def conv3x3(in_planes, out_planes, stride=1):\n \"\"\"3x3 convolution with padding\"\"\"\n return nn.Conv2d(in_planes, out_planes, kernel_size=3, stride=stride,\n padding=1, bias=False)","function_tokens":["def","conv3x3","(","in_planes",",","out_planes",",","stride","=","1",")",":","return","nn",".","Conv2d","(","in_planes",",","out_planes",",","kernel_size","=","3",",","stride","=","stride",",","padding","=","1",",","bias","=","False",")"],"url":"https:\/\/github.com\/CoinCheung\/BiSeNet\/blob\/f9231b7c971413e6ebdfcd961fbea53417b18851\/old\/fp16\/resnet.py#L16-L19"} {"nwo":"CoinCheung\/BiSeNet","sha":"f9231b7c971413e6ebdfcd961fbea53417b18851","path":"tools\/gen_coco_annos.py","language":"python","identifier":"gen_coco","parameters":"()","argument_list":"","return_statement":"","docstring":"root_path:\n |- images\n |- train2017\n |- val2017\n |- labels\n |- train2017\n |- val2017","docstring_summary":"root_path:\n |- images\n |- train2017\n |- val2017\n |- labels\n |- train2017\n |- val2017","docstring_tokens":["root_path",":","|","-","images","|","-","train2017","|","-","val2017","|","-","labels","|","-","train2017","|","-","val2017"],"function":"def gen_coco():\n '''\n root_path:\n |- images\n |- train2017\n |- val2017\n |- labels\n |- train2017\n |- val2017\n '''\n root_path = '.\/datasets\/coco'\n save_path = '.\/datasets\/coco\/'\n for mode in ('train', 'val'):\n im_root = osp.join(root_path, f'images\/{mode}2017')\n lb_root = osp.join(root_path, f'labels\/{mode}2017')\n\n ims = os.listdir(im_root)\n lbs = os.listdir(lb_root)\n\n print(len(ims))\n print(len(lbs))\n\n im_names = [el.replace('.jpg', '') for el in ims]\n lb_names = [el.replace('.png', '') for el in lbs]\n common_names = list(set(im_names) & set(lb_names))\n\n lines = [\n f'images\/{mode}2017\/{name}.jpg,labels\/{mode}2017\/{name}.png'\n for name in common_names\n ]\n\n with open(f'{save_path}\/{mode}.txt', 'w') as fw:\n fw.write('\\n'.join(lines))","function_tokens":["def","gen_coco","(",")",":","root_path","=","'.\/datasets\/coco'","save_path","=","'.\/datasets\/coco\/'","for","mode","in","(","'train'",",","'val'",")",":","im_root","=","osp",".","join","(","root_path",",","f'images\/{mode}2017'",")","lb_root","=","osp",".","join","(","root_path",",","f'labels\/{mode}2017'",")","ims","=","os",".","listdir","(","im_root",")","lbs","=","os",".","listdir","(","lb_root",")","print","(","len","(","ims",")",")","print","(","len","(","lbs",")",")","im_names","=","[","el",".","replace","(","'.jpg'",",","''",")","for","el","in","ims","]","lb_names","=","[","el",".","replace","(","'.png'",",","''",")","for","el","in","lbs","]","common_names","=","list","(","set","(","im_names",")","&","set","(","lb_names",")",")","lines","=","[","f'images\/{mode}2017\/{name}.jpg,labels\/{mode}2017\/{name}.png'","for","name","in","common_names","]","with","open","(","f'{save_path}\/{mode}.txt'",",","'w'",")","as","fw",":","fw",".","write","(","'\\n'",".","join","(","lines",")",")"],"url":"https:\/\/github.com\/CoinCheung\/BiSeNet\/blob\/f9231b7c971413e6ebdfcd961fbea53417b18851\/tools\/gen_coco_annos.py#L6-L38"}