id int64 0 458k | file_name stringlengths 4 119 | file_path stringlengths 14 227 | content stringlengths 24 9.96M | size int64 24 9.96M | language stringclasses 1
value | extension stringclasses 14
values | total_lines int64 1 219k | avg_line_length float64 2.52 4.63M | max_line_length int64 5 9.91M | alphanum_fraction float64 0 1 | repo_name stringlengths 7 101 | repo_stars int64 100 139k | repo_forks int64 0 26.4k | repo_open_issues int64 0 2.27k | repo_license stringclasses 12
values | repo_extraction_date stringclasses 433
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2,285,900 | densenet.py | cvlab-yonsei_RankMixup/calibrate/net/densenet.py | '''
Pytorch impplementation of DenseNet.
Reference:
[1] Gao Huang, Zhuang Liu, and Kilian Q. Weinberger. Densely connected convolutional networks.
arXiv preprint arXiv:1608.06993, 2016a.
'''
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
class Bottleneck(nn.Module):
def __in... | 6,643 | Python | .py | 145 | 37.944828 | 96 | 0.632467 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,901 | wide_resnet.py | cvlab-yonsei_RankMixup/calibrate/net/wide_resnet.py | '''
Pytorch implementation of wide resnet.
Reference:
[1] S. Zagoruyko and N. Komodakis. Wide residual networks. arXiv preprint arXiv:1605.07146, 2016.
'''
import torch
import torch.nn as nn
import math
import random
import numpy as np
import torch.nn.functional as F
def conv3x3(in_planes, out_planes, stride=1):
... | 15,190 | Python | .py | 353 | 32.453258 | 118 | 0.574189 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,902 | resnet_tiny_imagenet.py | cvlab-yonsei_RankMixup/calibrate/net/resnet_tiny_imagenet.py | '''
Pytorch implementation of ResNet models.
Reference:
[1] He, K., Zhang, X., Ren, S., Sun, J.: Deep residual learning for image recognition. In: CVPR, 2016.
'''
import torch
import math
import torch.nn as nn
import torch.nn.functional as F
# --- HELPERS ---
def conv3x3(in_planes, out_planes, stride=1):
'''
... | 5,585 | Python | .py | 145 | 30.462069 | 109 | 0.595357 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,903 | resnet_mixup.py | cvlab-yonsei_RankMixup/calibrate/net/resnet_mixup.py | import torch
import math
import random
import numpy as np
import torch.nn as nn
import torch.nn.functional as F
try:
from torch.hub import load_state_dict_from_url
except ImportError:
from torch.utils.model_zoo import load_url as load_state_dict_from_url
__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50'... | 24,005 | Python | .py | 552 | 33.166667 | 118 | 0.58991 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,904 | segement_trainer.py | cvlab-yonsei_RankMixup/calibrate/engine/segement_trainer.py | from typing import Dict
import numpy as np
import os.path as osp
from shutil import copyfile
import time
import json
import logging
import torch
import torch.nn.functional as F
from omegaconf import DictConfig, OmegaConf
from hydra.utils import instantiate
import wandb
from terminaltables.ascii_table import AsciiTable
... | 10,550 | Python | .py | 243 | 32.633745 | 101 | 0.580168 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,905 | nlp_trainer.py | cvlab-yonsei_RankMixup/calibrate/engine/nlp_trainer.py | import math
import time
import os.path as osp
from shutil import copyfile
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import logging
import wandb
from omegaconf import DictConfig, OmegaConf
from hydra.utils import instantiate
from calibrate.engine.trainer import Trainer
from c... | 8,327 | Python | .py | 201 | 30.373134 | 111 | 0.571464 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,906 | tester.py | cvlab-yonsei_RankMixup/calibrate/engine/tester.py | import os.path as osp
import time
import json
import logging
import numpy as np
import torch
import torch.nn.functional as F
from omegaconf import DictConfig, OmegaConf
from hydra.utils import instantiate
import wandb
from terminaltables.ascii_table import AsciiTable
from typing import Optional
from calibrate.net impor... | 7,003 | Python | .py | 172 | 30.482558 | 97 | 0.595516 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,907 | trainer.py | cvlab-yonsei_RankMixup/calibrate/engine/trainer.py | import os.path as osp
from shutil import copyfile
import time
import json
import logging
import torch
import torch.nn.functional as F
from omegaconf import DictConfig, OmegaConf
from hydra.utils import instantiate
import wandb
from terminaltables.ascii_table import AsciiTable
from calibrate.net import ModelWithTempera... | 18,112 | Python | .py | 396 | 33.800505 | 132 | 0.574151 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,908 | __init__.py | cvlab-yonsei_RankMixup/calibrate/engine/__init__.py | from .trainer import Trainer
from .segement_trainer import SegmentTrainer
from .nlp_trainer import NLPTrainer
from .tester import Tester
from .ood_tester import OODTester | 172 | Python | .py | 5 | 33.2 | 44 | 0.861446 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,909 | ood_tester.py | cvlab-yonsei_RankMixup/calibrate/engine/ood_tester.py | import os.path as osp
import time
import json
import logging
import torch
import torch.nn.functional as F
from omegaconf import DictConfig, OmegaConf
from hydra.utils import instantiate
import wandb
from terminaltables.ascii_table import AsciiTable
from typing import Optional
from calibrate.net import ModelWithTemperat... | 3,889 | Python | .py | 104 | 28.221154 | 88 | 0.603179 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,910 | file_io.py | cvlab-yonsei_RankMixup/calibrate/utils/file_io.py | import os
import os.path as osp
import zipfile
from typing import List
def mkdir(output_dir : str) -> None:
if not os.path.exists(output_dir):
os.makedirs(output_dir)
def zipdir(path, result_path):
zipf = zipfile.ZipFile(result_path, "w")
for root, dirs, files in os.walk(path):
for file ... | 895 | Python | .py | 28 | 25.214286 | 71 | 0.589744 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,911 | constants.py | cvlab-yonsei_RankMixup/calibrate/utils/constants.py | EPS: float = 1e-10
#: Loss binary mode suppose you are solving binary segmentation task.
#: That mean yor have only one class which pixels are labled as **1**,
#: the rest pixels are background and labeled as **0**.
#: Target mask shape - (N, H, W), model output mask shape (N, 1, H, W).
BINARY_MODE: str = "binary"
#: ... | 1,085 | Python | .py | 17 | 62.647059 | 82 | 0.714152 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,912 | __init__.py | cvlab-yonsei_RankMixup/calibrate/utils/__init__.py | from .file_io import *
from .checkpoint import *
from .misc import set_random_seed, get_logfile, round_dict
from .dist_helper import *
| 135 | Python | .py | 4 | 32.75 | 58 | 0.778626 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,913 | checkpoint.py | cvlab-yonsei_RankMixup/calibrate/utils/checkpoint.py | import os
import os.path as osp
import logging
import torch
from typing import Optional, Tuple
logger = logging.getLogger(__name__)
def load_checkpoint(
model_path: str,
model: torch.nn.Module,
device: torch.device
) -> None:
if not osp.exists(model_path):
raise FileNotFoundError(
... | 3,510 | Python | .py | 90 | 32.255556 | 96 | 0.644679 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,914 | dist_helper.py | cvlab-yonsei_RankMixup/calibrate/utils/dist_helper.py | import pickle
import os
import os.path as osp
import socket
import subprocess
from typing import Callable, List, Optional, Tuple
import torch
from torch import distributed as dist
import logging
import sys
def get_world_size():
if not dist.is_available():
return 1
if not dist.is_initialized():
... | 7,770 | Python | .py | 212 | 30.528302 | 115 | 0.657265 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,915 | misc.py | cvlab-yonsei_RankMixup/calibrate/utils/misc.py | import logging
import numpy as np
import os
import random
from datetime import datetime
import torch
from copy import deepcopy
logger = logging.getLogger(__name__)
def set_random_seed(seed: int = None, deterministic: bool = False):
"""
Set the random seed for the RNG in torch, numpy and python.
Args:
... | 1,615 | Python | .py | 48 | 27.479167 | 74 | 0.65619 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,916 | torch_helper.py | cvlab-yonsei_RankMixup/calibrate/utils/torch_helper.py | import random
import numpy as np
import torch
import torch.nn as nn
from .constants import EPS
def to_numpy(x: torch.Tensor):
return x.detach().cpu().numpy()
def get_lr(optimizer: torch.optim.Optimizer) -> float:
for param in optimizer.param_groups:
return param["lr"]
def worker_init_fn(worker_id... | 1,166 | Python | .py | 39 | 24.538462 | 61 | 0.619477 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,917 | mdca.py | cvlab-yonsei_RankMixup/calibrate/losses/mdca.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from .label_smoothing import LabelSmoothingCrossEntropy
class MDCA(nn.Module):
def __init__(self):
super(MDCA, self).__init__()
self.ls = LabelSmoothingCrossEntropy()
@property
def names(self):
return "loss", "loss... | 927 | Python | .py | 26 | 27.846154 | 56 | 0.603604 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,918 | brier_score.py | cvlab-yonsei_RankMixup/calibrate/losses/brier_score.py | '''
Implementation of Brier Score.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class BrierScore(nn.Module):
def __init__(self):
super(BrierScore, self).__init__()
def forward(self, input, target):
if input.dim()>2:
input = input.view(input.size(0),input.... | 909 | Python | .py | 23 | 32.608696 | 84 | 0.588435 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,919 | mmce.py | cvlab-yonsei_RankMixup/calibrate/losses/mmce.py | '''
Implementation of the MMCE (MMCE_m) and MMCE_weighted (MMCE_w).
Reference:
[1] A. Kumar, S. Sarawagi, U. Jain, Trainable Calibration Measures for Neural Networks from Kernel Mean Embeddings.
ICML, 2018.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable... | 6,815 | Python | .py | 111 | 49.414414 | 175 | 0.60522 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,920 | label_smoothing.py | cvlab-yonsei_RankMixup/calibrate/losses/label_smoothing.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class LabelSmoothingCrossEntropy(nn.Module):
def __init__(self, alpha=0.1, ignore_index=-100, reduction="mean"):
super(LabelSmoothingCrossEntropy, self).__init__()
self.alpha = alpha
self.ignore_index = ignore_index
... | 1,351 | Python | .py | 31 | 34.387097 | 86 | 0.581431 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,921 | logit_margin_plus.py | cvlab-yonsei_RankMixup/calibrate/losses/logit_margin_plus.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch import distributed as dist
from ..utils import reduce_tensor
class LogitMarginPlus(nn.Module):
"""Add marginal penalty to logits:
CE + alpha * max(0, max(l^n) - l^n - margin)
"""
def __init__(self,
num_... | 3,821 | Python | .py | 89 | 32.640449 | 97 | 0.572698 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,922 | penalty_l1.py | cvlab-yonsei_RankMixup/calibrate/losses/penalty_l1.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from calibrate.utils.constants import EPS
class PenaltyL1(nn.Module):
"""Penalty L1
loss = CE + alpha * |s - 1/K| (s: softmax outputs, K : number of classes)
"""
def __init__(self, num_classes, alpha=1.0):
supe... | 903 | Python | .py | 25 | 28.04 | 82 | 0.576566 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,923 | __init__.py | cvlab-yonsei_RankMixup/calibrate/losses/__init__.py | from .label_smoothing import LabelSmoothingCrossEntropy
from .focal_loss import FocalLoss
from .focal_loss_adaptive_gamma import FocalLossAdaptive
from .mmce import MMCE, MMCE_weighted
from .brier_score import BrierScore
from .penalty_entropy import PenaltyEntropy
from .penalty_l1 import PenaltyL1
from .logit_margin_l1... | 468 | Python | .py | 11 | 41.363636 | 56 | 0.861538 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,924 | rankmixup.py | cvlab-yonsei_RankMixup/calibrate/losses/rankmixup.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class RankMixup_MRL(nn.Module):
def __init__(self, num_classes: int = 10,
margin: float = 0.1,
alpha: float = 0.1,
ignore_index: int =-100):
super().__init__()
sel... | 5,114 | Python | .py | 104 | 38.807692 | 101 | 0.582894 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,925 | penalty_entropy.py | cvlab-yonsei_RankMixup/calibrate/losses/penalty_entropy.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from calibrate.utils.constants import EPS
class PenaltyEntropy(nn.Module):
"""Regularizing neural networks by penalizing confident output distributions, 2017. <https://arxiv.org/pdf/1701.06548>
loss = CE - alpha * Entropy(p)
"""
... | 1,439 | Python | .py | 34 | 34.058824 | 122 | 0.591105 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,926 | logit_margin_l1.py | cvlab-yonsei_RankMixup/calibrate/losses/logit_margin_l1.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class LogitMarginL1(nn.Module):
"""Add marginal penalty to logits:
CE + alpha * max(0, max(l^n) - l^n - margin)
Args:
margin (float, optional): The margin value. Defaults to 10.
alpha (float, optional): The balancing w... | 3,580 | Python | .py | 77 | 36.454545 | 97 | 0.591404 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,927 | focal_loss_adaptive_gamma.py | cvlab-yonsei_RankMixup/calibrate/losses/focal_loss_adaptive_gamma.py | '''
Implementation of Focal Loss with adaptive gamma.
Reference:
[1] T.-Y. Lin, P. Goyal, R. Girshick, K. He, and P. Dollar, Focal loss for dense object detection.
arXiv preprint arXiv:1708.02002, 2017.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
fro... | 2,524 | Python | .py | 66 | 30.727273 | 99 | 0.580645 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,928 | focal_loss.py | cvlab-yonsei_RankMixup/calibrate/losses/focal_loss.py | '''
Implementation of Focal Loss.
Reference:
[1] T.-Y. Lin, P. Goyal, R. Girshick, K. He, and P. Dollar, Focal loss for dense object detection.
arXiv preprint arXiv:1708.02002, 2017.
'''
import torch
import torch.nn as nn
import torch.nn.functional as F
class FocalLoss(nn.Module):
def __init__(self, gamma=0... | 1,336 | Python | .py | 34 | 31.588235 | 99 | 0.580695 | cvlab-yonsei/RankMixup | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,929 | fruitshopgame.py | deepikamerlin_Fruitshop-Game/fruitshopgame.py | import random
fruitbag = ["Apple","Orange","Banana","Pear","Grapes","Strawberry","Blueberry","Watermelon","Pineapple","Mango","Peach","Cherry","Kiwi",
"Lemon","Lime","Plum","Raspberry","Blackberry","Cantaloupe","Fig","Grapefruit","Pomegranate","Apricot","Nectarine","Papaya","Coconut",
"Passion Fruit","Guava"... | 1,848 | Python | .py | 32 | 50.375 | 147 | 0.645925 | deepikamerlin/Fruitshop-Game | 8 | 0 | 0 | EPL-2.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,930 | ui.py | andreafailla_pix2beats/ui.py | import json # io
import tempfile
import streamlit as st # UI
from PIL import Image # image processing
from backend import resize_and_convert, trackmaker # processing
from backend import rolling_title # animation
from constants import SCALES, NOTES, HARMONIES, SAMPLE_IMAGES # constants
from my_presets import PRE... | 14,877 | Python | .py | 412 | 25.40534 | 195 | 0.542353 | andreafailla/pix2beats | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,931 | my_presets.py | andreafailla_pix2beats/my_presets.py | PRESETS = {
"None": {
"scale": "Major",
"key": "A",
"octave": 2,
"harmony": "None",
"randomize_octaves": True,
"resize_to_n_pixels": False,
"t_value": 0.2,
"n_pixels": 64,
"gain_db": 0.0,
"drive_db": 0.0,
"cutoff_hz": 0.0,
... | 3,298 | Python | .py | 130 | 16.861538 | 36 | 0.424874 | andreafailla/pix2beats | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,932 | constants.py | andreafailla_pix2beats/constants.py | SAMPLE_IMAGES = ["mona_lisa.png", "pixel_art_landscape.png", "sunflower.png"]
SAMPLE_RATE = 22050 # standard audio sample rate
FADE_DURATION = 0.015 # duration of fade in and fade out
NOTES = ["A", "A#", "B", "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#"]
PIANO_NOTES = {
"A0": 27.5,
"A#0": 29.1352350948... | 4,040 | Python | .py | 135 | 25.2 | 77 | 0.58312 | andreafailla/pix2beats | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,933 | backend.py | andreafailla_pix2beats/backend.py | """
Loosely based on
https://github.com/victormurcia/Making-Music-From-Images/blob/main/music_to_images.py
"""
import os
import random
import time
import numpy as np
# image
from PIL import Image
# audio
from pedalboard import Pedalboard, Chorus, Reverb, Gain, LadderFilter, Delay, Distortion
from pedalboard.io impo... | 7,836 | Python | .py | 253 | 23.731225 | 88 | 0.605815 | andreafailla/pix2beats | 8 | 1 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,934 | ttt_download_datasets.py | ttt-matching-based-vos_ttt_matching_vos/ttt_download_datasets.py | from argparse import ArgumentParser
import gdown
import os
import tarfile
import urllib.request
import zipfile
"""
Arguments loading
"""
parser = ArgumentParser()
parser.add_argument('--root_dir', default='datasets/video_segmentation')
args = parser.parse_args()
##### DAVIS 2017 #########
davis_dir = os.path.join(ar... | 3,447 | Python | .py | 77 | 43.233766 | 83 | 0.757819 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,935 | inference_core.py | ttt-matching-based-vos_ttt_matching_vos/STCN/inference_core.py | import torch
from inference_memory_bank import MemoryBank
from model.eval_network import STCN
from model.aggregate import aggregate
from util.tensor_util import pad_divide_by
class InferenceCore:
def __init__(self, prop_net:STCN, images, num_objects, top_k=20, mem_every=5, include_last=False):
self.prop... | 3,003 | Python | .py | 63 | 38.206349 | 113 | 0.602604 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,936 | inference_memory_bank.py | ttt-matching-based-vos_ttt_matching_vos/STCN/inference_memory_bank.py | import math
import torch
def softmax_w_top(x, top):
""" Selects the top k memory bank correspondences for each query feature (and apply softmax
on the top k correspondences). Every other correspondence is set to 0.
"""
values, indices = torch.topk(x, k=top, dim=1)
x_exp = values.exp_()
x_exp ... | 2,725 | Python | .py | 70 | 29.742857 | 95 | 0.560168 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,937 | train.py | ttt-matching-based-vos_ttt_matching_vos/STCN/train.py | import datetime
from os import path
import math
import random
import numpy as np
import torch
from torch.utils.data import DataLoader, ConcatDataset
import torch.distributed as distributed
from model.model import STCNModel
from dataset.static_dataset import StaticTransformDataset
from dataset.vos_dataset import VOSDa... | 7,258 | Python | .py | 164 | 39.256098 | 117 | 0.694433 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,938 | inference_core_yv.py | ttt-matching-based-vos_ttt_matching_vos/STCN/inference_core_yv.py | import torch
from inference_memory_bank import MemoryBank
from model.eval_network import STCN
from model.aggregate import aggregate
from util.tensor_util import pad_divide_by
class InferenceCore:
def __init__(self, prop_net:STCN, images, num_objects, top_k=20,
mem_every=5, include_last=Fals... | 4,317 | Python | .py | 90 | 37.244444 | 128 | 0.579638 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,939 | eval_all_datasets_ttt.py | ttt-matching-based-vos_ttt_matching_vos/STCN/eval_all_datasets_ttt.py | import random
import warnings
warnings.filterwarnings("ignore")
import torch.nn as nn
from torch.utils.data import DataLoader
from model.eval_network import STCN
from model.losses import EntropyLoss
from ttt.config.load_config import load_config
from ttt.model.model_ttt import STCN_TTT
from ttt.utils.meter import Av... | 7,930 | Python | .py | 149 | 40.946309 | 120 | 0.593463 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,940 | load_config.py | ttt-matching-based-vos_ttt_matching_vos/STCN/ttt/config/load_config.py | import argparse
import yaml
import os
"""
Inspired from https://gist.github.com/robcowie/7c39e2afb140c905fdf2661b93ff3df9
"""
class ConfigAction(argparse.Action):
"""Add configuration file to current defaults."""
def __init__(self, *args, **kwargs):
"""Config action is a search path, so a list, so o... | 4,415 | Python | .py | 87 | 42.701149 | 107 | 0.662027 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,941 | save_config.py | ttt-matching-based-vos_ttt_matching_vos/STCN/ttt/config/save_config.py | import argparse
import os
import yaml
def parse_arguments():
formatter = lambda prog: argparse.ArgumentDefaultsHelpFormatter(prog, max_help_position=80)
parser = argparse.ArgumentParser(
description='This is the training code of a video similarity network based on self-supervision',
formatter_... | 5,394 | Python | .py | 100 | 44.11 | 130 | 0.631619 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,942 | helper.py | ttt-matching-based-vos_ttt_matching_vos/STCN/ttt/utils/helper.py | import os
import time
import torch
import numpy as np
import torch.nn.functional as F
from os import path
from PIL import Image
from inference_core import InferenceCore as InferenceCoreDavis
from inference_core_yv import InferenceCore as InferenceCoreYT
from util.tensor_util import unpad
from dataset.davis_test_datas... | 9,061 | Python | .py | 179 | 41.374302 | 113 | 0.627657 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,943 | meter.py | ttt-matching-based-vos_ttt_matching_vos/STCN/ttt/utils/meter.py | import torch
import numpy as np
from collections import OrderedDict
class AverageMeter(object):
"""Computes and stores the average and current value"""
def __init__(self, name, fmt=':.3f'):
self.name = name
self.fmt = fmt
self.values = []
def reset(self):
self.values = []... | 2,339 | Python | .py | 62 | 30.306452 | 95 | 0.593514 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,944 | vos_dataset_ttt.py | ttt-matching-based-vos_ttt_matching_vos/STCN/ttt/dataset/vos_dataset_ttt.py | import copy
import os
from os import path
import torch
from torch.utils.data.dataset import Dataset
from torchvision import transforms
from torchvision.transforms import InterpolationMode
from PIL import Image
import numpy as np
from dataset.range_transform import im_normalization, im_mean
from dataset.reseed import ... | 13,099 | Python | .py | 259 | 37.471042 | 115 | 0.564429 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,945 | model_ttt.py | ttt-matching-based-vos_ttt_matching_vos/STCN/ttt/model/model_ttt.py | """
model.py - warpper and utility functions for network training
Compute loss, back-prop, update parameters, logging, etc.
"""
import torch
import torch.nn as nn
from model.network import STCN
class STCN_TTT(STCN):
def __init__(self,):
super().__init__(False)
def propagate(self, frames, mask_first... | 6,738 | Python | .py | 151 | 32.086093 | 122 | 0.524878 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,946 | util.py | ttt-matching-based-vos_ttt_matching_vos/STCN/dataset/util.py | import numpy as np
def all_to_onehot(masks, labels):
if len(masks.shape) == 3:
Ms = np.zeros((len(labels), masks.shape[0], masks.shape[1], masks.shape[2]), dtype=np.uint8)
else:
Ms = np.zeros((len(labels), masks.shape[0], masks.shape[1]), dtype=np.uint8)
for k, l in enumerate(labels):
... | 386 | Python | .py | 9 | 36.111111 | 100 | 0.621918 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,947 | generic_test_dataset.py | ttt-matching-based-vos_ttt_matching_vos/STCN/dataset/generic_test_dataset.py | import os
from os import path
import torch
from torch.utils.data.dataset import Dataset
from torchvision import transforms
from torchvision.transforms import InterpolationMode
from PIL import Image
import numpy as np
from dataset.range_transform import im_normalization
from dataset.util import all_to_onehot
class G... | 3,957 | Python | .py | 97 | 30.082474 | 96 | 0.575702 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,948 | vos_dataset.py | ttt-matching-based-vos_ttt_matching_vos/STCN/dataset/vos_dataset.py | import os
from os import path
import torch
from torch.utils.data.dataset import Dataset
from torchvision import transforms
from torchvision.transforms import InterpolationMode
from PIL import Image
import numpy as np
from dataset.range_transform import im_normalization, im_mean
from dataset.reseed import reseed
from ... | 10,113 | Python | .py | 229 | 32.10917 | 117 | 0.554424 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,949 | mose_test_dataset.py | ttt-matching-based-vos_ttt_matching_vos/STCN/dataset/mose_test_dataset.py | """
Modified from https://github.com/seoungwugoh/STM/blob/master/dataset.py
"""
import os
from os import path
import numpy as np
from PIL import Image
import torch
from torchvision import transforms
from torchvision.transforms import InterpolationMode
from torch.utils.data.dataset import Dataset
from dataset.range_tr... | 3,472 | Python | .py | 85 | 31.2 | 100 | 0.59267 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,950 | davis_test_dataset.py | ttt-matching-based-vos_ttt_matching_vos/STCN/dataset/davis_test_dataset.py | """
Modified from https://github.com/seoungwugoh/STM/blob/master/dataset.py
"""
import os
from os import path
import numpy as np
from PIL import Image
import torch
from torchvision import transforms
from torchvision.transforms import InterpolationMode
from torch.utils.data.dataset import Dataset
from dataset.range_tr... | 5,166 | Python | .py | 122 | 30.909836 | 105 | 0.557446 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,951 | static_dataset.py | ttt-matching-based-vos_ttt_matching_vos/STCN/dataset/static_dataset.py | import os
from os import path
import torch
from torch.utils.data.dataset import Dataset
from torchvision import transforms
from torchvision.transforms import InterpolationMode
from PIL import Image
import numpy as np
from dataset.range_transform import im_normalization, im_mean
from dataset.tps import random_tps_warp... | 5,023 | Python | .py | 112 | 34.776786 | 130 | 0.602787 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,952 | range_transform.py | ttt-matching-based-vos_ttt_matching_vos/STCN/dataset/range_transform.py | import torchvision.transforms as transforms
im_mean = (124, 116, 104)
im_normalization = transforms.Normalize(
mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225]
)
inv_im_trans = transforms.Normalize(
mean=[-0.485/0.229, -0.456/0.224, -0.406/... | 377 | Python | .py | 9 | 30.777778 | 64 | 0.531507 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,953 | yv_test_dataset.py | ttt-matching-based-vos_ttt_matching_vos/STCN/dataset/yv_test_dataset.py | import os
from os import path
import torch
from torch.utils.data.dataset import Dataset
from torchvision import transforms
from torchvision.transforms import InterpolationMode
from PIL import Image
import numpy as np
from dataset.range_transform import im_normalization
from dataset.util import all_to_onehot
class Y... | 3,999 | Python | .py | 96 | 31.010417 | 96 | 0.580695 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,954 | tps.py | ttt-matching-based-vos_ttt_matching_vos/STCN/dataset/tps.py | import numpy as np
from PIL import Image
import cv2
import thinplate as tps
cv2.setNumThreads(0)
def pick_random_points(h, w, n_samples):
y_idx = np.random.choice(np.arange(h), size=n_samples, replace=False)
x_idx = np.random.choice(np.arange(w), size=n_samples, replace=False)
return y_idx/h, x_idx/w
de... | 1,167 | Python | .py | 28 | 37.5 | 103 | 0.686726 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,955 | hyper_para.py | ttt-matching-based-vos_ttt_matching_vos/STCN/util/hyper_para.py | from argparse import ArgumentParser
def none_or_default(x, default):
return x if x is not None else default
class HyperParameters():
def parse(self, unknown_arg_ok=False):
parser = ArgumentParser()
# Enable torch.backends.cudnn.benchmark -- Faster in some cases, test in your own environment
... | 4,763 | Python | .py | 74 | 54.216216 | 173 | 0.629709 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,956 | tensor_util.py | ttt-matching-based-vos_ttt_matching_vos/STCN/util/tensor_util.py | import torch.nn.functional as F
def compute_tensor_iu(seg, gt):
intersection = (seg & gt).float().sum()
union = (seg | gt).float().sum()
return intersection, union
def compute_tensor_iou(seg, gt):
intersection, union = compute_tensor_iu(seg, gt)
iou = (intersection + 1e-6) / (union + 1e-6)
... | 1,045 | Python | .py | 34 | 25.176471 | 66 | 0.524476 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,957 | logger.py | ttt-matching-based-vos_ttt_matching_vos/STCN/util/logger.py | """
Dumps things to tensorboard and console
"""
import os
import warnings
import git
import torchvision.transforms as transforms
from torch.utils.tensorboard import SummaryWriter
def tensor_to_numpy(image):
image_np = (image.numpy() * 255).astype('uint8')
return image_np
def detach_to_cpu(x):
return x.... | 3,017 | Python | .py | 83 | 27.313253 | 128 | 0.552804 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,958 | log_integrator.py | ttt-matching-based-vos_ttt_matching_vos/STCN/util/log_integrator.py | """
Integrate numerical values for some iterations
Typically used for loss computation / logging to tensorboard
Call finalize and create a new Integrator when you want to display/log
"""
import torch
class Integrator:
def __init__(self, logger, distributed=True, local_rank=0, world_size=1):
self.values =... | 2,408 | Python | .py | 63 | 27.555556 | 77 | 0.550258 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,959 | load_subset.py | ttt-matching-based-vos_ttt_matching_vos/STCN/util/load_subset.py | """
load_subset.py - Presents a subset of data
DAVIS - only the training set
YouTubeVOS - I manually filtered some erroneous ones out but I haven't checked all
"""
def load_sub_davis(path='util/davis_subset.txt'):
with open(path, mode='r') as f:
subset = set(f.read().splitlines())
return subset
def l... | 457 | Python | .py | 13 | 31.461538 | 82 | 0.687075 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,960 | image_saver.py | ttt-matching-based-vos_ttt_matching_vos/STCN/util/image_saver.py | import cv2
import numpy as np
import torch
from dataset.range_transform import inv_im_trans
from collections import defaultdict
def tensor_to_numpy(image):
image_np = (image.numpy() * 255).astype('uint8')
return image_np
def tensor_to_np_float(image):
image_np = image.numpy().astype('float32')
return... | 3,923 | Python | .py | 106 | 29.613208 | 105 | 0.58702 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,961 | network.py | ttt-matching-based-vos_ttt_matching_vos/STCN/model/network.py | """
network.py - The core of the neural network
Defines the structure and memory operations
Modifed from STM: https://github.com/seoungwugoh/STM
The trailing number of a variable usually denote the stride
e.g. f16 -> encoded features with stride 16
"""
import math
import torch
import torch.nn as nn
import torch.nn.f... | 5,934 | Python | .py | 142 | 32.507042 | 94 | 0.573576 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,962 | losses.py | ttt-matching-based-vos_ttt_matching_vos/STCN/model/losses.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from util.tensor_util import compute_tensor_iu
from collections import defaultdict
def get_iou_hook(values):
return 'iou/iou', (values['hide_iou/i']+1)/(values['hide_iou/u']+1)
def get_sec_iou_hook(values):
return 'iou/sec_iou', (values['hid... | 5,014 | Python | .py | 111 | 36 | 112 | 0.546593 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,963 | eval_network.py | ttt-matching-based-vos_ttt_matching_vos/STCN/model/eval_network.py | """
eval_network.py - Evaluation version of the network
The logic is basically the same
but with top-k and some implementation optimization
The trailing number of a variable usually denote the stride
e.g. f16 -> encoded features with stride 16
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
fr... | 2,854 | Python | .py | 66 | 35.287879 | 76 | 0.60224 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,964 | model.py | ttt-matching-based-vos_ttt_matching_vos/STCN/model/model.py | """
model.py - warpper and utility functions for network training
Compute loss, back-prop, update parameters, logging, etc.
"""
import os
import time
import torch
import torch.nn as nn
import torch.optim as optim
from model.network import STCN
from model.losses import LossComputer, iou_hooks_mo, iou_hooks_so
from ut... | 10,190 | Python | .py | 212 | 35.150943 | 119 | 0.537809 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,965 | cbam.py | ttt-matching-based-vos_ttt_matching_vos/STCN/model/cbam.py | # Modified from https://github.com/Jongchan/attention-module/blob/master/MODELS/cbam.py
import torch
import torch.nn as nn
import torch.nn.functional as F
class BasicConv(nn.Module):
def __init__(self, in_planes, out_planes, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True):
super(BasicCo... | 3,042 | Python | .py | 67 | 36.671642 | 154 | 0.610455 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,966 | mod_resnet.py | ttt-matching-based-vos_ttt_matching_vos/STCN/model/mod_resnet.py | """
mod_resnet.py - A modified ResNet structure
We append extra channels to the first conv by some network surgery
"""
from collections import OrderedDict
import math
import torch
import torch.nn as nn
from torch.utils import model_zoo
def load_weights_sequential(target, source_state, extra_chan=1):
new_di... | 5,526 | Python | .py | 126 | 34.388889 | 95 | 0.60859 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,967 | modules.py | ttt-matching-based-vos_ttt_matching_vos/STCN/model/modules.py | """
modules.py - This file stores the rathering boring network blocks.
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
from torchvision import models
from model import mod_resnet
from model import cbam
class ResBlock(nn.Module):
def __init__(self, indim, outdim=None):
super(ResBlo... | 5,213 | Python | .py | 133 | 31.233083 | 105 | 0.593545 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,968 | aggregate.py | ttt-matching-based-vos_ttt_matching_vos/STCN/model/aggregate.py | import torch
import torch.nn.functional as F
# Soft aggregation from STM
def aggregate(prob, keep_bg=False):
logits = get_logits(prob)
return get_softmax(logits, keep_bg)
def get_logits(prob):
# add the background mask
new_prob = torch.cat([
torch.prod(1-prob, dim=0, keepdim=True),
p... | 1,265 | Python | .py | 39 | 27.025641 | 77 | 0.643328 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,969 | davisc_create.py | ttt-matching-based-vos_ttt_matching_vos/DAVIS-C/davisc_create.py | import os, glob, cv2, subprocess, numpy as np
import tensorflow_hub as hub
import tensorflow as tf
from PIL import Image
import skimage.color as cl
from skimage.filters import gaussian
from imgaug.augmenters.artistic import stylize_cartoon
DAVIS_VIDEOS = ['bike-packing',
'blackswan',
'... | 12,364 | Python | .py | 246 | 40.861789 | 156 | 0.548933 | ttt-matching-based-vos/ttt_matching_vos | 8 | 0 | 0 | GPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,970 | setup.py | NioTheFirst_ScType/setup.py | from setuptools import setup, find_packages
with open("README.md", "r", encoding="utf-8") as f:
long_description = f.read()
setup(
name="slither-analyzer",
description="Slither is a Solidity static analysis framework written in Python 3.",
url="https://github.com/crytic/slither",
author="Trail of ... | 2,573 | Python | .py | 68 | 28.632353 | 108 | 0.565721 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,971 | financial_type_keys.py | NioTheFirst_ScType/financial_type_keys.py | '''
Copy of the table with `tcheck_parser.py`.
This table stores the key associated with each financial type.
'''
f_type_num = {
-1: "undef",
0: "raw balance",
1: "net balance",
2: "accrued balance",
3: "final balance",
10: "compound fee ratio (t)",
11: "transaction fee",
12: "simple f... | 604 | Python | .py | 24 | 21.083333 | 62 | 0.612069 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,972 | json_diff.py | NioTheFirst_ScType/scripts/json_diff.py | import sys
import json
from pprint import pprint
from deepdiff import DeepDiff # pip install deepdiff
if len(sys.argv) != 3:
print("Usage: python json_diff.py 1.json 2.json")
sys.exit(-1)
with open(sys.argv[1], encoding="utf8") as f:
d1 = json.load(f)
with open(sys.argv[2], encoding="utf8") as f:
d... | 618 | Python | .py | 19 | 29 | 60 | 0.707276 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,973 | __about__.py | NioTheFirst_ScType/slither/__about__.py | # SPDX-FileCopyrightText: 2023-present NioTheFirst <bzhangprogramming@gmail.com>
#
# SPDX-License-Identifier: MIT
__version__ = "0.1.0"
| 136 | Python | .py | 4 | 33 | 80 | 0.772727 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,974 | tcheck_module.py | NioTheFirst_ScType/slither/tcheck_module.py | total_compilations = -1
def update_total_compilations(total):
global total_compilations
total_compilations = total
def get_total_compilations():
global total_compilations
return(total_compilations)
| 217 | Python | .py | 7 | 27.285714 | 37 | 0.78744 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,975 | __main__.py | NioTheFirst_ScType/slither/__main__.py | #!/usr/bin/env python3
import argparse
import cProfile
import glob
import inspect
import json
import logging
import os
import pstats
import sys
import traceback
from typing import Tuple, Optional, List, Dict, Type, Union, Any, Sequence
from pkg_resources import iter_entry_points, require
from crytic_compile import c... | 34,129 | Python | .py | 811 | 34.355117 | 151 | 0.62083 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,976 | all_exceptions.py | NioTheFirst_ScType/slither/all_exceptions.py | """
This module import all slither exceptions
"""
# pylint: disable=unused-import
from slither.slithir.exceptions import SlithIRError
from slither.solc_parsing.exceptions import ParsingError, VariableNotFound
from slither.core.exceptions import SlitherCoreError
from slither.exceptions import SlitherException
| 310 | Python | .py | 8 | 37.75 | 74 | 0.870861 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,977 | slither.py | NioTheFirst_ScType/slither/slither.py | import logging
from typing import Union, List, ValuesView, Type, Dict
from crytic_compile import CryticCompile, InvalidCompilation
# pylint: disable= no-name-in-module
from slither.core.compilation_unit import SlitherCompilationUnit
from slither.core.scope.scope import FileScope
from slither.core.slither_core import ... | 8,516 | Python | .py | 170 | 40.647059 | 124 | 0.658231 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,978 | sctype_cf_pairs.py | NioTheFirst_ScType/slither/sctype_cf_pairs.py | func_ptr_hash = {}
cont_ptr_hash = {}
def add_cont_with_state_var(contract_name, contract):
global cont_ptr_hash
if(len(_read_state_variables(contract)) == 0):
return
else:
cont_ptr_hash[contract_name] = contract
def get_cont_with_state_var(contract_name):
global cont_ptr_hash
if(... | 1,262 | Python | .py | 39 | 27.179487 | 87 | 0.667763 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,979 | exceptions.py | NioTheFirst_ScType/slither/formatters/exceptions.py | from slither.exceptions import SlitherException
class FormatImpossible(SlitherException):
pass
class FormatError(SlitherException):
pass
| 149 | Python | .py | 5 | 26.4 | 47 | 0.857143 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,980 | patches.py | NioTheFirst_ScType/slither/formatters/utils/patches.py | import os
import difflib
from typing import Dict, Tuple, Union
from collections import defaultdict
from slither.core.compilation_unit import SlitherCompilationUnit
# pylint: disable=too-many-arguments
def create_patch(
result: Dict,
file: str,
start: int,
end: int,
old_str: Union[str, bytes],
... | 1,859 | Python | .py | 46 | 35.152174 | 100 | 0.671468 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,981 | naming_convention.py | NioTheFirst_ScType/slither/formatters/naming_convention/naming_convention.py | import re
import logging
from typing import List
from slither.core.compilation_unit import SlitherCompilationUnit
from slither.slithir.operations import (
Send,
Transfer,
OperationWithLValue,
HighLevelCall,
LowLevelCall,
InternalCall,
InternalDynamicCall,
Operation,
)
from slither.core... | 25,464 | Python | .py | 549 | 35.918033 | 112 | 0.566125 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,982 | constant_pragma.py | NioTheFirst_ScType/slither/formatters/attributes/constant_pragma.py | import re
from slither.formatters.exceptions import FormatImpossible
from slither.formatters.utils.patches import create_patch
# Indicates the recommended versions for replacement
REPLACEMENT_VERSIONS = ["^0.4.25", "^0.5.3"]
# pylint: disable=anomalous-backslash-in-string
# group:
# 0: ^ > >= < <= (optional)
# 1: ' ... | 2,805 | Python | .py | 68 | 34.558824 | 89 | 0.639765 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,983 | incorrect_solc.py | NioTheFirst_ScType/slither/formatters/attributes/incorrect_solc.py | import re
from slither.formatters.exceptions import FormatImpossible
from slither.formatters.utils.patches import create_patch
# Indicates the recommended versions for replacement
REPLACEMENT_VERSIONS = ["^0.4.25", "^0.5.3"]
# group:
# 0: ^ > >= < <= (optional)
# 1: ' ' (optional)
# 2: version number
# 3: version nu... | 2,369 | Python | .py | 60 | 32.1 | 85 | 0.60792 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,984 | const_functions.py | NioTheFirst_ScType/slither/formatters/attributes/const_functions.py | import re
from slither.core.compilation_unit import SlitherCompilationUnit
from slither.formatters.exceptions import FormatError
from slither.formatters.utils.patches import create_patch
def custom_format(compilation_unit: SlitherCompilationUnit, result):
for file_scope in compilation_unit.scopes.values():
... | 2,116 | Python | .py | 49 | 30.489796 | 95 | 0.57226 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,985 | external_function.py | NioTheFirst_ScType/slither/formatters/functions/external_function.py | import re
from slither.core.compilation_unit import SlitherCompilationUnit
from slither.formatters.utils.patches import create_patch
def custom_format(compilation_unit: SlitherCompilationUnit, result):
for file_scope in compilation_unit.scopes.values():
elements = result["elements"]
for element i... | 2,497 | Python | .py | 53 | 35.377358 | 102 | 0.582206 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,986 | unchanged_state_variables.py | NioTheFirst_ScType/slither/formatters/variables/unchanged_state_variables.py | import re
from slither.core.compilation_unit import SlitherCompilationUnit
from slither.formatters.exceptions import FormatError, FormatImpossible
from slither.formatters.utils.patches import create_patch
def custom_format(compilation_unit: SlitherCompilationUnit, result, attribute: str) -> None:
elements = resu... | 2,027 | Python | .py | 49 | 33.510204 | 97 | 0.654315 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,987 | unused_state_variables.py | NioTheFirst_ScType/slither/formatters/variables/unused_state_variables.py | from slither.core.compilation_unit import SlitherCompilationUnit
from slither.formatters.utils.patches import create_patch
def custom_format(compilation_unit: SlitherCompilationUnit, result):
elements = result["elements"]
for element in elements:
if element["type"] == "variable":
_patch(
... | 1,153 | Python | .py | 28 | 32.857143 | 95 | 0.628571 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,988 | all_printers.py | NioTheFirst_ScType/slither/printers/all_printers.py | # pylint: disable=unused-import,relative-beyond-top-level
from .summary.function import FunctionSummary
from .summary.contract import ContractSummary
from .inheritance.inheritance import PrinterInheritance
from .inheritance.inheritance_graph import PrinterInheritanceGraph
from .call.call_graph import PrinterCallGraph
f... | 1,099 | Python | .py | 22 | 48.954545 | 76 | 0.88208 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,989 | abstract_printer.py | NioTheFirst_ScType/slither/printers/abstract_printer.py | import abc
from logging import Logger
from typing import TYPE_CHECKING, Union, List, Optional, Dict
from slither.utils import output
from slither.utils.output import SupportedOutput
if TYPE_CHECKING:
from slither import Slither
class IncorrectPrinterInitialization(Exception):
pass
class AbstractPrinter(m... | 1,746 | Python | .py | 46 | 29.73913 | 72 | 0.64133 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,990 | modifier_calls.py | NioTheFirst_ScType/slither/printers/summary/modifier_calls.py | """
Module printing summary of the contract
"""
from slither.core.declarations import Function
from slither.printers.abstract_printer import AbstractPrinter
from slither.utils.myprettytable import MyPrettyTable
class Modifiers(AbstractPrinter):
ARGUMENT = "modifiers"
HELP = "Print the modifiers called b... | 1,578 | Python | .py | 38 | 30.789474 | 88 | 0.600654 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,991 | function.py | NioTheFirst_ScType/slither/printers/summary/function.py | """
Module printing summary of the contract
"""
from slither.printers.abstract_printer import AbstractPrinter
from slither.utils.myprettytable import MyPrettyTable
class FunctionSummary(AbstractPrinter):
ARGUMENT = "function-summary"
HELP = "Print a summary of the functions"
WIKI = "https://github.... | 3,534 | Python | .py | 103 | 19.563107 | 95 | 0.43931 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,992 | human_summary.py | NioTheFirst_ScType/slither/printers/summary/human_summary.py | """
Module printing summary of the contract
"""
import logging
from pathlib import Path
from typing import Tuple, List, Dict
from slither.core.declarations import SolidityFunction, Function
from slither.core.variables.state_variable import StateVariable
from slither.printers.abstract_printer import AbstractPrinter
fro... | 15,234 | Python | .py | 355 | 31.03662 | 140 | 0.575962 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,993 | require_calls.py | NioTheFirst_ScType/slither/printers/summary/require_calls.py | """
Module printing summary of the contract
"""
from slither.core.declarations import SolidityFunction
from slither.printers.abstract_printer import AbstractPrinter
from slither.slithir.operations import SolidityCall
from slither.utils.myprettytable import MyPrettyTable
require_or_assert = [
SolidityFunction(... | 1,939 | Python | .py | 52 | 26.846154 | 89 | 0.585821 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,994 | evm.py | NioTheFirst_ScType/slither/printers/summary/evm.py | """
Module printing evm mapping of the contract
"""
from slither.printers.abstract_printer import AbstractPrinter
from slither.analyses.evm import (
generate_source_to_evm_ins_mapping,
load_evm_cfg_builder,
)
from slither.utils.colors import blue, green, magenta, red
def _extract_evm_info(slither):
""... | 4,900 | Python | .py | 103 | 34.864078 | 117 | 0.573194 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,995 | slithir.py | NioTheFirst_ScType/slither/printers/summary/slithir.py | """
Module printing summary of the contract
"""
from slither.core.declarations import Function
from slither.printers.abstract_printer import AbstractPrinter
def _print_function(function: Function) -> str:
txt = ""
for node in function.nodes:
if node.expression:
txt += f"\t\tExpression:... | 1,945 | Python | .py | 48 | 29.541667 | 108 | 0.574603 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,996 | declaration.py | NioTheFirst_ScType/slither/printers/summary/declaration.py | from slither.printers.abstract_printer import AbstractPrinter
from slither.utils.source_mapping import get_definition, get_implementation, get_references
class Declaration(AbstractPrinter):
ARGUMENT = "declaration"
HELP = "Prototype showing the source code declaration, implementation and references of the con... | 2,675 | Python | .py | 45 | 44.755556 | 132 | 0.557678 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,997 | variable_order.py | NioTheFirst_ScType/slither/printers/summary/variable_order.py | """
Module printing summary of the contract
"""
from slither.printers.abstract_printer import AbstractPrinter
from slither.utils.myprettytable import MyPrettyTable
class VariableOrder(AbstractPrinter):
ARGUMENT = "variable-order"
HELP = "Print the storage order of the state variables"
WIKI = "https... | 1,334 | Python | .py | 31 | 33.645161 | 98 | 0.632843 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,998 | data_depenency.py | NioTheFirst_ScType/slither/printers/summary/data_depenency.py | """
Module printing summary of the contract
"""
from slither.printers.abstract_printer import AbstractPrinter
from slither.analyses.data_dependency.data_dependency import get_dependencies
from slither.slithir.variables import TemporaryVariable, ReferenceVariable
from slither.utils.myprettytable import MyPrettyTabl... | 1,983 | Python | .py | 52 | 27.923077 | 96 | 0.58142 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |
2,285,999 | when_not_paused.py | NioTheFirst_ScType/slither/printers/summary/when_not_paused.py | """
Module printing summary of the contract
"""
from slither.core.declarations import Function
from slither.core.declarations.function import SolidityFunction
from slither.printers.abstract_printer import AbstractPrinter
from slither.utils import output
from slither.utils.myprettytable import MyPrettyTable
def _... | 1,918 | Python | .py | 44 | 35.386364 | 94 | 0.668821 | NioTheFirst/ScType | 8 | 4 | 1 | AGPL-3.0 | 9/5/2024, 10:48:01 PM (Europe/Amsterdam) |