text stringlengths 24 1.04M | metadata stringlengths 233 497 |
|---|---|
### File: references/depth/stereo/utils/__init__.py
from .losses import *
from .metrics import *
from .distributed import *
from .logger import *
from .padder import *
from .norm import *
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/depth/stereo/utils/__init__.py", "license": "bsd-3-clause", "size": 136} |
### File: references/depth/stereo/utils/distributed.py
import os
import torch
import torch.distributed as dist
def _redefine_print(is_main):
"""disables printing when not in main process"""
import builtins as __builtin__
builtin_print = __builtin__.print
def print(*args, **kwargs):
force = ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/depth/stereo/utils/distributed.py", "license": "bsd-3-clause", "size": 1758} |
### File: references/depth/stereo/utils/logger.py
import datetime
import time
from collections import defaultdict, deque
import torch
from .distributed import reduce_across_processes
class SmoothedValue:
"""Track a series of values and provide access to smoothed values over a
window or the global series ave... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/depth/stereo/utils/logger.py", "license": "bsd-3-clause", "size": 5027} |
### File: references/depth/stereo/utils/losses.py
from typing import List, Optional
import torch
from torch import nn, Tensor
from torch.nn import functional as F
from torchvision.prototype.models.depth.stereo.raft_stereo import grid_sample, make_coords_grid
def make_gaussian_kernel(kernel_size: int, sigma: float) -... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/depth/stereo/utils/losses.py", "license": "bsd-3-clause", "size": 17473} |
### File: references/depth/stereo/utils/metrics.py
from typing import Dict, List, Optional, Tuple
from torch import Tensor
AVAILABLE_METRICS = ["mae", "rmse", "epe", "bad1", "bad2", "epe", "1px", "3px", "5px", "fl-all", "relepe"]
def compute_metrics(
flow_pred: Tensor, flow_gt: Tensor, valid_flow_mask: Optional... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/depth/stereo/utils/metrics.py", "license": "bsd-3-clause", "size": 1951} |
### File: references/depth/stereo/utils/norm.py
import torch
def freeze_batch_norm(model):
for m in model.modules():
if isinstance(m, torch.nn.BatchNorm2d):
m.eval()
def unfreeze_batch_norm(model):
for m in model.modules():
if isinstance(m, torch.nn.BatchNorm2d):
m.tr... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/depth/stereo/utils/norm.py", "license": "bsd-3-clause", "size": 278} |
### File: references/depth/stereo/utils/padder.py
import torch.nn.functional as F
class InputPadder:
"""Pads images such that dimensions are divisible by 8"""
# TODO: Ideally, this should be part of the eval transforms preset, instead
# of being part of the validation code. It's not obvious what a good
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/depth/stereo/utils/padder.py", "license": "bsd-3-clause", "size": 1139} |
### File: references/depth/stereo/visualization.py
import os
from typing import List
import numpy as np
import torch
from torch import Tensor
from torchvision.utils import make_grid
@torch.no_grad()
def make_disparity_image(disparity: Tensor):
# normalize image to [0, 1]
disparity = disparity.detach().cpu()
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/depth/stereo/visualization.py", "license": "bsd-3-clause", "size": 4964} |
### File: references/detection/coco_eval.py
import copy
import io
from contextlib import redirect_stdout
import numpy as np
import pycocotools.mask as mask_util
import torch
import utils
from pycocotools.coco import COCO
from pycocotools.cocoeval import COCOeval
class CocoEvaluator:
def __init__(self, coco_gt, i... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/detection/coco_eval.py", "license": "bsd-3-clause", "size": 6447} |
### File: references/detection/coco_utils.py
import os
import torch
import torch.utils.data
import torchvision
import transforms as T
from pycocotools import mask as coco_mask
from pycocotools.coco import COCO
def convert_coco_poly_to_mask(segmentations, height, width):
masks = []
for polygons in segmentatio... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/detection/coco_utils.py", "license": "bsd-3-clause", "size": 8397} |
### File: references/detection/engine.py
import math
import sys
import time
import torch
import torchvision.models.detection.mask_rcnn
import utils
from coco_eval import CocoEvaluator
from coco_utils import get_coco_api_from_dataset
def train_one_epoch(model, optimizer, data_loader, device, epoch, print_freq, scaler... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/detection/engine.py", "license": "bsd-3-clause", "size": 4063} |
### File: references/detection/group_by_aspect_ratio.py
import bisect
import copy
import math
from collections import defaultdict
from itertools import chain, repeat
import numpy as np
import torch
import torch.utils.data
import torchvision
from PIL import Image
from torch.utils.data.sampler import BatchSampler, Sampl... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/detection/group_by_aspect_ratio.py", "license": "bsd-3-clause", "size": 7147} |
### File: references/detection/presets.py
from collections import defaultdict
import torch
import transforms as reference_transforms
def get_modules(use_v2):
# We need a protected import to avoid the V2 warning in case just V1 is used
if use_v2:
import torchvision.transforms.v2
import torchvi... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/detection/presets.py", "license": "bsd-3-clause", "size": 3957} |
### File: references/detection/train.py
r"""PyTorch Detection Training.
To run in a multi-gpu environment, use the distributed launcher::
python -m torch.distributed.launch --nproc_per_node=$NGPU --use_env \
train.py ... --world-size $NGPU
The default hyperparameters are tuned for training on 8 gpus and ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/detection/train.py", "license": "bsd-3-clause", "size": 13684} |
### File: references/detection/transforms.py
from typing import Dict, List, Optional, Tuple, Union
import torch
import torchvision
from torch import nn, Tensor
from torchvision import ops
from torchvision.transforms import functional as F, InterpolationMode, transforms as T
def _flip_coco_person_keypoints(kps, width... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/detection/transforms.py", "license": "bsd-3-clause", "size": 23628} |
### File: references/detection/utils.py
import datetime
import errno
import os
import time
from collections import defaultdict, deque
import torch
import torch.distributed as dist
class SmoothedValue:
"""Track a series of values and provide access to smoothed values over a
window or the global series average... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/detection/utils.py", "license": "bsd-3-clause", "size": 8388} |
### File: references/optical_flow/presets.py
import torch
import transforms as T
class OpticalFlowPresetEval(torch.nn.Module):
def __init__(self):
super().__init__()
self.transforms = T.Compose(
[
T.PILToTensor(),
T.ConvertImageDtype(torch.float32),
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/optical_flow/presets.py", "license": "bsd-3-clause", "size": 1908} |
### File: references/optical_flow/train.py
import argparse
import warnings
from math import ceil
from pathlib import Path
import torch
import torchvision.models.optical_flow
import utils
from presets import OpticalFlowPresetEval, OpticalFlowPresetTrain
from torchvision.datasets import FlyingChairs, FlyingThings3D, HD1... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/optical_flow/train.py", "license": "bsd-3-clause", "size": 15503} |
### File: references/optical_flow/transforms.py
import torch
import torchvision.transforms as T
import torchvision.transforms.functional as F
class ValidateModelInput(torch.nn.Module):
# Pass-through transform that checks the shape and dtypes to make sure the model gets what it expects
def forward(self, img1,... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/optical_flow/transforms.py", "license": "bsd-3-clause", "size": 11949} |
### File: references/optical_flow/utils.py
import datetime
import os
import time
from collections import defaultdict, deque
import torch
import torch.distributed as dist
import torch.nn.functional as F
class SmoothedValue:
"""Track a series of values and provide access to smoothed values over a
window or the... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/optical_flow/utils.py", "license": "bsd-3-clause", "size": 9609} |
### File: references/segmentation/coco_utils.py
import copy
import os
import torch
import torch.utils.data
import torchvision
from PIL import Image
from pycocotools import mask as coco_mask
from transforms import Compose
class FilterAndRemapCocoCategories:
def __init__(self, categories, remap=True):
self... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/segmentation/coco_utils.py", "license": "bsd-3-clause", "size": 4325} |
### File: references/segmentation/presets.py
import torch
def get_modules(use_v2):
# We need a protected import to avoid the V2 warning in case just V1 is used
if use_v2:
import torchvision.transforms.v2
import torchvision.tv_tensors
import v2_extras
return torchvision.transfo... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/segmentation/presets.py", "license": "bsd-3-clause", "size": 3588} |
### File: references/segmentation/train.py
import datetime
import os
import time
import warnings
import presets
import torch
import torch.utils.data
import torchvision
import utils
from coco_utils import get_coco
from torch import nn
from torch.optim.lr_scheduler import PolynomialLR
from torchvision.transforms import ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/segmentation/train.py", "license": "bsd-3-clause", "size": 13404} |
### File: references/segmentation/transforms.py
import random
import numpy as np
import torch
from torchvision import transforms as T
from torchvision.transforms import functional as F
def pad_if_smaller(img, size, fill=0):
min_size = min(img.size)
if min_size < size:
ow, oh = img.size
padh =... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/segmentation/transforms.py", "license": "bsd-3-clause", "size": 2826} |
### File: references/segmentation/utils.py
import datetime
import errno
import os
import time
from collections import defaultdict, deque
import torch
import torch.distributed as dist
class SmoothedValue:
"""Track a series of values and provide access to smoothed values over a
window or the global series aver... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/segmentation/utils.py", "license": "bsd-3-clause", "size": 9142} |
### File: references/segmentation/v2_extras.py
"""This file only exists to be lazy-imported and avoid V2-related import warnings when just using V1."""
import torch
from torchvision import tv_tensors
from torchvision.transforms import v2
class PadIfSmaller(v2.Transform):
def __init__(self, size, fill=0):
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/segmentation/v2_extras.py", "license": "bsd-3-clause", "size": 3582} |
### File: references/similarity/loss.py
"""
Pytorch adaptation of https://omoindrot.github.io/triplet-loss
https://github.com/omoindrot/tensorflow-triplet-loss
"""
import torch
import torch.nn as nn
class TripletMarginLoss(nn.Module):
def __init__(self, margin=1.0, p=2.0, mining="batch_all"):
supe... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/similarity/loss.py", "license": "bsd-3-clause", "size": 3719} |
### File: references/similarity/model.py
import torch.nn as nn
import torchvision.models as models
class EmbeddingNet(nn.Module):
def __init__(self, backbone=None):
super().__init__()
if backbone is None:
backbone = models.resnet50(num_classes=128)
self.backbone = backbone
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/similarity/model.py", "license": "bsd-3-clause", "size": 395} |
### File: references/similarity/sampler.py
import random
from collections import defaultdict
import torch
from torch.utils.data.sampler import Sampler
def create_groups(groups, k):
"""Bins sample indices with respect to groups, remove bins with less than k samples
Args:
groups (list[int]): where ith... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/similarity/sampler.py", "license": "bsd-3-clause", "size": 2817} |
### File: references/similarity/test.py
import unittest
from collections import defaultdict
import torch
import torchvision.transforms as transforms
from sampler import PKSampler
from torch.utils.data import DataLoader
from torchvision.datasets import FakeData
class Tester(unittest.TestCase):
def test_pksampler(... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/similarity/test.py", "license": "bsd-3-clause", "size": 1516} |
### File: references/similarity/train.py
import os
import torch
import torchvision.transforms as transforms
from loss import TripletMarginLoss
from model import EmbeddingNet
from sampler import PKSampler
from torch.optim import Adam
from torch.utils.data import DataLoader
from torchvision.datasets import FashionMNIST
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/similarity/train.py", "license": "bsd-3-clause", "size": 6722} |
### File: references/video_classification/datasets.py
from typing import Tuple
import torchvision
from torch import Tensor
class KineticsWithVideoId(torchvision.datasets.Kinetics):
def __getitem__(self, idx: int) -> Tuple[Tensor, Tensor, int]:
video, audio, info, video_idx = self.video_clips.get_clip(idx... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/video_classification/datasets.py", "license": "bsd-3-clause", "size": 440} |
### File: references/video_classification/presets.py
import torch
from torchvision.transforms import transforms
from transforms import ConvertBCHWtoCBHW
class VideoClassificationPresetTrain:
def __init__(
self,
*,
crop_size,
resize_size,
mean=(0.43216, 0.394666, 0.37645),
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/video_classification/presets.py", "license": "bsd-3-clause", "size": 1936} |
### File: references/video_classification/train.py
import datetime
import os
import time
import warnings
import datasets
import presets
import torch
import torch.utils.data
import torchvision
import torchvision.datasets.video_utils
import utils
from torch import nn
from torch.utils.data.dataloader import default_colla... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/video_classification/train.py", "license": "bsd-3-clause", "size": 18245} |
### File: references/video_classification/transforms.py
import torch
import torch.nn as nn
class ConvertBCHWtoCBHW(nn.Module):
"""Convert tensor from (B, C, H, W) to (C, B, H, W)"""
def forward(self, vid: torch.Tensor) -> torch.Tensor:
return vid.permute(1, 0, 2, 3)
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/video_classification/transforms.py", "license": "bsd-3-clause", "size": 230} |
### File: references/video_classification/utils.py
import datetime
import errno
import os
import time
from collections import defaultdict, deque
import torch
import torch.distributed as dist
class SmoothedValue:
"""Track a series of values and provide access to smoothed values over a
window or the global ser... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "references/video_classification/utils.py", "license": "bsd-3-clause", "size": 7891} |
### File: scripts/collect_model_urls.py
import pathlib
import re
import sys
MODEL_URL_PATTERN = re.compile(r"https://download[.]pytorch[.]org/models/.+?[.]pth")
def main(*roots):
model_urls = set()
for root in roots:
for path in pathlib.Path(root).rglob("*.py"):
with open(path, "r") as fi... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "scripts/collect_model_urls.py", "license": "bsd-3-clause", "size": 484} |
### File: scripts/download_model_urls.py
import asyncio
import sys
from pathlib import Path
from time import perf_counter
from urllib.parse import urlsplit
import aiofiles
import aiohttp
from torchvision import models
from tqdm.asyncio import tqdm
async def main(download_root):
download_root.mkdir(parents=True, ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "scripts/download_model_urls.py", "license": "bsd-3-clause", "size": 1382} |
### File: scripts/fbcode_to_main_sync.sh
#!/bin/bash
if [ -z $1 ]
then
echo "Commit hash is required to be passed when running this script."
echo "./fbcode_to_main_sync.sh <commit_hash> <fork_name> <fork_main_branch>"
exit 1
fi
commit_hash=$1
if [ -z $2 ]
then
echo "Fork name is required to be passed ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Shell", "repo_name": "minhanghuang/pytorch-vision", "path": "scripts/fbcode_to_main_sync.sh", "license": "bsd-3-clause", "size": 1147} |
### File: scripts/release_notes/classify_prs.py
# In[1]:
# imports and set configuration
import pandas as pd
from retrieve_prs_data import run
exclude_prototype = True
data_filename = "10.0_to_11.0-rc2.json"
previous_release = "v10.0"
current_release = "v11.0-rc2"
# In[2]:
df = pd.read_json(data_filename).T
df.tai... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "scripts/release_notes/classify_prs.py", "license": "bsd-3-clause", "size": 3465} |
### File: scripts/release_notes/retrieve_prs_data.py
import json
import locale
import os
import re
import subprocess
from collections import namedtuple
from os.path import expanduser
import requests
Features = namedtuple(
"Features",
[
"title",
"body",
"pr_number",
"files_chan... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "scripts/release_notes/retrieve_prs_data.py", "license": "bsd-3-clause", "size": 5997} |
### File: setup.py
import distutils.command.clean
import distutils.spawn
import glob
import os
import shutil
import subprocess
import sys
import torch
from pkg_resources import DistributionNotFound, get_distribution, parse_version
from setuptools import find_packages, setup
from torch.utils.cpp_extension import BuildE... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "setup.py", "license": "bsd-3-clause", "size": 22359} |
### File: test/_utils_internal.py
import os
# Get relative file path
# this returns relative path from current file.
def get_relative_path(curr_file, *path_components):
return os.path.join(os.path.dirname(curr_file), *path_components)
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "test/_utils_internal.py", "license": "bsd-3-clause", "size": 207} |
### File: test/builtin_dataset_mocks.py
import bz2
import collections.abc
import csv
import functools
import gzip
import io
import itertools
import json
import lzma
import pathlib
import pickle
import random
import shutil
import unittest.mock
import xml.etree.ElementTree as ET
from collections import Counter, defaultdi... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "test/builtin_dataset_mocks.py", "license": "bsd-3-clause", "size": 54670} |
### File: test/common_extended_utils.py
import os
from collections import defaultdict
from numbers import Number
from typing import Any, List
import torch
from torch.utils._python_dispatch import TorchDispatchMode
from torch.utils._pytree import tree_map
from torchvision.models._api import Weights
aten = torch.ops.... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "test/common_extended_utils.py", "license": "bsd-3-clause", "size": 9627} |
### File: test/common_utils.py
import contextlib
import functools
import itertools
import os
import pathlib
import random
import re
import shutil
import sys
import tempfile
import warnings
from subprocess import CalledProcessError, check_output, STDOUT
import numpy as np
import PIL.Image
import pytest
import torch
imp... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "test/common_utils.py", "license": "bsd-3-clause", "size": 16187} |
### File: test/conftest.py
import random
import numpy as np
import pytest
import torch
from common_utils import (
CUDA_NOT_AVAILABLE_MSG,
IN_FBCODE,
IN_OSS_CI,
IN_RE_WORKER,
MPS_NOT_AVAILABLE_MSG,
OSS_CI_GPU_NO_CUDA_MSG,
)
def pytest_configure(config):
# register an additional marker (se... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "test/conftest.py", "license": "bsd-3-clause", "size": 5752} |
### File: test/cpp/test_custom_operators.cpp
#include <gtest/gtest.h>
#include <torch/script.h>
#include <torch/torch.h>
// FIXME: the include path differs from OSS due to the extra csrc
#include <torchvision/csrc/ops/nms.h>
TEST(test_custom_operators, nms) {
// make sure that the torchvision ops are visible to the... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "test/cpp/test_custom_operators.cpp", "license": "bsd-3-clause", "size": 1932} |
### File: test/datasets_utils.py
import contextlib
import functools
import importlib
import inspect
import itertools
import os
import pathlib
import platform
import random
import shutil
import string
import struct
import tarfile
import unittest
import unittest.mock
import zipfile
from collections import defaultdict
fro... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "test/datasets_utils.py", "license": "bsd-3-clause", "size": 40587} |
### File: test/preprocess-bench.py
import argparse
import os
from timeit import default_timer as timer
import torch
import torch.utils.data
import torchvision
import torchvision.datasets as datasets
import torchvision.transforms as transforms
from torch.utils.model_zoo import tqdm
parser = argparse.ArgumentParser(de... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "test/preprocess-bench.py", "license": "bsd-3-clause", "size": 2402} |
### File: test/prototype_common_utils.py
import collections.abc
import dataclasses
from typing import Optional, Sequence
import pytest
import torch
from torch.nn.functional import one_hot
from torchvision.prototype import tv_tensors
from transforms_v2_legacy_utils import combinations_grid, DEFAULT_EXTRA_DIMS, from_l... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "test/prototype_common_utils.py", "license": "bsd-3-clause", "size": 3083} |
### File: test/smoke_test.py
"""Run smoke tests"""
import sys
from pathlib import Path
import torch
import torchvision
from torchvision.io import decode_jpeg, read_file, read_image
from torchvision.models import resnet50, ResNet50_Weights
SCRIPT_DIR = Path(__file__).parent
def smoke_test_torchvision() -> None:
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "test/smoke_test.py", "license": "bsd-3-clause", "size": 3685} |
### File: test/tracing/frcnn/CMakeLists.txt
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(test_frcnn_tracing)
find_package(Torch REQUIRED)
find_package(TorchVision REQUIRED)
# This due to some headers importing Python.h
find_package(Python3 COMPONENTS Development)
add_executable(test_frcnn_tracing test_frc... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-vision", "path": "test/tracing/frcnn/CMakeLists.txt", "license": "bsd-3-clause", "size": 524} |
### File: test/tracing/frcnn/test_frcnn_tracing.cpp
#include <torch/script.h>
#include <torch/torch.h>
#include <torchvision/vision.h>
#include <torchvision/ops/nms.h>
int main() {
torch::DeviceType device_type;
device_type = torch::kCPU;
torch::jit::script::Module module;
try {
std::cout << "Loading mod... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "test/tracing/frcnn/test_frcnn_tracing.cpp", "license": "bsd-3-clause", "size": 1590} |
### File: test/tracing/frcnn/trace_model.py
import os.path as osp
import torch
import torchvision
HERE = osp.dirname(osp.abspath(__file__))
ASSETS = osp.dirname(osp.dirname(HERE))
model = torchvision.models.detection.fasterrcnn_resnet50_fpn(weights=None, weights_backbone=None)
model.eval()
traced_model = torch.jit.... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "test/tracing/frcnn/trace_model.py", "license": "bsd-3-clause", "size": 338} |
### File: test/transforms_v2_dispatcher_infos.py
import pytest
import torchvision.transforms.v2.functional as F
from torchvision import tv_tensors
from transforms_v2_kernel_infos import KERNEL_INFOS
from transforms_v2_legacy_utils import InfoBase, TestMark
__all__ = ["DispatcherInfo", "DISPATCHER_INFOS"]
class PILKe... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "test/transforms_v2_dispatcher_infos.py", "license": "bsd-3-clause", "size": 8832} |
### File: test/transforms_v2_kernel_infos.py
import functools
import itertools
import PIL.Image
import pytest
import torch.testing
import torchvision.transforms.v2.functional as F
from torchvision.transforms._functional_tensor import _max_value as get_max_value
from transforms_v2_legacy_utils import (
ArgsKwargs,
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "test/transforms_v2_kernel_infos.py", "license": "bsd-3-clause", "size": 34004} |
### File: test/transforms_v2_legacy_utils.py
"""
As the name implies, these are legacy utilities that are hopefully removed soon. The future of
transforms v2 testing is in test/test_transforms_v2_refactored.py. All new test should be
implemented there and must not use any of the utilities here.
The following legacy mo... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "test/transforms_v2_legacy_utils.py", "license": "bsd-3-clause", "size": 20298} |
### File: torchvision/__init__.py
import os
import warnings
from modulefinder import Module
import torch
from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils
from .extension import _HAS_OPS
try:
from .version import __version__ # noqa: F401
except ImportError:
pass
# C... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/__init__.py", "license": "bsd-3-clause", "size": 3368} |
### File: torchvision/_internally_replaced_utils.py
import importlib.machinery
import os
from torch.hub import _get_torch_home
_HOME = os.path.join(_get_torch_home(), "datasets", "vision")
_USE_SHARDED_DATASETS = False
def _download_file_from_remote_location(fpath: str, url: str) -> None:
pass
def _is_remote... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/_internally_replaced_utils.py", "license": "bsd-3-clause", "size": 1389} |
### File: torchvision/_meta_registrations.py
import functools
import torch
import torch._custom_ops
import torch.library
# Ensure that torch.ops.torchvision is visible
import torchvision.extension # noqa: F401
@functools.lru_cache(None)
def get_meta_lib():
return torch.library.Library("torchvision", "IMPL", "M... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/_meta_registrations.py", "license": "bsd-3-clause", "size": 2373} |
### File: torchvision/_utils.py
import enum
from typing import Sequence, Type, TypeVar
T = TypeVar("T", bound=enum.Enum)
class StrEnumMeta(enum.EnumMeta):
auto = enum.auto
def from_str(self: Type[T], member: str) -> T: # type: ignore[misc]
try:
return self[member]
except KeyErro... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/_utils.py", "license": "bsd-3-clause", "size": 934} |
### File: torchvision/csrc/io/decoder/audio_sampler.cpp
#include "audio_sampler.h"
#include <c10/util/Logging.h>
#include "util.h"
#define AVRESAMPLE_MAX_CHANNELS 32
// www.ffmpeg.org/doxygen/1.1/doc_2examples_2resampling_audio_8c-example.html#a24
namespace ffmpeg {
namespace {
int preparePlanes(
const AudioForm... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/audio_sampler.cpp", "license": "bsd-3-clause", "size": 5992} |
### File: torchvision/csrc/io/decoder/audio_sampler.h
#pragma once
#include "defs.h"
namespace ffmpeg {
/**
* Class transcode audio frames from one format into another
*/
class AudioSampler : public MediaSampler {
public:
explicit AudioSampler(void* logCtx);
~AudioSampler() override;
// MediaSampler overr... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/audio_sampler.h", "license": "bsd-3-clause", "size": 834} |
### File: torchvision/csrc/io/decoder/audio_stream.cpp
#include "audio_stream.h"
#include <c10/util/Logging.h>
#include <limits>
#include "util.h"
namespace ffmpeg {
namespace {
bool operator==(const AudioFormat& x, const AVFrame& y) {
return x.samples == static_cast<size_t>(y.sample_rate) &&
x.channels == st... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/audio_stream.cpp", "license": "bsd-3-clause", "size": 3168} |
### File: torchvision/csrc/io/decoder/audio_stream.h
#pragma once
#include "audio_sampler.h"
#include "stream.h"
namespace ffmpeg {
/**
* Class uses FFMPEG library to decode one audio stream.
*/
class AudioStream : public Stream {
public:
AudioStream(
AVFormatContext* inputCtx,
int index,
boo... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/audio_stream.h", "license": "bsd-3-clause", "size": 532} |
### File: torchvision/csrc/io/decoder/cc_stream.cpp
#include "cc_stream.h"
namespace ffmpeg {
CCStream::CCStream(
AVFormatContext* inputCtx,
int index,
bool convertPtsToWallTime,
const SubtitleFormat& format)
: SubtitleStream(inputCtx, index, convertPtsToWallTime, format) {
format_.type = TYPE_C... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/cc_stream.cpp", "license": "bsd-3-clause", "size": 619} |
### File: torchvision/csrc/io/decoder/cc_stream.h
#pragma once
#include "subtitle_stream.h"
namespace ffmpeg {
/**
* Class uses FFMPEG library to decode one closed captions stream.
*/
class CCStream : public SubtitleStream {
public:
CCStream(
AVFormatContext* inputCtx,
int index,
bool convertP... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/cc_stream.h", "license": "bsd-3-clause", "size": 416} |
### File: torchvision/csrc/io/decoder/decoder.cpp
#include "decoder.h"
#include <c10/util/Logging.h>
#include <libavutil/avutil.h>
#include <future>
#include <iostream>
#include <mutex>
#include "audio_stream.h"
#include "cc_stream.h"
#include "subtitle_stream.h"
#include "util.h"
#include "video_stream.h"
namespace f... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/decoder.cpp", "license": "bsd-3-clause", "size": 20979} |
### File: torchvision/csrc/io/decoder/decoder.h
#pragma once
#include <bitset>
#include <unordered_map>
#include "seekable_buffer.h"
#include "stream.h"
#if defined(_MSC_VER)
#include <BaseTsd.h>
using ssize_t = SSIZE_T;
#endif
namespace ffmpeg {
/**
* Class uses FFMPEG library to decode media streams.
* Media by... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/decoder.h", "license": "bsd-3-clause", "size": 2653} |
### File: torchvision/csrc/io/decoder/defs.h
#pragma once
#include <array>
#include <functional>
#include <memory>
#include <set>
#include <string>
#include <unordered_set>
#include <vector>
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavformat/avio.h>
#include <libavuti... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/defs.h", "license": "bsd-3-clause", "size": 12898} |
### File: torchvision/csrc/io/decoder/gpu/decoder.cpp
#include "decoder.h"
#include <c10/util/Logging.h>
#include <nppi_color_conversion.h>
#include <cmath>
#include <cstring>
#include <unordered_map>
static float chroma_height_factor(cudaVideoSurfaceFormat surface_format) {
return (surface_format == cudaVideoSurfac... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/gpu/decoder.cpp", "license": "bsd-3-clause", "size": 15424} |
### File: torchvision/csrc/io/decoder/gpu/decoder.h
#include <cuda.h>
#include <cuda_runtime_api.h>
#include <cuviddec.h>
#include <nvcuvid.h>
#include <torch/torch.h>
#include <cstdint>
#include <queue>
static auto check_for_cuda_errors =
[](CUresult result, int line_num, std::string file_name) {
if (CUDA_S... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/gpu/decoder.h", "license": "bsd-3-clause", "size": 2735} |
### File: torchvision/csrc/io/decoder/gpu/demuxer.h
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavcodec/bsf.h>
#include <libavformat/avformat.h>
#include <libavformat/avio.h>
}
class Demuxer {
private:
AVFormatContext* fmtCtx = NULL;
AVBSFContext* bsfCtx = NULL;
AVPacket pkt, pktFiltered;
AVCode... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/gpu/demuxer.h", "license": "bsd-3-clause", "size": 7277} |
### File: torchvision/csrc/io/decoder/gpu/gpu_decoder.cpp
#include "gpu_decoder.h"
#include <c10/cuda/CUDAGuard.h>
/* Set cuda device, create cuda context and initialise the demuxer and decoder.
*/
GPUDecoder::GPUDecoder(std::string src_file, torch::Device dev)
: demuxer(src_file.c_str()) {
at::cuda::CUDAGuard ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/gpu/gpu_decoder.cpp", "license": "bsd-3-clause", "size": 2068} |
### File: torchvision/csrc/io/decoder/gpu/gpu_decoder.h
#include <torch/custom_class.h>
#include <torch/torch.h>
#include "decoder.h"
#include "demuxer.h"
class GPUDecoder : public torch::CustomClassHolder {
public:
GPUDecoder(std::string, torch::Device);
~GPUDecoder();
torch::Tensor decode();
void seek(doubl... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/gpu/gpu_decoder.h", "license": "bsd-3-clause", "size": 468} |
### File: torchvision/csrc/io/decoder/memory_buffer.cpp
#include "memory_buffer.h"
#include <c10/util/Logging.h>
namespace ffmpeg {
MemoryBuffer::MemoryBuffer(const uint8_t* buffer, size_t size)
: buffer_(buffer), len_(size) {}
int MemoryBuffer::read(uint8_t* buf, int size) {
if (pos_ < len_) {
auto availa... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/memory_buffer.cpp", "license": "bsd-3-clause", "size": 1605} |
### File: torchvision/csrc/io/decoder/memory_buffer.h
#pragma once
#include "defs.h"
namespace ffmpeg {
/**
* Class uses external memory buffer and implements a seekable interface.
*/
class MemoryBuffer {
public:
explicit MemoryBuffer(const uint8_t* buffer, size_t size);
int64_t seek(int64_t offset, int whenc... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/memory_buffer.h", "license": "bsd-3-clause", "size": 591} |
### File: torchvision/csrc/io/decoder/seekable_buffer.cpp
#include "seekable_buffer.h"
#include <c10/util/Logging.h>
#include <chrono>
#include "memory_buffer.h"
namespace ffmpeg {
int SeekableBuffer::init(
DecoderInCallback&& in,
uint64_t timeoutMs,
size_t maxSeekableBytes,
ImageType* type) {
shutd... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/seekable_buffer.cpp", "license": "bsd-3-clause", "size": 3495} |
### File: torchvision/csrc/io/decoder/seekable_buffer.h
#pragma once
#include "defs.h"
namespace ffmpeg {
/**
* Class uses internal buffer to store initial size bytes as a seekable cache
* from Media provider and let ffmpeg to seek and read bytes from cache
* and beyond - reading bytes directly from Media provide... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/seekable_buffer.h", "license": "bsd-3-clause", "size": 1223} |
### File: torchvision/csrc/io/decoder/stream.cpp
#include "stream.h"
#include <c10/util/Logging.h>
#include <stdio.h>
#include <string.h>
#include "util.h"
namespace ffmpeg {
const AVRational timeBaseQ = AVRational{1, AV_TIME_BASE};
Stream::Stream(
AVFormatContext* inputCtx,
MediaFormat format,
bool conve... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/stream.cpp", "license": "bsd-3-clause", "size": 8491} |
### File: torchvision/csrc/io/decoder/stream.h
#pragma once
#include <atomic>
#include "defs.h"
#include "time_keeper.h"
namespace ffmpeg {
/**
* Class uses FFMPEG library to decode one media stream (audio or video).
*/
class Stream {
public:
Stream(
AVFormatContext* inputCtx,
MediaFormat format,
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/stream.h", "license": "bsd-3-clause", "size": 2452} |
### File: torchvision/csrc/io/decoder/subtitle_sampler.cpp
#include "subtitle_sampler.h"
#include <c10/util/Logging.h>
#include "util.h"
namespace ffmpeg {
SubtitleSampler::~SubtitleSampler() {
cleanUp();
}
void SubtitleSampler::shutdown() {
cleanUp();
}
bool SubtitleSampler::init(const SamplerParameters& param... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/subtitle_sampler.cpp", "license": "bsd-3-clause", "size": 862} |
### File: torchvision/csrc/io/decoder/subtitle_sampler.h
#pragma once
#include "defs.h"
namespace ffmpeg {
/**
* Class transcode audio frames from one format into another
*/
class SubtitleSampler : public MediaSampler {
public:
SubtitleSampler() = default;
~SubtitleSampler() override;
bool init(const Samp... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/subtitle_sampler.h", "license": "bsd-3-clause", "size": 743} |
### File: torchvision/csrc/io/decoder/subtitle_stream.cpp
#include "subtitle_stream.h"
#include <c10/util/Logging.h>
#include <limits>
#include "util.h"
namespace ffmpeg {
const AVRational timeBaseQ = AVRational{1, AV_TIME_BASE};
SubtitleStream::SubtitleStream(
AVFormatContext* inputCtx,
int index,
bool c... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/subtitle_stream.cpp", "license": "bsd-3-clause", "size": 2413} |
### File: torchvision/csrc/io/decoder/subtitle_stream.h
#pragma once
#include "stream.h"
#include "subtitle_sampler.h"
namespace ffmpeg {
/**
* Class uses FFMPEG library to decode one subtitle stream.
*/
struct AVSubtitleKeeper : AVSubtitle {
int64_t release{0};
};
class SubtitleStream : public Stream {
public... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/subtitle_stream.h", "license": "bsd-3-clause", "size": 798} |
### File: torchvision/csrc/io/decoder/sync_decoder.cpp
#include "sync_decoder.h"
#include <c10/util/Logging.h>
namespace ffmpeg {
SyncDecoder::AVByteStorage::AVByteStorage(size_t n) {
ensure(n);
}
SyncDecoder::AVByteStorage::~AVByteStorage() {
av_free(buffer_);
}
void SyncDecoder::AVByteStorage::ensure(size_t n... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/sync_decoder.cpp", "license": "bsd-3-clause", "size": 2068} |
### File: torchvision/csrc/io/decoder/sync_decoder.h
#pragma once
#include <list>
#include "decoder.h"
namespace ffmpeg {
/**
* Class uses FFMPEG library to decode media streams.
* Media bytes can be explicitly provided through read-callback
* or fetched internally by FFMPEG library
*/
class SyncDecoder : public... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/sync_decoder.h", "license": "bsd-3-clause", "size": 1216} |
### File: torchvision/csrc/io/decoder/sync_decoder_test.cpp
#include <c10/util/Logging.h>
#include <dirent.h>
#include <gtest/gtest.h>
#include "memory_buffer.h"
#include "sync_decoder.h"
#include "util.h"
using namespace ffmpeg;
namespace {
struct VideoFileStats {
std::string name;
size_t durationPts{0};
int n... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/sync_decoder_test.cpp", "license": "bsd-3-clause", "size": 12702} |
### File: torchvision/csrc/io/decoder/time_keeper.cpp
#include "time_keeper.h"
#include "defs.h"
namespace ffmpeg {
namespace {
const long kMaxTimeBaseDiference = 10;
}
long TimeKeeper::adjust(long& decoderTimestamp) {
const long now = std::chrono::duration_cast<std::chrono::microseconds>(
s... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/time_keeper.cpp", "license": "bsd-3-clause", "size": 860} |
### File: torchvision/csrc/io/decoder/time_keeper.h
#pragma once
#include <stdlib.h>
#include <chrono>
namespace ffmpeg {
/**
* Class keeps the track of the decoded timestamps (us) for media streams.
*/
class TimeKeeper {
public:
TimeKeeper() = default;
// adjust provided @timestamp to the corrected value
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/time_keeper.h", "license": "bsd-3-clause", "size": 461} |
### File: torchvision/csrc/io/decoder/util.cpp
#include "util.h"
#include <c10/util/Logging.h>
namespace ffmpeg {
namespace Serializer {
// fixed size types
template <typename T>
inline size_t getSize(const T& x) {
return sizeof(x);
}
template <typename T>
inline bool serializeItem(
uint8_t* dest,
size_t ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/util.cpp", "license": "bsd-3-clause", "size": 12249} |
### File: torchvision/csrc/io/decoder/util.h
#pragma once
#include "defs.h"
namespace ffmpeg {
/**
* FFMPEG library utility functions.
*/
namespace Util {
std::string generateErrorDesc(int errorCode);
size_t serialize(const AVSubtitle& sub, ByteStorage* out);
bool deserialize(const ByteStorage& buf, AVSubtitle* s... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/util.h", "license": "bsd-3-clause", "size": 618} |
### File: torchvision/csrc/io/decoder/util_test.cpp
#include <c10/util/Logging.h>
#include <dirent.h>
#include <gtest/gtest.h>
#include "util.h"
TEST(Util, TestSetFormatDimensions) {
// clang-format off
const size_t test_cases[][9] = {
// (userW, userH, srcW, srcH, minDimension, maxDimension, cropImage, dest... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/util_test.cpp", "license": "bsd-3-clause", "size": 1340} |
### File: torchvision/csrc/io/decoder/video_sampler.cpp
#include "video_sampler.h"
#include <c10/util/Logging.h>
#include "util.h"
// www.ffmpeg.org/doxygen/0.5/swscale-example_8c-source.html
namespace ffmpeg {
namespace {
// Setup the data pointers and linesizes based on the specified image
// parameters and the p... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/video_sampler.cpp", "license": "bsd-3-clause", "size": 10427} |
### File: torchvision/csrc/io/decoder/video_sampler.h
#pragma once
#include "defs.h"
namespace ffmpeg {
/**
* Class transcode video frames from one format into another
*/
class VideoSampler : public MediaSampler {
public:
VideoSampler(int swsFlags = SWS_AREA, int64_t loggingUuid = 0);
~VideoSampler() overri... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/video_sampler.h", "license": "bsd-3-clause", "size": 1002} |
### File: torchvision/csrc/io/decoder/video_stream.cpp
#include "video_stream.h"
#include <c10/util/Logging.h>
#include "util.h"
namespace ffmpeg {
namespace {
bool operator==(const VideoFormat& x, const AVFrame& y) {
return x.width == static_cast<size_t>(y.width) &&
x.height == static_cast<size_t>(y.height) ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/video_stream.cpp", "license": "bsd-3-clause", "size": 4157} |
### File: torchvision/csrc/io/decoder/video_stream.h
#pragma once
#include "stream.h"
#include "video_sampler.h"
namespace ffmpeg {
/**
* Class uses FFMPEG library to decode one video stream.
*/
class VideoStream : public Stream {
public:
VideoStream(
AVFormatContext* inputCtx,
int index,
boo... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/decoder/video_stream.h", "license": "bsd-3-clause", "size": 621} |
### File: torchvision/csrc/io/image/cpu/common_jpeg.cpp
#include "common_jpeg.h"
namespace vision {
namespace image {
namespace detail {
#if JPEG_FOUND
void torch_jpeg_error_exit(j_common_ptr cinfo) {
/* cinfo->err really points to a torch_jpeg_error_mgr struct, so coerce
* pointer */
torch_jpeg_error_ptr myer... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/image/cpu/common_jpeg.cpp", "license": "bsd-3-clause", "size": 698} |
### File: torchvision/csrc/io/image/cpu/common_jpeg.h
#pragma once
#if JPEG_FOUND
#include <stdio.h>
#include <jpeglib.h>
#include <setjmp.h>
namespace vision {
namespace image {
namespace detail {
static const JOCTET EOI_BUFFER[1] = {JPEG_EOI};
struct torch_jpeg_error_mgr {
struct jpeg_error_mgr pub; /* "public"... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-vision", "path": "torchvision/csrc/io/image/cpu/common_jpeg.h", "license": "bsd-3-clause", "size": 577} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.