This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gc | |
import math | |
import time | |
import datetime | |
from contextlib import contextmanager | |
import torch | |
class Monitor: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ssl | |
import urllib | |
from pathlib import Path | |
import torch | |
from torch.utils.data import Dataset | |
from torchvision.datasets.utils import extract_archive, check_integrity | |
import h5py | |
import pandas as pd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def chunk_dim(tensor, chunks, dim=0): | |
"""Split a dimension of a tensor into two dimensions""" | |
shape = list(tensor.shape) | |
shape[dim] //= chunks | |
shape.insert(dim, chunks) | |
return tensor.view(shape) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Frechet's distance between two multi-variate Gaussians""" | |
import torch | |
import torch.nn as nn | |
class FrechetDistance: | |
"""Frechet's distance between two multi-variate Gaussians | |
https://www.sciencedirect.com/science/article/pii/0047259X8290077X | |
""" | |
def __init__(self, double=True, num_iterations=20, eps=1e-12): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Tuple, Optional, Union, List | |
import torch | |
import torch.nn as nn | |
__all__ = [ | |
'dot', 'get_neighbors', 'gather_features', 'point_sparsity', | |
'weighted_sampling' | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
from typing import Tuple, Optional | |
from contextlib import contextmanager | |
import torch | |
from torch.utils import benchmark | |
# @torch.jit.script | |
def nearest_neighbors( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Utilities for argparse arguments.""" | |
import os | |
import sys | |
from argparse import Namespace | |
from collections import OrderedDict | |
from itertools import product, chain | |
from typing import Union, Dict | |
__all__ = ['parse_grid'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""Ego4D video box blur.""" | |
import gc | |
import json | |
from pathlib import Path | |
from argparse import ArgumentParser | |
# conda install av pillow tqdm -c conda-forge -c anaconda | |
import av # used versions: av=8.0.3 and ffmpeg=4.3.1 | |
from tqdm import tqdm # used versions: tqdm=4.59.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""YOLOv3 object detector.""" | |
import math | |
from pathlib import Path | |
from urllib.request import urlopen | |
from PIL import Image | |
from PIL import ImageColor, ImageOps | |
import matplotlib.pyplot as plt | |
import matplotlib.patches as patches |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import partial | |
import torch | |
from torch import nn | |
from torch.autograd import grad | |
from torch.autograd.functional import jacobian, jvp | |
def rand_cov(vector): | |
"""Create a covariance matrix from the specs of a given vector.""" |