Exemple #1
0
if LOGGING:
    wandb.watch(policy)

optimizer = torch.optim.Adam(policy.parameters(), lr=params["LR"])
eps = np.finfo(np.float32).eps.item()

if not os.path.exists(exp_dir):
    os.mkdir(exp_dir)

fixed_cam = npa([0, 0, 0])

for i_episode in trange(params["NUM_EPISODES"]):
    # sample image
    state = torch.Tensor(data_generator.sample()).permute(
        2, 0, 1).unsqueeze(0).to(device)
    env.base_light = -data_generator.light + 1

    # encode to latent variables (mu/var)
    latent_mu, latent_variance = policy.encode(state)

    lmu_npy = latent_mu.detach().view(-1).cpu().numpy()
    lva_npy = latent_variance.detach().view(-1).cpu().numpy()

    if LOGGING:
        wandb.log({
            "mu mean": np.mean(lmu_npy),
            "mu min": np.min(lmu_npy),
            "mu max": np.max(lmu_npy),
            "var mean": np.mean(lva_npy),
            "var min": np.min(lva_npy),
            "var max": np.max(lva_npy),
Exemple #2
0
from threedee_tools.datasets import CubeLoader
from threedee_tools.renderer import Renderer
import numpy as np
import matplotlib.pyplot as plt

env = Renderer(128, 128, shape="ijcv")

gen = CubeLoader()
imga = gen.sample()

print(gen.cam)
print(gen.light)

env.base_light = -gen.light + 1
imgb = env.render(np.ones((160)), np.array([0, 0, 0]), cam_pos=gen.cam + .7)
imgb = np.array(imgb, dtype=np.float32) / 255

imgab = np.zeros((128, 128 * 2, 3), dtype=np.float32)
imgab[:, :128, :] = imga
imgab[:, 128:, :] = imgb

plt.imshow(imgab)
plt.show()