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 torch | |
import torch.nn as nn | |
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence | |
seqs = ['gigantic_string','tiny_str','medium_str'] | |
# make <pad> idx 0 | |
vocab = ['<pad>'] + sorted(set(''.join(seqs))) | |
# make model |
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
cmd=$@ | |
cv_dir=`expr "$cmd" : '.*--cv_dir \([^ ]*\).*'` | |
mkdir -p $cv_dir | |
# temporarily create two files: submit.sh and run.sh | |
cat > $cv_dir/submit.sh << EOF | |
universe = vanilla | |
Executable = /lusr/bin/bash | |
Arguments = $cv_dir/run.sh |
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 torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
import torchvision.models as tmodels | |
from functools import partial | |
import collections | |
# dummy data: 10 batches of images with batch size 16 | |
dataset = [torch.rand(16,3,224,224).cuda() for _ in range(10)] |
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 cv2 | |
import numpy as np | |
import argparse | |
''' | |
usage: python click_heatmap.py <image file> | |
left-click: add point to heatmap | |
s: save image (000.png, 001.png, ...) | |
q: quit | |
r: reset |
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 torch | |
import io | |
from PIL import Image | |
import numpy as np | |
# Dataset class for extracting binary data from images to store | |
class ImageDataset: | |
def __init__(self): | |
super(ImageDataset, self).__init__() | |
self.images = [] # some list of PIL images |
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
Video player with live chat playback |
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
function getDriveFolderFromPath (path) { | |
return (path || "/").split("/").reduce ( function(prev,current) { | |
if (prev && current) { | |
var fldrs = prev.getFoldersByName(current); | |
return fldrs.hasNext() ? fldrs.next() : null; | |
} | |
else { | |
return current ? null : prev; | |
} | |
},DriveApp.getRootFolder()); |