Last active
August 29, 2019 11:20
-
-
Save gatheluck/3192bd43ac120f703284a99b263b0f56 to your computer and use it in GitHub Desktop.
Compare the results of rendering
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
import os | |
import tqdm | |
import argparse | |
import torch | |
import torch.nn as nn | |
import torchvision | |
from skimage.io import imread, imsave | |
import neural_renderer as nr | |
import soft_renderer as sr | |
current_dir = os.path.dirname(os.path.realpath(__file__)) | |
data_dir = os.path.join(current_dir, 'data') | |
def main(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('-io', '--filename_obj', type=str, default=os.path.join(data_dir, 'teapot.obj')) | |
opts = parser.parse_args() | |
# load .obj | |
vertices, faces = nr.load_obj(opts.filename_obj) | |
vertices, faces = vertices[None,:,:], faces[None,:,:] | |
nmr_renderer = nr.Renderer(camera_mode='look_at', perspective=False) | |
nmr_renderer.eye = [0, 0, -2.732] | |
softras_renderer = sr.SoftRenderer(camera_mode='look_at', perspective=False, eye=[0, 0, -2.732]) | |
nmr_images = nmr_renderer(vertices, faces, mode='silhouettes') | |
softras_images = softras_renderer(vertices, faces)[:,-1,:,:] | |
image_1st = torch.cat((nmr_images, softras_images), dim=2) | |
image_2nd = torch.cat((softras_images, nmr_images), dim=2) | |
torchvision.utils.save_image(torch.cat((image_1st,image_2nd), dim=1), '../logs/my_cat.png') | |
if __name__=='__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment