This file contains hidden or 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
# adapted from https://github.com/autonomousvision/giraffe (MIT License) | |
class Renderer(object): | |
# ... | |
def render_full_visualization(self, img_out_path, | |
render_program=['object_rotation']): | |
for rp in render_program: | |
# ... | |
# APPEND THIS TO THE END OF render_full_visualization | |
if rp == 'object_wipeout': | |
self.set_random_seed() |
This file contains hidden or 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
# adapted from https://github.com/autonomousvision/giraffe (MIT License) | |
inherit_from: configs/256res/cars_256.yaml | |
training: | |
out_dir: out/cars256_pretrained | |
test: | |
model_file: https://s3.eu-central-1.amazonaws.com/avg-projects/giraffe/models/checkpoint_cars256-d9ea5e11.pt | |
rendering: | |
render_dir: rendering | |
render_program: ['object_wipeout'] |
This file contains hidden or 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
# adapted from https://github.com/autonomousvision/giraffe (MIT License) | |
inherit_from: configs/256res/cars_256.yaml | |
training: | |
out_dir: out/cars256_pretrained | |
test: | |
model_file: https://s3.eu-central-1.amazonaws.com/avg-projects/giraffe/models/checkpoint_cars256-d9ea5e11.pt | |
rendering: | |
render_dir: rendering | |
render_program: ['render_camera_elevation', 'render_add_cars'] |
This file contains hidden or 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 PointerNetwork(nn.Module): | |
""" | |
From "Pointer Networks" by Vinyals et al. (2017) | |
Adapted from pointer-networks-pytorch by ast0414: | |
https://github.com/ast0414/pointer-networks-pytorch | |
Args: | |
n_hidden: The number of features to expect in the inputs. | |
""" |
This file contains hidden or 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 GradTracker(): | |
def __init__( | |
self, | |
model: nn.Module | |
): | |
self.model = model | |
self.reset_history() | |
self.reset_buffer() | |
def __getitem__( |
This file contains hidden or 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 models/layers/mesh_conv.py in https://github.com/ranahanocka/MeshCNN | |
def dihedral_angle(mesh, edge_points): | |
""" | |
Angle between two faces connected to edge. | |
""" | |
normals_a = get_normals(mesh, edge_points, 0) | |
normals_b = get_normals(mesh, edge_points, 3) | |
dot = np.sum(normals_a * normals_b, axis=1).clip(-1, 1) | |
angles = np.expand_dims(np.pi - np.arccos(dot), axis=0) |
This file contains hidden or 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
# Simplified from models/layers/mesh_conv.py in https://github.com/ranahanocka/MeshCNN | |
class MeshCov(nn.Module): | |
def __init__(self, in_c, out_c, k=5, bias=True): | |
super(MeshConv, self).__init__() | |
self.conv = nn.Conv2d(in_channels=in_c, out_channels=out_c, kernel_size=(1, k), bias=bias) | |
def forward(self, x) | |
""" | |
Forward pass given a feature tensor x with shape (N, C, E, 5): |
This file contains hidden or 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 https://towardsdatascience.com/docker-for-data-science-9c0ce73e8263 | |
# We will use Ubuntu for our image | |
FROM ubuntu | |
# Updating Ubuntu packages | |
RUN apt-get update && yes|apt-get upgrade | |
# Adding wget and bzip2 | |
RUN apt-get install -y wget bzip2 |
This file contains hidden or 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
# "If you want to ignore the file conflict and let dpkg take over the file (even without the Replaces), | |
# you can pass the --force-overwrite command-line option." | |
# (https://raphaelhertzog.com/2011/08/01/understanding-dpkgs-file-overwrite-error/) | |
sudo apt-get -o Dpkg::Options::="--force-overwrite" install --fix-broken |
This file contains hidden or 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 __future__ import division | |
from math import sqrt | |
from os.path import basename, splitext, join | |
from PIL import Image | |
import deepzoom | |
from openslide import open_slide | |
try: | |
from functools import reduce | |
except ImportError: |