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
def demo_vectorized_interface(): | |
""" | |
This demonstrates how to use the kwcoco vectorized interface for images / | |
categories / annotations. | |
""" | |
import kwcoco | |
import ubelt as ub | |
# Dummy data for the demo | |
coco_dset = kwcoco.CocoDataset.demo('vidshapes3', num_frames=5) | |
# Reroot to make file-paths more readable in this demo as relative paths |
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 redbaron | |
import ubelt as ub | |
import re | |
import xdev | |
# INPUT: | |
# fpath = <path-to-the-file> | |
text = open(fpath).read() |
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
""" | |
References: | |
https://github.com/willmcgugan/rich/blob/master/rich/_loop.py | |
https://twitter.com/graingert/status/1432827783357607937 | |
""" | |
from typing import Iterable, Tuple, TypeVar | |
T = TypeVar("T") | |
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
# https://gis.cdc.gov/grasp/covidnet/COVID19_5.html | |
# 2020-21 | |
import ubelt as ub | |
US_POP_APPROX = 330e6 | |
SAMPLE_SIZE = US_POP_APPROX * 0.1 | |
print(SAMPLE_SIZE) | |
# NOTE: These are lab-verified COVID numbers. The sample size is 190509. This | |
# represents about 10% of the US population. This chart says total observed |
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
def lazy_install(module_name, submodules, submod_attrs): | |
""" | |
Defines gettr for lazy import via PEP 562 | |
https://www.python.org/dev/peps/pep-0562/ | |
""" | |
import sys | |
import importlib | |
import importlib.util | |
all_funcs = [] | |
for mod, funcs in submod_attrs.items(): |
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
""" | |
Experiment Script Related to Pytorch Memory Leak Issue | |
References: | |
https://github.com/pytorch/pytorch/issues/13246 | |
https://gist.github.com/mprostock/2850f3cd465155689052f0fa3a177a50 | |
""" | |
from torch.utils.data import Dataset, DataLoader | |
import numpy as np | |
import torch |
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
(py36) joncrall@Ooo:~/code/netharn$ python setup.py build | |
-------------------------------------------------------------------------------- | |
-- Trying "Ninja" generator | |
-------------------------------- | |
--------------------------- | |
---------------------- | |
----------------- | |
------------ |
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
(py36) joncrall@Ooo:~/code/netharn$ ./setup.py clean && pip install -e . | |
Deleting directory="./__pycache__" | |
Deleting directory="./_skbuild" | |
Not deleting non-existant path="./__pycache__/skbuild_pr.cpython-36.pyc" | |
Obtaining file:///home/joncrall/code/netharn | |
Installing build dependencies ... done | |
Getting requirements to build wheel ... done | |
Preparing wheel metadata ... done | |
Requirement already satisfied: torch in /home/joncrall/.local/conda/envs/py36/lib/python3.6/site-packages (from netharn==0.1.8.dev0) (1.0.0) | |
Requirement already satisfied: tqdm in /home/joncrall/.local/conda/envs/py36/lib/python3.6/site-packages (from netharn==0.1.8.dev0) (4.23.4) |
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
# -*- coding: utf-8 -*- | |
""" | |
This module can be used as both a script and an importable module. | |
Run `python ggr_matching.py --help` for more details. | |
See docstring in fit for more details on the importable module. | |
conda install opencv | |
conda install pytorch torchvision -c pytorch |
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
__heredoc__(){ NOOP=; } | |
has_pymodule(){ | |
__heredoc__ ''' | |
Check if a python module is installed. Echos "True" or "False" to the | |
command line depending on the result. | |
Example: | |
source $HOME/local/init/utils.sh |