This file contains hidden or 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 tempfile | |
| import urllib.request | |
| import importlib.util | |
| from pathlib import Path | |
| def import_from_url(url): | |
| """Import a module from a given URL""" | |
| with tempfile.TemporaryDirectory() as path: | |
| path = Path(path) / Path(url).name |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |