<jupyter_start><jupyter_text>Lowest Error Best Action  LEBA - Training  Here we can compute the lowest error fixed trajectory over the training set in the vision and touch only poking setting. We set greedy_checks = 2 to approximate the best action and increase speed.<jupyter_code>import os
from pterotactyl.policies.dataset_specific import LEBA
from pterotactyl import pretrained


class Params: # define training arguments 
    def __init__(self):
        
        self.limit_data = True
        self.env_batch_size = 2
        self.num_actions = 50
        self.seed = 0
        self.budget = 5
        self.number_points = 10000
        self.loss_coeff = 9000
        self.exp_type = "LEBA_example"
        self.finger = True 
        self.num_grasps = 5 
        self.use_touch = True 
        self.use_img = True
        self.visualize = True
        self.use_latent = False
        self.use_recon = True 
        self.eval = False 
        self.greedy_checks = 2
        self.pretrained_recon = True
        self.pretrained = False
        
    

params = Params()
trainer = LEBA.Engine(params)
trainer()<jupyter_output>pybullet build time: Sep 20 2021 20:33:29
/private/home/ejsmith/.conda/envs/cluster/lib/python3.8/site-packages/pytorch3d/io/obj_io.py:529: UserWarning: No mtl file provided
  warnings.warn("No mtl file provided")
100%|█████████████████████████████████████████████████████████████████████████████| 400/400 [00:00<00:00, 2933.91it/s]<jupyter_text>LEBA - Evaluation  We now evaluate the trained moddel. Because we run with the visualize paramater as true we can view predicted objects.<jupyter_code>import os

from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw 
from glob import glob 

from pterotactyl import objects
FONT_LOCATION = os.path.dirname(objects.__file__) + '/OpenSans-Bold.ttf'


params.eval = True 
params.visualize = True
tester = LEBA.Engine(params)
tester()


histogram = Image.open('results/LEBA_example/histogram.png')
display(histogram)
print('\n\n')
actions = Image.open('results/LEBA_example/sphere_projection.png')
print('   Projected Actions')
display(actions)



img_locations = glob('results/LEBA_example/*/')
for location in img_locations[:5]:
    mesh = Image.open(location + "mesh.png")
    points = Image.open(location + "points.png")
    gt = Image.open(location + "ground_truth.png")
    
    
    combo = Image.new('RGB', (512*3, 512))
    x_offset = 0
    
    for im, st in [[gt, 'Ground Truth'], [mesh, 'Mesh'], [points, 'Point Cloud']]:
        
        draw = ImageDraw.Draw(im)
        font = ImageFont.truetype(FONT_LOCATION, 35)
        W,H = im.size
        w,h = font.getsize(st)
        draw.text(((W-w)/2, 0),st,(0, 0, 0), font = font)
        combo.paste(im, (x_offset, 0))
        x_offset += im.size[0]
        
    display(combo)<jupyter_output>100%|█████████████████████████████████████████████████████████████████████████████| 400/400 [00:00<00:00, 4489.13it/s]<jupyter_text>LEBA - Pretrained  We now evaliate the pretrained models in the same setting:<jupyter_code>import os

from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw 
from glob import glob 

from pterotactyl import objects
from pterotactyl.policies.dataset_specific import LEBA

FONT_LOCATION = os.path.dirname(objects.__file__) + '/OpenSans-Bold.ttf'



class Params: # define training arguments 
    def __init__(self):
        
        self.limit_data = True
        self.env_batch_size = 2
        self.num_actions = 50
        self.seed = 0 
        self.budget = 5
        self.number_points = 10000
        self.loss_coeff = 9000
        self.exp_type = "LEBA_pre"
        self.finger = True 
        self.num_grasps = 5 
        self.use_touch = True 
        self.use_img = True
        self.visualize = True
        self.use_latent = False
        self.use_recon = True 
        self.eval = True 
        self.greedy_checks = 50
        self.pretrained_recon = True
        self.pretrained = True 
        
    

params = Params()
eval = LEBA.Engine(params)
eval()


histogram = Image.open('results/LEBA_pre/histogram.png')
display(histogram)
print('\n\n')
actions = Image.open('results/LEBA_pre/sphere_projection.png')
print('   Projected Actions')
display(actions)



img_locations = glob('results/LEBA_pre/*/')
for location in img_locations[:5]:
    mesh = Image.open(location + "mesh.png")
    points = Image.open(location + "points.png")
    gt = Image.open(location + "ground_truth.png")
    
    
    combo = Image.new('RGB', (512*3, 512))
    x_offset = 0
    
    for im, st in [[gt, 'Ground Truth'], [mesh, 'Mesh'], [points, 'Point Cloud']]:
        
        draw = ImageDraw.Draw(im)
        font = ImageFont.truetype(FONT_LOCATION, 35)
        W,H = im.size
        w,h = font.getsize(st)
        draw.text(((W-w)/2, 0),st,(0, 0, 0), font = font)
        combo.paste(im, (x_offset, 0))
        x_offset += im.size[0]
        
    display(combo)<jupyter_output>100%|█████████████████████████████████████████████████████████████████████████████| 400/400 [00:00<00:00, 3610.05it/s]
{'fraction_non_alphanumeric': 0.15162241887905606, 'fraction_numerical': 0.03087512291052114, 'mean_word_length': 2.9827721221613155, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '264863', 'license': 'MIT', 'n_tokens_mistral': 2021, 'n_tokens_neox': 1737, 'n_words': 393, 'path': 'notebook/Policies/dataset_specific/LEBA.ipynb', 'repo_name': 'maurock/Active-3D-Vision-and-Touch', 'size': '5085'}