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 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: |
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
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): |
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
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) |
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
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) |