Skip to content

Commit

Permalink
Change to use basic scene
Browse files Browse the repository at this point in the history
  • Loading branch information
oarriaga committed Nov 5, 2020
1 parent 571f7df commit 5f55336
Showing 1 changed file with 13 additions and 29 deletions.
42 changes: 13 additions & 29 deletions examples/discovery_of_latent_keypoints/discover_latent_keypoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
# os.environ["CUDA_DEVICE_ORDER"] = 'PCI_BUS_ID'
# os.environ["CUDA_VISIBLE_DEVICES"] = '0'
# os.environ["PYOPENGL_PLATFORM"] = 'egl'
from distutils.util import strtobool

import json
import argparse

import numpy as np
from paz.models import KeypointNetShared
from paz.models import Projector

from paz.abstract import GeneratingSequence
from paz.optimization import KeypointNetLoss
from paz.optimization.callbacks import DrawInferences
Expand All @@ -21,17 +18,11 @@
from tensorflow.keras.callbacks import ReduceLROnPlateau, EarlyStopping
from tensorflow.keras.utils import Progbar

from poseur.scenes import MultiView
import numpy as np
from scene import DualView

description = 'Training script for learning latent 3D keypoints'
parser = argparse.ArgumentParser(description=description)
parser.add_argument(
'-op', '--obj_path',
default=os.path.join(
os.path.expanduser('~'),
'.keras/paz/datasets/ycb/models/035_power_drill/textured.obj'),
type=str, help='Path for writing model weights and logs')
parser.add_argument('-fp', '--filepath', type=str, help='Path of OBJ mesh')
parser.add_argument('-cl', '--class_name', default='035_power_drill', type=str,
help='Class name to be added to model save path')
parser.add_argument('-nk', '--num_keypoints', default=7, type=int,
Expand All @@ -56,26 +47,20 @@
help='Maximum number of epochs before finishing')
parser.add_argument('-st', '--steps_per_epoch', default=1000, type=int,
help='Steps per epoch')
parser.add_argument('-sh', '--sphere', default='full',
choices=['full', 'half'], type=str,
parser.add_argument('-to', '--top_only', default=0, choices=[0, 1], type=int,
help='Flag for full sphere or top half for rendering')
parser.add_argument('-sm', '--smooth', type=strtobool, nargs='?',
const=True, default=True,
help='Activate smoothness trimesh flag for loading object')
parser.add_argument('-r', '--roll', default=3.14159, type=float,
help='Threshold for camera roll in radians')
parser.add_argument('-t', '--translation', default=None, type=float,
help='Threshold for translation')
help='Angle in radians used to sample roll of camera')
parser.add_argument('-s', '--shift', default=None, type=float,
help='Shift in XY camera axis')
parser.add_argument('-d', '--depth', default=0.30, type=float,
help='Distance from camera to origin in meters')
parser.add_argument('-s', '--shift', default=0.05, type=float,
help='Threshold of random shift of camera')
parser.add_argument('-fv', '--y_fov', default=3.14159 / 4.0, type=float,
help='Field of view angle in radians')
parser.add_argument('-sc', '--scale', default=10.0, type=float,
help='Scale applied to translation vector')
parser.add_argument('-l', '--light', default=5.0, type=float,
help='Light intensity from poseur')
parser.add_argument('-bk', '--background', default=0, type=int,
help='Background color')
parser.add_argument('-rn', '--rotation_noise', default=0.1, type=float,
help='Sigma of noise added to relative pose estimation')
parser.add_argument('-sd', '--separation_delta', default=0.05, type=float,
Expand All @@ -92,11 +77,10 @@


# setting scene
scene = MultiView(args.obj_path, (args.image_size, args.image_size),
args.y_fov, args.depth, args.sphere, args.roll,
args.translation, args.shift, args.light,
args.background, bool(args.smooth))
focal_length = scene.camera.get_projection_matrix()[0, 0]
scene = DualView(args.filepath, (args.image_size, args.image_size),
args.y_fov, args.depth, args.light, bool(args.top_only),
args.scale, args.roll, args.shift)
focal_length = scene.camera.camera.get_projection_matrix()[0, 0]

# setting sequence
input_shape = (args.image_size, args.image_size, 3)
Expand Down

0 comments on commit 5f55336

Please sign in to comment.