Exemplo n.º 1
0
 def __init__(self, path):
     ds = np.load(path)
     self.train = ds["train"]
     self.test = ds["test"]
     self.val = ds["val"]
     print("dataset loaded:", path)
     self.og = ObjGenerator(MAX_GRID, 1.0)
     self.paths = []
     self.sample_idx = [
         0, 0, 0, 0
     ]  # corresponding to train labeled, train unlabeled, test, val
Exemplo n.º 2
0
    get_data_dir(),
    "list-v2-snek_{}-grid_{}-final.pkl".format(SNEK_LEN_2, GRID_SIZE_2))

SNEK_LEN_3 = 14
GRID_SIZE_3 = 6
OUT_PATH_3 = os.path.join(
    get_data_dir(),
    "list-v2-snek_{}-grid_{}-final.pkl".format(SNEK_LEN_3, GRID_SIZE_3))

SNEK_LEN_4 = 15
GRID_SIZE_4 = 8
OUT_PATH_4 = os.path.join(
    get_data_dir(),
    "list-v2-snek_{}-grid_{}-final.pkl".format(SNEK_LEN_4, GRID_SIZE_4))

og1 = ObjGenerator(GRID_SIZE_1, 1.0)
og2 = ObjGenerator(GRID_SIZE_2, 1.0)
og3 = ObjGenerator(GRID_SIZE_3, 1.0)
og4 = ObjGenerator(GRID_SIZE_4, 1.0)

with open(OUT_PATH_1, "rb") as output_file:
    final1 = pickle.load(output_file)

with open(OUT_PATH_2, "rb") as output_file:
    final2 = pickle.load(output_file)

with open(OUT_PATH_3, "rb") as output_file:
    final3 = pickle.load(output_file)

with open(OUT_PATH_4, "rb") as output_file:
    final4 = pickle.load(output_file)
Exemplo n.º 3
0
OUT_PATH = os.path.join(get_data_dir(), "object-{:06d}.obj")

# the size of the snake is randomly sampled
# from this interval
SNEK_LEN_MIN = 5
SNEK_LEN_MAX = 10

GRID_SIZE = 4  # the grid for the snake is N x N x N

CUBE_SIZE = 1.0  # cubes are unit-sized

### IMPORTANT
OBJECTS_TO_GENERATE = 1000

if __name__ == '__main__':
    og = ObjGenerator(GRID_SIZE, CUBE_SIZE)
    ## test with one cube
    # v, f = make_cube(CUBE_SIZE)
    # plot_cube(v, f)

    # test with one grid
    g = og.walk_snek(SNEK_LEN_MIN, SNEK_LEN_MAX)
    print(g)

    v, f = og.grid_to_cubes(g)
    og.write_obj(g, v, f, 0, OUT_PATH)
    og.plot_cube(v, f)

    # v, f = og.grid_to_cubes(np.flip(g,axis=0))
    # og.plot_cube(v, f)
    #
Exemplo n.º 4
0
# from: https://open.spotify.com/user/spotify/playlist/37i9dQZEVXcHz1uKVd65vg?si=FIkd0LBAS9en1sRXxkH57A

IN_PATH = os.path.expanduser("~/data/ig/aggregated-question.pkl")
PARAMS = [(11, 5), (13, 5), (14, 6), (15, 8)]

MAX_GRID = 8

with open(IN_PATH, "rb") as output_file:
    refs = pickle.load(output_file)
    cola = pickle.load(output_file)
    colb = pickle.load(output_file)
    colc = pickle.load(output_file)
    cold = pickle.load(output_file)
    answ = pickle.load(output_file)

og = ObjGenerator(MAX_GRID, 1.0)


def plot_obj_from_list(in_list):
    obj, idx = in_list
    grid = np.array(obj).reshape(
        (PARAMS[idx][1], PARAMS[idx][1], PARAMS[idx][1]))
    uniform_grid = embed_in_bigger(grid, MAX_GRID)
    v, f = og.grid_to_cubes(uniform_grid)
    og.plot_cube(v, f)
    # plt.show()


def embed_in_bigger(grid, bigger_size):
    if grid.shape[0] == bigger_size:
        return grid
Exemplo n.º 5
0
import pickle
import os
import matplotlib.pyplot as plt
from inversegraphics_generator.obj_generator import ObjGenerator
from inversegraphics_generator.iqtest_objs import get_data_dir

SNEK_LEN = 9
GRID_SIZE = 4
OUT_PATH = os.path.join(
    get_data_dir(), "tree-v2-snek_{}-grid_{}.pkl".format(SNEK_LEN, GRID_SIZE))
print("loading file:", OUT_PATH)

og = ObjGenerator(GRID_SIZE, 1.0)


def getLeafs(node):
    if len(node.children) == 0:
        return node
    else:
        out = [getLeafs(child) for child in node.children]
        out_flat = []
        for child in out:  # each layer removes some mess
            if type([]) == type(child):
                for child2 in child:
                    out_flat.append(child2)
            else:
                out_flat.append(child)
        return out_flat


root = pickle.load(open(OUT_PATH, "rb"))