Skip to content

Instantly share code, notes, and snippets.

Avatar
An eroteme is a question mark

Jon Crall Erotemic

An eroteme is a question mark
View GitHub Profile
@Erotemic
Erotemic / autogen_skimage_filters_init.py
Created Dec 24, 2020
Demo auto-generated version of skimage.filters
View autogen_skimage_filters_init.py
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():
View debug_memory.py
"""
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
View gist:244890e27b37aa2219ac2f3414f8c302
(py36) joncrall@Ooo:~/code/netharn$ python setup.py build
--------------------------------------------------------------------------------
-- Trying "Ninja" generator
--------------------------------
---------------------------
----------------------
-----------------
------------
@Erotemic
Erotemic / gist:1f9b19ad1d116c9731ce7f446f020ce4
Created Feb 9, 2019
cant find numpy error with pip install
View gist:1f9b19ad1d116c9731ce7f446f020ce4
(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)
View ggr_matching.py
# -*- 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
@Erotemic
Erotemic / ubuntu_setup_venv3_standalone.sh
Last active Dec 19, 2018
The setup_venv3 bash command sets up a python3 virtual environment on a fresh ubuntu install. The file contains quite a few helper functions that make the actual implementation of setup_venv3 rather short.
View ubuntu_setup_venv3_standalone.sh
__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
View scale_space.py
import scipy
import scipy.ndimage
import numpy as np
import ubelt as ub
def g(f, s, **kw):
"""
Apply a gaussian filter to an input signal
View benchmark_pandas.py
def benchmark_pandas():
import timerit
import pandas as pd
import numpy as np
column_data = {
key: np.random.rand(1000)
for key in map(chr, range(ord('a'), ord('z')))
}
View gist:27f80be9eca982aa51518770b826b6a4
Timer unit: 1e-06 s
Pystone time: 0.026254 s
File: /home/joncrall/code/netharn/netharn/models/yolo2/light_region_loss.py
Function: _build_targets_tensor at line 382
Line # Hits Time Per Hit % Time Line Contents
==============================================================
382 @profiler.profile
View gist:e6be4658bad9fa28a56bf4e7c516a820
Timer unit: 1e-06 s
Pystone time: 0.05441 s
File: /home/joncrall/code/netharn/netharn/models/yolo2/light_postproc.py
Function: _get_boxes at line 202
Line # Hits Time Per Hit % Time Line Contents
==============================================================
202 @profiler.profile