def __init__(self, opt): """ Core Atlasnet module : decoder to meshes and pointclouds. This network takes an embedding in the form of a latent vector and returns a pointcloud or a mesh Author : Thibault Groueix 01.11.2019 :param opt: """ super(Atlasnet, self).__init__() self.opt = opt self.device = opt.device # Define number of points per primitives self.nb_pts_in_primitive = opt.number_points // opt.nb_primitives self.nb_pts_in_primitive_eval = opt.number_points_eval // opt.nb_primitives if opt.remove_all_batchNorms: torch.nn.BatchNorm1d = Identity print("Replacing all batchnorms by identities.") # Initialize templates self.template = [ get_template(opt.template_type, device=opt.device) for i in range(0, opt.nb_primitives) ] # Intialize deformation networks self.decoder = nn.ModuleList( [Mapping2Dto3D(opt) for i in range(0, opt.nb_primitives)])
def get(): id = request.args.get('id') if not (id and ObjectId.is_valid(id)): abort(400) result = get_template(ObjectId(id)) if not result: return Response(status=404) obj = convert_template_from_mongo(result) response_data = json.dumps(obj) logger.debug('--response_data--' + response_data) resp = Response(response=response_data, status=201, content_type='application/json') return resp
def prepare_image_regions(id): image = get_image(id) if not image: return False kind = image.get('kind') if not kind: return False storage_id = image.get('storage_id') file = read_gridfs(storage_id) if not file: return False filename = file.filename bytes = file.read() template_id = image.get('template_id') template = get_template(template_id) if not template: return False regions = template.get('regions') if not regions: return False path = os.path.join(image_dir, kind, str(id)) if not os.path.exists(path): os.makedirs(path) src_filename = os.path.join(path, filename) logger.debug('--src_filename--' + src_filename) f = open(src_filename, 'wb') f.write(bytes) f.close() try: image_collection.update_one({'_id': id}, { '$set': { 'filename': filename, 'regions': regions, 'status': 'prepare' } }) except Exception as e: logger.debug('--prepare_image_regions--' + str(e)) return False return True
def __init__(self, opt, proto_feature, ttl_point, num_primitives): super(Proto2Dto3DCluster, self).__init__() self.opt = opt self.proto_feat = nn.Parameter( torch.from_numpy(proto_feature).float().unsqueeze(0), requires_grad=False) # Dummy var for initialization self.num_slaves = num_primitives self.num_per_slave = ttl_point // num_primitives self.template = [ get_template(opt.template_type, device=opt.device) for _ in range(num_primitives) ] print( f'New 2D -> 3D Cluster with prototype initialized, this cluster contains {self.num_slaves} slave(s)' ) self.slave_pool = nn.ModuleList( [Proto2Dto3DSlave(opt) for _ in range(num_primitives)])