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
<!DOCTYPE html> | |
<html> | |
<!-- | |
+lightbox.html, a page for automatically showing all images in a | |
directory on an Apache server. Just copy it into the directory. | |
Works by scraping the default directory HTML at "./" - David Bau. | |
--> | |
<head> | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js" | |
integrity="sha256-CMMTrj5gGwOAXBeFi7kNokqowkzbeL8ydAJy39ewjkQ=" |
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
''' | |
To use a runningstats object, | |
1. Create the the desired stat object, e.g., `m = Mean()` | |
2. Feed it batches via the add method, e.g., `m.add(batch)` | |
3. Repeat step 2 any number of times. | |
4. Read out the statistic of interest, e.g., `m.mean()` | |
Built-in runningstats objects include: |
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 instrumenting a torch model. (David Bau) | |
Trace will hook one layer at a time. | |
TraceDict will hook multiple layers at once. | |
subsequence slices intervals from Sequential modules. | |
get_module, replace_module, get_parameter resolve dotted names. | |
set_requires_grad recursively sets requires_grad in module parameters. | |
""" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
<!DOCTYPE html> | |
<html> | |
<!-- an example vue HTML file that displays images and metadata --> | |
<head> | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js" | |
integrity="sha256-CMMTrj5gGwOAXBeFi7kNokqowkzbeL8ydAJy39ewjkQ=" | |
crossorigin="anonymous"></script> | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lodash.js" | |
integrity="sha256-qwbDmNVLiCqkqRBpF46q5bjYH11j5cd+K+Y6D3/ja28=" | |
crossorigin="anonymous"></script> |
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 os | |
import torch.utils.data as data | |
from torchvision.datasets.folder import default_loader, is_image_file | |
from PIL import Image | |
def grayscale_loader(path): | |
with open(path, 'rb') as f: | |
return Image.open(f).convert('L') | |
class FeatureFolder(data.Dataset): |
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 collections import defaultdict | |
from importlib import import_module | |
def autoimport_eval(term): | |
''' | |
Used to eval any expression containing fully-qualified names, such as | |
'torchvision.models.alexnet(pretrained=True)' with automatic import of | |
global module names. | |
''' |
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 python2.7 | |
# Script to create simple flat pytorch ImageFolder folder hierarchy | |
# of training and validation images for miniplaces. Each category | |
# name is just a folder name (numbered in alphabetical order as in | |
# the original miniplaces), and both train and val images are places | |
# directly inside a single level of folders with the flat cateogry names. | |
import shutil, os, tarfile |
NewerOlder