Skip to content

Instantly share code, notes, and snippets.

class SegDataset(Dataset):
def __init__(self, csv_loc, data_dir, augments=200):
self.data_dir = data_dir
self.images_data = read_csv(csv_loc)
self.images = self.prepare_images()
def transform(self, raw, seg):
i, j, h, w = transforms.RandomCrop.get_params(
raw, output_size=(128, 128))
raw = trans_f.crop(raw, i, j, h, w)
device = torch.device("cuda")
class SegDataset(Dataset):
def __init__(self, csv_loc, data_dir):
self.data_dir = data_dir
self.images_data = read_csv(csv_loc)
self.images = self.prepare_images()
def transform(self, raw, seg):
t = transforms.CenterCrop(128)
@mataney
mataney / UNet.py
Last active June 22, 2018 10:40
UNet implementation
class UNet(nn.Module):
def __init__(self, in_dim, out_dim, num_filter, lr):
super(UNet, self).__init__()
self.in_dim = in_dim
self.out_dim = out_dim
self.num_filter = num_filter
act_fn = nn.LeakyReLU(0.2, inplace=True)
def conv_block(in_dim, out_dim, act_fn):
@mataney
mataney / finished_files_openntm_style.py
Created November 15, 2017 15:03
Using finished files to openNTM style
from tensorflow.core.example import example_pb2
import tensorflow as tf
import glob, struct
def text_generator(example_generator):
"""Generates article and abstract text from tf.Example.
Args:
example_generator: a generator of tf.Examples from file. See data.example_generator"""
while True: