repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
STTS | STTS-main/MViT/slowfast/datasets/loader.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""Data loader."""
import itertools
import numpy as np
from functools import partial
import torch
from torch.utils.data._utils.collate import default_collate
from torch.utils.data.distributed import DistributedSampler
from ... | 7,067 | 34.878173 | 79 | py |
STTS | STTS-main/MViT/slowfast/datasets/imagenet.py | # Copyright (c) Facebook, Inc. and its affiliates.
import json
import numpy as np
import os
import random
import re
import torch
import torch.utils.data
from PIL import Image
from torchvision import transforms as transforms_tv
import slowfast.datasets.transform as transform
import slowfast.utils.logging as logging
#... | 7,414 | 35.348039 | 84 | py |
STTS | STTS-main/MViT/slowfast/datasets/rand_augment.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""
This implementation is based on
https://github.com/rwightman/pytorch-image-models/blob/master/timm/data/auto_augment.py
pulished under an Apache License 2.0.
COMMENT FROM ORIGINAL:
AutoAugment, RandAugment, and AugMix for PyTorch
This code im... | 16,199 | 29.337079 | 119 | py |
STTS | STTS-main/MViT/slowfast/datasets/build.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
from fvcore.common.registry import Registry
DATASET_REGISTRY = Registry("DATASET")
DATASET_REGISTRY.__doc__ = """
Registry for dataset.
The registered object will be called with `obj(cfg, split)`.
The call should return a ... | 1,120 | 34.03125 | 80 | py |
STTS | STTS-main/MViT/slowfast/visualization/async_predictor.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import atexit
import numpy as np
import queue
import torch
import torch.multiprocessing as mp
import slowfast.utils.logging as logging
from slowfast.datasets import cv2_transform
from slowfast.visualization.predictor import... | 9,808 | 29.653125 | 98 | py |
STTS | STTS-main/MViT/slowfast/visualization/demo_loader.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import atexit
import copy
import queue
import threading
import time
import cv2
import slowfast.utils.logging as logging
from slowfast.visualization.utils import TaskInfo
logger = logging.get_logger(__name__)
class VideoM... | 12,402 | 32.79564 | 97 | py |
STTS | STTS-main/MViT/slowfast/visualization/predictor.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import queue
import cv2
import torch
from detectron2 import model_zoo
from detectron2.config import get_cfg
from detectron2.engine import DefaultPredictor
import slowfast.utils.checkpoint as cu
from slowfast.datasets import... | 6,847 | 31.923077 | 85 | py |
STTS | STTS-main/MViT/slowfast/visualization/gradcam_utils.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import matplotlib.pyplot as plt
import torch
import torch.nn.functional as F
import slowfast.datasets.utils as data_utils
from slowfast.visualization.utils import get_layer
class GradCAM:
"""
GradCAM class helps c... | 6,958 | 37.877095 | 92 | py |
STTS | STTS-main/MViT/slowfast/visualization/utils.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import itertools
import numpy as np
import matplotlib.pyplot as plt
import torch
from sklearn.metrics import confusion_matrix
import slowfast.utils.logging as logging
from slowfast.datasets.utils import pack_pathway_output,... | 12,593 | 32.494681 | 101 | py |
STTS | STTS-main/MViT/slowfast/visualization/prediction_vis.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import numpy as np
import torch
import slowfast.datasets.utils as data_utils
import slowfast.utils.logging as logging
import slowfast.visualization.tensorboard_vis as tb
from slowfast.utils.misc import get_class_names
from ... | 5,296 | 37.948529 | 108 | py |
STTS | STTS-main/MViT/slowfast/visualization/ava_demo_precomputed_boxes.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import numpy as np
import os
import cv2
import torch
import tqdm
import slowfast.utils.checkpoint as cu
import slowfast.utils.logging as logging
from slowfast.datasets.ava_helper import parse_bboxes_file
from slowfast.datas... | 17,969 | 37.397436 | 98 | py |
STTS | STTS-main/MViT/slowfast/visualization/tensorboard_vis.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import logging as log
import math
import os
import matplotlib.pyplot as plt
import torch
from torch.utils.tensorboard import SummaryWriter
from torchvision.utils import make_grid
import slowfast.utils.logging as logging
imp... | 16,010 | 36.234884 | 102 | py |
STTS | STTS-main/MViT/slowfast/visualization/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
| 95 | 31 | 71 | py |
STTS | STTS-main/MViT/slowfast/visualization/video_visualizer.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import itertools
import logging as log
import numpy as np
import matplotlib.pyplot as plt
import torch
from detectron2.utils.visualizer import Visualizer
import slowfast.utils.logging as logging
from slowfast.utils.misc imp... | 27,400 | 39.414454 | 143 | py |
STTS | STTS-main/MViT/slowfast/utils/c2_model_loading.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""Caffe2 to PyTorch checkpoint name converting utility."""
import re
def get_name_convert_func():
"""
Get the function to convert Caffe2 layer names to PyTorch layer names.
Returns:
(func): function t... | 5,005 | 40.371901 | 80 | py |
STTS | STTS-main/MViT/slowfast/utils/ava_eval_helper.py | # Copyright (c) Facebook, Inc. and its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ... | 9,926 | 31.547541 | 82 | py |
STTS | STTS-main/MViT/slowfast/utils/parser.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""Argument parser functions."""
import argparse
import sys
import slowfast.utils.checkpoint as cu
from slowfast.config.defaults import get_cfg
def parse_args():
"""
Parse the following arguments for a default pa... | 3,021 | 30.810526 | 80 | py |
STTS | STTS-main/MViT/slowfast/utils/multigrid.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""Helper functions for multigrid training."""
import numpy as np
import slowfast.utils.logging as logging
logger = logging.get_logger(__name__)
class MultigridSchedule(object):
"""
This class defines multigrid ... | 8,754 | 35.327801 | 81 | py |
STTS | STTS-main/MViT/slowfast/utils/checkpoint.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""Functions that handle saving and loading of checkpoints."""
import copy
import numpy as np
import os
import pickle
from collections import OrderedDict
import torch
import slowfast.utils.distributed as du
import slowfast... | 19,869 | 36.775665 | 102 | py |
STTS | STTS-main/MViT/slowfast/utils/benchmark.py | # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
"""
Functions for benchmarks.
"""
import numpy as np
import pprint
import torch
import tqdm
from fvcore.common.timer import Timer
import slowfast.utils.logging as logging
import slowfast.utils.misc as misc
from slowfast.datasets import loader
from... | 3,290 | 30.644231 | 81 | py |
STTS | STTS-main/MViT/slowfast/utils/logging.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""Logging."""
import atexit
import builtins
import decimal
import functools
import logging
import os
import sys
import simplejson
import slowfast.utils.distributed as du
from slowfast.utils.env import pathmgr
def _suppr... | 2,746 | 26.47 | 79 | py |
STTS | STTS-main/MViT/slowfast/utils/misc.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import json
import logging
import math
import numpy as np
import os
from datetime import datetime
import psutil
import torch
from fvcore.nn.activation_count import activation_count
from fvcore.nn.flop_count import flop_count... | 12,587 | 31.78125 | 84 | py |
STTS | STTS-main/MViT/slowfast/utils/distributed.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""Distributed helpers."""
import functools
import logging
import pickle
import torch
import torch.distributed as dist
_LOCAL_PROCESS_GROUP = None
def all_gather(tensors):
"""
All gathers the provided tensors fro... | 8,879 | 27.645161 | 85 | py |
STTS | STTS-main/MViT/slowfast/utils/metrics.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""Functions for computing metrics."""
import torch
def topks_correct(preds, labels, ks):
"""
Given the predictions, labels, and a list of top-k values, compute the
number of correct predictions for each top-k... | 2,381 | 35.646154 | 76 | py |
STTS | STTS-main/MViT/slowfast/utils/__init__.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
| 95 | 31 | 71 | py |
STTS | STTS-main/MViT/slowfast/utils/weight_init_helper.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""Utility function for weight initialization"""
import torch.nn as nn
from fvcore.nn.weight_init import c2_msra_fill
def init_weights(model, fc_init_std=0.01, zero_init_final_bn=True):
"""
Performs ResNet style w... | 1,563 | 33.755556 | 76 | py |
STTS | STTS-main/MViT/slowfast/utils/multiprocessing.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""Multiprocessing helpers."""
import torch
def run(
local_rank,
num_proc,
func,
init_method,
shard_id,
num_shards,
backend,
cfg,
output_queue=None,
):
"""
Runs a function from ... | 2,105 | 32.428571 | 80 | py |
STTS | STTS-main/MViT/slowfast/utils/lr_policy.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""Learning rate policy."""
import math
def get_lr_at_epoch(cfg, cur_epoch):
"""
Retrieve the learning rate of the current epoch with the option to perform
warm up in the beginning of the training stage.
A... | 3,266 | 30.413462 | 80 | py |
STTS | STTS-main/MViT/slowfast/utils/env.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""Set up Environment."""
from iopath.common.file_io import PathManagerFactory
_ENV_SETUP_DONE = False
pathmgr = PathManagerFactory.get(key="pyslowfast")
checkpoint_pathmgr = PathManagerFactory.get(key="pyslowfast_checkpoi... | 445 | 23.777778 | 72 | py |
STTS | STTS-main/MViT/slowfast/utils/bn_helper.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""bn helper."""
import itertools
import torch
@torch.no_grad()
def compute_and_update_bn_stats(model, data_loader, num_batches=200):
"""
Compute and update the batch norm stats to make it more precise. During
... | 2,858 | 35.653846 | 80 | py |
STTS | STTS-main/MViT/slowfast/utils/meters.py | #!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
"""Meters."""
import datetime
import numpy as np
import os
from collections import defaultdict, deque
import torch
from fvcore.common.timer import Timer
from sklearn.metrics import average_precision_score
import slowfast.d... | 27,039 | 31.228844 | 80 | py |
STTS | STTS-main/MViT/slowfast/utils/ava_evaluation/label_map_util.py | # Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | 6,350 | 32.781915 | 100 | py |
STTS | STTS-main/MViT/slowfast/utils/ava_evaluation/np_box_list_ops.py | # Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | 21,645 | 35.441077 | 82 | py |
STTS | STTS-main/MViT/slowfast/utils/ava_evaluation/per_image_evaluation.py | # Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | 19,882 | 42.795154 | 89 | py |
STTS | STTS-main/MViT/slowfast/utils/ava_evaluation/standard_fields.py | # Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | 9,780 | 42.278761 | 82 | py |
STTS | STTS-main/MViT/slowfast/utils/ava_evaluation/np_box_mask_list.py | # Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | 2,705 | 35.567568 | 84 | py |
STTS | STTS-main/MViT/slowfast/utils/ava_evaluation/np_mask_ops.py | # Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | 4,525 | 33.549618 | 81 | py |
STTS | STTS-main/MViT/slowfast/utils/ava_evaluation/np_box_list.py | # Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | 5,028 | 33.923611 | 83 | py |
STTS | STTS-main/MViT/slowfast/utils/ava_evaluation/metrics.py | # Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | 5,710 | 35.845161 | 81 | py |
STTS | STTS-main/MViT/slowfast/utils/ava_evaluation/__init__.py | 0 | 0 | 0 | py | |
STTS | STTS-main/MViT/slowfast/utils/ava_evaluation/np_box_mask_list_ops.py | # Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | 16,307 | 37.013986 | 82 | py |
STTS | STTS-main/MViT/slowfast/utils/ava_evaluation/object_detection_evaluation.py | # Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | 34,271 | 40.142857 | 84 | py |
STTS | STTS-main/MViT/slowfast/utils/ava_evaluation/np_box_ops.py | # Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applica... | 3,565 | 31.715596 | 80 | py |
STTS | STTS-main/VideoSwin/setup.py | from setuptools import find_packages, setup
def readme():
with open('README.md', encoding='utf-8') as f:
content = f.read()
return content
version_file = 'mmaction/version.py'
def get_version():
with open(version_file, 'r') as f:
exec(compile(f.read(), version_file, 'exec'))
return... | 4,885 | 36.584615 | 125 | py |
STTS | STTS-main/VideoSwin/tools/test.py | import argparse
import os
import os.path as osp
import warnings
import mmcv
import torch
from mmcv import Config, DictAction
from mmcv.cnn import fuse_conv_bn
from mmcv.fileio.io import file_handlers
from mmcv.parallel import MMDataParallel, MMDistributedDataParallel
from mmcv.runner import get_dist_info, init_dist, l... | 13,558 | 35.645946 | 80 | py |
STTS | STTS-main/VideoSwin/tools/__init__.py | from .analysis import * # noqa: F401, F403
from .data import * # noqa: F401, F403
from .deployment import * # noqa: F401, F403
from .misc import * # noqa: F401, F403
| 170 | 33.2 | 45 | py |
STTS | STTS-main/VideoSwin/tools/train.py | import argparse
import copy
import os
import os.path as osp
import time
import warnings
import mmcv
import torch
from mmcv import Config, DictAction
from mmcv.runner import get_dist_info, init_dist, set_random_seed, load_checkpoint
from mmcv.utils import get_git_hash
from mmaction import __version__
from mmaction.api... | 7,620 | 34.119816 | 86 | py |
STTS | STTS-main/VideoSwin/tools/deployment/publish_model.py | import argparse
import subprocess
import torch
def parse_args():
parser = argparse.ArgumentParser(
description='Process a checkpoint to be published')
parser.add_argument('in_file', help='input checkpoint filename')
parser.add_argument('out_file', help='output checkpoint filename')
args = par... | 1,125 | 27.15 | 77 | py |
STTS | STTS-main/VideoSwin/tools/deployment/pytorch2onnx.py | import argparse
import mmcv
import numpy as np
import torch
from mmcv.runner import load_checkpoint
from mmaction.models import build_model
try:
import onnx
import onnxruntime as rt
except ImportError as e:
raise ImportError(f'Please install onnx and onnxruntime first. {e}')
try:
from mmcv.onnx.symb... | 5,940 | 33.947059 | 78 | py |
STTS | STTS-main/VideoSwin/tools/misc/clip_feature_extraction.py | import argparse
import os
import os.path as osp
import warnings
from datetime import datetime
import mmcv
import numpy as np
import torch
import torch.distributed as dist
from mmcv import Config, DictAction
from mmcv.cnn import fuse_conv_bn
from mmcv.fileio.io import file_handlers
from mmcv.parallel import MMDataParal... | 7,541 | 31.934498 | 78 | py |
STTS | STTS-main/VideoSwin/tools/misc/flow_extraction.py | import argparse
import os
import os.path as osp
import cv2
import numpy as np
def flow_to_img(raw_flow, bound=20.):
"""Convert flow to gray image.
Args:
raw_flow (np.ndarray[float]): Estimated flow with the shape (w, h).
bound (float): Bound for the flow-to-image normalization. Default: 20.
... | 6,059 | 31.406417 | 79 | py |
STTS | STTS-main/VideoSwin/tools/misc/bsn_proposal_generation.py | import argparse
import os
import os.path as osp
import mmcv
import numpy as np
import torch.multiprocessing as mp
from mmaction.localization import (generate_bsp_feature,
generate_candidate_proposals)
def load_video_infos(ann_file):
"""Load the video annotations.
Args:
... | 6,626 | 32.469697 | 79 | py |
STTS | STTS-main/VideoSwin/tools/analysis/bench_processing.py | """This file is for benchmark dataloading process. The command line to run this
file is:
$ python -m cProfile -o program.prof tools/analysis/bench_processing.py
configs/task/method/[config filename]
It use cProfile to record cpu running time and output to program.prof
To visualize cProfile output program.prof, use Sn... | 1,874 | 28.296875 | 79 | py |
STTS | STTS-main/VideoSwin/tools/analysis/eval_metric.py | import argparse
import mmcv
from mmcv import Config, DictAction
from mmaction.datasets import build_dataset
def parse_args():
parser = argparse.ArgumentParser(description='Evaluate metric of the '
'results saved in pkl/yaml/json format')
parser.add_argument('config', hel... | 2,063 | 30.272727 | 78 | py |
STTS | STTS-main/VideoSwin/tools/analysis/benchmark.py | import argparse
import time
import torch
from mmcv import Config
from mmcv.cnn import fuse_conv_bn
from mmcv.parallel import MMDataParallel
from mmcv.runner.fp16_utils import wrap_fp16_model
from mmaction.datasets import build_dataloader, build_dataset
from mmaction.models import build_model
def parse_args():
p... | 2,638 | 27.376344 | 79 | py |
STTS | STTS-main/VideoSwin/tools/analysis/report_accuracy.py | import argparse
from mmcv import load
from scipy.special import softmax
from mmaction.core.evaluation import (get_weighted_score, mean_class_accuracy,
top_k_accuracy)
def parse_args():
parser = argparse.ArgumentParser(description='Fusing multiple scores')
parser.add_arg... | 1,725 | 29.280702 | 78 | py |
STTS | STTS-main/VideoSwin/tools/analysis/get_flops.py | import argparse
from mmcv import Config
from mmaction.models import build_recognizer
try:
from mmcv.cnn import get_model_complexity_info
except ImportError:
raise ImportError('Please upgrade mmcv to >0.6.2')
def parse_args():
parser = argparse.ArgumentParser(description='Train a recognizer')
parser... | 1,980 | 26.136986 | 79 | py |
STTS | STTS-main/VideoSwin/tools/analysis/print_config.py | import argparse
from mmcv import Config, DictAction
def parse_args():
parser = argparse.ArgumentParser(description='Print the whole config')
parser.add_argument('config', help='config file path')
parser.add_argument(
'--options', nargs='+', action=DictAction, help='arguments in dict')
args = ... | 591 | 20.925926 | 76 | py |
STTS | STTS-main/VideoSwin/tools/analysis/analyze_logs.py | import argparse
import json
from collections import defaultdict
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
def cal_train_time(log_dicts, args):
for i, log_dict in enumerate(log_dicts):
print(f'{"-" * 5}Analyze train time of {args.json_logs[i]}{"-" * 5}')
all_times = ... | 5,760 | 33.497006 | 79 | py |
STTS | STTS-main/VideoSwin/tools/analysis/report_map.py | import argparse
import os
import os.path as osp
import mmcv
import numpy as np
from mmaction.core import ActivityNetLocalization
args = None
def cuhk17_top1():
"""Assign label for each proposal with the cuhk17 result, which is the #2
entry in http://activity-net.org/challenges/2017/evaluation.html."""
... | 2,424 | 26.873563 | 77 | py |
STTS | STTS-main/VideoSwin/tools/analysis/check_videos.py | import argparse
import os
import warnings
from functools import partial
from multiprocessing import Manager, Pool, cpu_count
import numpy as np
from mmcv import Config, DictAction
from tqdm import tqdm
from mmaction.datasets import PIPELINES, build_dataset
def parse_args():
parser = argparse.ArgumentParser(desc... | 5,259 | 32.503185 | 79 | py |
STTS | STTS-main/VideoSwin/tools/data/build_rawframes.py | import argparse
import glob
import os
import os.path as osp
import sys
import warnings
from multiprocessing import Pool
import mmcv
import numpy as np
def extract_frame(vid_item):
"""Generate optical flow using dense flow.
Args:
vid_item (list): Video item containing video full path,
vid... | 9,098 | 36.599174 | 104 | py |
STTS | STTS-main/VideoSwin/tools/data/parse_file_list.py | import csv
import fnmatch
import glob
import json
import os
import os.path as osp
def parse_directory(path,
rgb_prefix='img_',
flow_x_prefix='flow_x_',
flow_y_prefix='flow_y_',
level=1):
"""Parse directories holding extracted frames f... | 18,190 | 33.001869 | 90 | py |
STTS | STTS-main/VideoSwin/tools/data/denormalize_proposal_file.py | import argparse
import os.path as osp
from tools.data.parse_file_list import parse_directory
from mmaction.localization import load_localize_proposal_file
def process_norm_proposal_file(norm_proposal_file, frame_dict):
"""Process the normalized proposal file and denormalize it.
Args:
norm_proposal_... | 2,533 | 29.53012 | 77 | py |
STTS | STTS-main/VideoSwin/tools/data/extract_audio.py | import argparse
import glob
import os
import os.path as osp
from multiprocessing import Pool
import mmcv
def extract_audio_wav(line):
"""Extract the audio wave from video streams using FFMPEG."""
video_id, _ = osp.splitext(osp.basename(line))
video_dir = osp.dirname(line)
video_rel_dir = osp.relpath(... | 1,984 | 31.016129 | 77 | py |
STTS | STTS-main/VideoSwin/tools/data/anno_txt2json.py | import argparse
import mmcv
def parse_args():
parser = argparse.ArgumentParser(
description='Convert txt annotation list to json')
parser.add_argument(
'annofile', type=str, help='the txt annotation file to convert')
parser.add_argument(
'--format',
type=str,
defau... | 2,840 | 26.582524 | 78 | py |
STTS | STTS-main/VideoSwin/tools/data/build_file_list.py | import argparse
import glob
import json
import os.path as osp
import random
from mmcv.runner import set_random_seed
from tools.data.anno_txt2json import lines2dictlist
from tools.data.parse_file_list import (parse_directory, parse_diving48_splits,
parse_hmdb51_split,
... | 10,396 | 37.794776 | 109 | py |
STTS | STTS-main/VideoSwin/tools/data/resize_video.py | import argparse
import glob
import os
import os.path as osp
import sys
from multiprocessing import Pool
def resize_videos(vid_item):
"""Generate resized video cache.
Args:
vid_item (list): Video item containing video full path,
video relative path.
Returns:
bool: Whether gene... | 3,750 | 32.792793 | 138 | py |
STTS | STTS-main/VideoSwin/tools/data/build_videos.py | import argparse
import glob
import os
import os.path as osp
import sys
from multiprocessing import Pool
def encode_video(frame_dir_item):
"""Encode frames to video using ffmpeg.
Args:
frame_dir_item (list): Rawframe item containing raw frame directory
full path, rawframe directory (short)... | 4,104 | 31.322835 | 79 | py |
STTS | STTS-main/VideoSwin/tools/data/build_audio_features.py | import argparse
import glob
import os
import os.path as osp
import sys
from multiprocessing import Pool
import mmcv
import numpy as np
from scipy.io import wavfile
try:
import librosa
import lws
except ImportError:
print('Please import librosa, lws first.')
sys.path.append('..')
SILENCE_THRESHOLD = 2
FM... | 10,532 | 32.438095 | 79 | py |
STTS | STTS-main/VideoSwin/tools/data/gym/download.py | # This scripts is copied from
# https://github.com/activitynet/ActivityNet/blob/master/Crawler/Kinetics/download.py # noqa: E501
# The code is licensed under the MIT licence.
import argparse
import os
import ssl
import subprocess
import mmcv
from joblib import Parallel, delayed
ssl._create_default_https_context = ss... | 3,416 | 33.17 | 99 | py |
STTS | STTS-main/VideoSwin/tools/data/gym/generate_file_list.py | import os
import os.path as osp
annotation_root = '../../../data/gym/annotations'
data_root = '../../../data/gym/subactions'
frame_data_root = '../../../data/gym/subaction_frames'
videos = os.listdir(data_root)
videos = set(videos)
train_file_org = osp.join(annotation_root, 'gym99_train_org.txt')
val_file_org = osp.... | 1,835 | 36.469388 | 69 | py |
STTS | STTS-main/VideoSwin/tools/data/gym/trim_subaction.py | import os
import os.path as osp
import subprocess
import mmcv
data_root = '../../../data/gym'
anno_root = f'{data_root}/annotations'
event_anno_file = f'{anno_root}/event_annotation.json'
event_root = f'{data_root}/events'
subaction_root = f'{data_root}/subactions'
events = os.listdir(event_root)
events = set(event... | 1,581 | 29.423077 | 74 | py |
STTS | STTS-main/VideoSwin/tools/data/gym/trim_event.py | import os
import os.path as osp
import subprocess
import mmcv
data_root = '../../../data/gym'
video_root = f'{data_root}/videos'
anno_root = f'{data_root}/annotations'
anno_file = f'{anno_root}/annotation.json'
event_anno_file = f'{anno_root}/event_annotation.json'
event_root = f'{data_root}/events'
videos = os.lis... | 1,665 | 27.724138 | 74 | py |
STTS | STTS-main/VideoSwin/tools/data/hvu/parse_tag_list.py | import mmcv
tag_list = '../../../data/hvu/annotations/hvu_categories.csv'
lines = open(tag_list).readlines()
lines = [x.strip().split(',') for x in lines[1:]]
tag_categories = {}
for line in lines:
tag, category = line
tag_categories.setdefault(category, []).append(tag)
for k in tag_categories:
tag_categ... | 380 | 22.8125 | 61 | py |
STTS | STTS-main/VideoSwin/tools/data/hvu/download.py | # ------------------------------------------------------------------------------
# Adapted from https://github.com/activitynet/ActivityNet/
# Original licence: Copyright (c) Microsoft, under the MIT License.
# ------------------------------------------------------------------------------
import argparse
import glob
im... | 6,954 | 33.60199 | 80 | py |
STTS | STTS-main/VideoSwin/tools/data/hvu/generate_sub_file_list.py | import argparse
import os.path as osp
import mmcv
def main(annotation_file, category):
assert category in [
'action', 'attribute', 'concept', 'event', 'object', 'scene'
]
data = mmcv.load(annotation_file)
basename = osp.basename(annotation_file)
dirname = osp.dirname(annotation_file)
... | 1,181 | 27.142857 | 79 | py |
STTS | STTS-main/VideoSwin/tools/data/hvu/generate_file_list.py | import argparse
import fnmatch
import glob
import os
import os.path as osp
import mmcv
annotation_root = '../../data/hvu/annotations'
tag_file = 'hvu_tags.json'
args = None
def parse_directory(path,
rgb_prefix='img_',
flow_x_prefix='flow_x_',
flow_y_prefix... | 4,836 | 30.822368 | 79 | py |
STTS | STTS-main/VideoSwin/tools/data/activitynet/process_annotations.py | """This file processes the annotation files and generates proper annotation
files for localizers."""
import json
import numpy as np
def load_json(file):
with open(file) as json_file:
data = json.load(json_file)
return data
data_file = '../../../data/ActivityNet'
info_file = f'{data_file}/video_... | 1,656 | 29.685185 | 77 | py |
STTS | STTS-main/VideoSwin/tools/data/activitynet/download.py | # This scripts is copied from
# https://github.com/activitynet/ActivityNet/blob/master/Crawler/Kinetics/download.py # noqa: E501
# The code is licensed under the MIT licence.
import argparse
import os
import ssl
import subprocess
import mmcv
from joblib import Parallel, delayed
ssl._create_default_https_context = ss... | 4,910 | 32.182432 | 99 | py |
STTS | STTS-main/VideoSwin/tools/data/activitynet/convert_proposal_format.py | """This file converts the output proposal file of proposal generator (BSN, BMN)
into the input proposal file of action classifier (Currently supports SSN and
P-GCN, not including TSN, I3D etc.)."""
import argparse
import mmcv
import numpy as np
from mmaction.core import pairwise_temporal_iou
def load_annotations(an... | 6,116 | 36.759259 | 96 | py |
STTS | STTS-main/VideoSwin/tools/data/activitynet/generate_rawframes_filelist.py | import json
import os
import os.path as osp
data_file = '../../../data/ActivityNet'
video_list = f'{data_file}/video_info_new.csv'
anno_file = f'{data_file}/anet_anno_action.json'
rawframe_dir = f'{data_file}/rawframes'
action_name_list = 'action_name.csv'
train_rawframe_dir = rawframe_dir
val_rawframe_dir = rawframe... | 3,463 | 29.654867 | 79 | py |
STTS | STTS-main/VideoSwin/tools/data/activitynet/activitynet_feature_postprocessing.py | import argparse
import multiprocessing
import os
import os.path as osp
import numpy as np
import scipy.interpolate
from mmcv import dump, load
args = None
def parse_args():
parser = argparse.ArgumentParser(description='ANet Feature Prepare')
parser.add_argument('--rgb', default='', help='rgb feature root')
... | 3,213 | 31.464646 | 79 | py |
STTS | STTS-main/VideoSwin/tools/data/activitynet/tsn_feature_extraction.py | import argparse
import os
import os.path as osp
import pickle
import mmcv
import numpy as np
import torch
from mmaction.datasets.pipelines import Compose
from mmaction.models import build_model
def parse_args():
parser = argparse.ArgumentParser(description='Extract TSN Feature')
parser.add_argument('--data-... | 5,206 | 33.946309 | 78 | py |
STTS | STTS-main/VideoSwin/tools/data/ava/download_videos_parallel.py | import argparse
import os.path as osp
import subprocess
import mmcv
from joblib import Parallel, delayed
URL_PREFIX = 'https://s3.amazonaws.com/ava-dataset/trainval/'
def download_video(video_url, output_dir, num_attempts=5):
video_file = osp.basename(video_url)
output_file = osp.join(output_dir, video_file... | 2,118 | 31.106061 | 79 | py |
STTS | STTS-main/VideoSwin/tools/data/kinetics/download.py | # ------------------------------------------------------------------------------
# Adapted from https://github.com/activitynet/ActivityNet/
# Original licence: Copyright (c) Microsoft, under the MIT License.
# ------------------------------------------------------------------------------
import argparse
import glob
imp... | 8,132 | 34.515284 | 80 | py |
STTS | STTS-main/VideoSwin/tools/data/omnisource/trim_raw_video.py | import os
import os.path as osp
import sys
from subprocess import check_output
import mmcv
def get_duration(vid_name):
command = f'ffprobe -i {vid_name} 2>&1 | grep "Duration"'
output = str(check_output(command, shell=True))
output = output.split(',')[0].split('Duration:')[1].strip()
h, m, s = output... | 1,146 | 24.488889 | 79 | py |
STTS | STTS-main/VideoSwin/mmcv_custom/__init__.py | # -*- coding: utf-8 -*-
| 24 | 11.5 | 23 | py |
STTS | STTS-main/VideoSwin/mmcv_custom/runner/checkpoint.py | # Copyright (c) Open-MMLab. All rights reserved.
import apex
import os.path as osp
import time
from tempfile import TemporaryDirectory
import torch
from torch.optim import Optimizer
import mmcv
from mmcv.parallel import is_module_wrapper
from mmcv.runner.checkpoint import weights_to_cpu, get_state_dict
def save_chec... | 2,843 | 34.111111 | 77 | py |
STTS | STTS-main/VideoSwin/mmcv_custom/runner/__init__.py | from .epoch_based_runner import EpochBasedRunnerAmp
__all__ = [
'EpochBasedRunnerAmp'
]
| 94 | 12.571429 | 51 | py |
STTS | STTS-main/VideoSwin/mmcv_custom/runner/epoch_based_runner.py | # Copyright (c) Open-MMLab. All rights reserved.
import os.path as osp
import platform
import shutil
import time
import warnings
import torch
import mmcv
from .checkpoint import save_checkpoint
import apex
from torch.optim import Optimizer
import os
class EpochBasedRunnerAmp(mmcv.runner.EpochBasedRunner):
def _... | 9,764 | 38.216867 | 91 | py |
STTS | STTS-main/VideoSwin/mmaction/version.py | # Copyright (c) Open-MMLab. All rights reserved.
__version__ = '0.15.0'
def parse_version_info(version_str):
version_info = []
for x in version_str.split('.'):
if x.isdigit():
version_info.append(int(x))
elif x.find('rc') != -1:
patch_version = x.split('rc')
... | 502 | 25.473684 | 56 | py |
STTS | STTS-main/VideoSwin/mmaction/__init__.py | import mmcv
from mmcv import digit_version
from .version import __version__
mmcv_minimum_version = '1.3.1'
mmcv_maximum_version = '1.4.0'
mmcv_version = digit_version(mmcv.__version__)
assert (digit_version(mmcv_minimum_version) <= mmcv_version
<= digit_version(mmcv_maximum_version)), \
f'MMCV=={mmcv.__v... | 465 | 28.125 | 77 | py |
STTS | STTS-main/VideoSwin/mmaction/apis/inference.py | import os
import os.path as osp
import re
from operator import itemgetter
import mmcv
import torch
from mmcv.parallel import collate, scatter
from mmcv.runner import load_checkpoint
from mmaction.core import OutputHook
from mmaction.datasets.pipelines import Compose
from mmaction.models import build_recognizer
def ... | 5,977 | 37.076433 | 79 | py |
STTS | STTS-main/VideoSwin/mmaction/apis/test.py | import os.path as osp
import pickle
import shutil
import tempfile
# TODO import test functions from mmcv and delete them from mmaction2
import warnings
import mmcv
import torch
import torch.distributed as dist
from mmcv.runner import get_dist_info
try:
from mmcv.engine import (single_gpu_test, multi_gpu_test,
... | 7,577 | 35.965854 | 79 | py |
STTS | STTS-main/VideoSwin/mmaction/apis/__init__.py | from .inference import inference_recognizer, init_recognizer
from .test import multi_gpu_test, single_gpu_test
from .train import train_model
__all__ = [
'train_model', 'init_recognizer', 'inference_recognizer', 'multi_gpu_test',
'single_gpu_test'
]
| 259 | 27.888889 | 79 | py |
STTS | STTS-main/VideoSwin/mmaction/apis/train.py | import copy as cp
import os.path as osp
import torch
from mmcv.parallel import MMDataParallel, MMDistributedDataParallel
from mmcv.runner import (DistSamplerSeedHook, EpochBasedRunner, OptimizerHook,
build_optimizer, get_dist_info)
from mmcv.runner.hooks import Fp16OptimizerHook
from ..core i... | 10,658 | 39.222642 | 107 | py |
STTS | STTS-main/VideoSwin/mmaction/core/__init__.py | from .bbox import * # noqa: F401, F403
from .evaluation import * # noqa: F401, F403
from .hooks import * # noqa: F401, F403
from .optimizer import * # noqa: F401, F403
from .runner import * # noqa: F401, F403
from .scheduler import * # noqa: F401, F403
| 259 | 36.142857 | 45 | py |
STTS | STTS-main/VideoSwin/mmaction/core/scheduler/lr_updater.py | from mmcv.runner import HOOKS, LrUpdaterHook
from mmcv.runner.hooks.lr_updater import annealing_cos
@HOOKS.register_module()
class TINLrUpdaterHook(LrUpdaterHook):
def __init__(self, min_lr, **kwargs):
self.min_lr = min_lr
super().__init__(**kwargs)
def get_warmup_lr(self, cur_iters):
... | 1,493 | 36.35 | 76 | py |
STTS | STTS-main/VideoSwin/mmaction/core/scheduler/__init__.py | from .lr_updater import TINLrUpdaterHook
__all__ = ['TINLrUpdaterHook']
| 73 | 17.5 | 40 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.