id
int64
0
190k
prompt
stringlengths
21
13.4M
docstring
stringlengths
1
12k
12,438
import os import warnings from typing import Optional, Any, Dict import ee import ipyleaflet import ipywidgets as widgets from box import Box from bqplot import pyplot as plt from IPython.display import display from .basemaps import get_xyz_dict, xyz_to_leaflet from .common import * from .conversion import * from .ee_t...
Create linked maps of Earth Engine data layers. Args: rows (int, optional): The number of rows of maps to create. Defaults to 2. cols (int, optional): The number of columns of maps to create. Defaults to 2. height (str, optional): The height of each map in pixels. Defaults to "400px". ee_objects (list, optional): The l...
12,439
import os import warnings from typing import Optional, Any, Dict import ee import ipyleaflet import ipywidgets as widgets from box import Box from bqplot import pyplot as plt from IPython.display import display from .basemaps import get_xyz_dict, xyz_to_leaflet from .common import * from .conversion import * from .ee_t...
Creates a time series inspector. Args: layers_dict (dict, optional): A dictionary of layers to be shown on the map. Defaults to None. left_name (str, optional): A name for the left layer. Defaults to None. right_name (str, optional): A name for the right layer. Defaults to None. width (str, optional): Width of the drop...
12,440
import os import warnings from typing import Optional, Any, Dict import ee import ipyleaflet import ipywidgets as widgets from box import Box from bqplot import pyplot as plt from IPython.display import display from .basemaps import get_xyz_dict, xyz_to_leaflet from .common import * from .conversion import * from .ee_t...
Gets a basemap tile layer by name. Args: name (str): The name of the basemap. Returns: ipylealfet.TileLayer | ipyleaflet.WMSLayer: The basemap layer.
12,441
import pandas as pd import plotly.express as px from .common import * def github_raw_url(url): """Get the raw URL for a GitHub file. Args: url (str): The GitHub URL. Returns: str: The raw URL. """ if isinstance(url, str) and url.startswith("https://github.com/") and "blob" in url: ...
Create a bar chart with plotly.express, Args: data: DataFrame | array-like | dict | str (local file path or HTTP URL) This argument needs to be passed for column names (and not keyword names) to be used. Array-like and dict are transformed internally to a pandas DataFrame. Optional: if missing, a DataFrame gets constru...
12,442
import pandas as pd import plotly.express as px from .common import * def github_raw_url(url): """Get the raw URL for a GitHub file. Args: url (str): The GitHub URL. Returns: str: The raw URL. """ if isinstance(url, str) and url.startswith("https://github.com/") and "blob" in url: ...
Create a line chart with plotly.express, Args: data: DataFrame | array-like | dict | str (local file path or HTTP URL) This argument needs to be passed for column names (and not keyword names) to be used. Array-like and dict are transformed internally to a pandas DataFrame. Optional: if missing, a DataFrame gets constr...
12,443
import pandas as pd import plotly.express as px from .common import * def github_raw_url(url): """Get the raw URL for a GitHub file. Args: url (str): The GitHub URL. Returns: str: The raw URL. """ if isinstance(url, str) and url.startswith("https://github.com/") and "blob" in url: ...
Create a line chart with plotly.express, Args: data: DataFrame | array-like | dict | str (local file path or HTTP URL) This argument needs to be passed for column names (and not keyword names) to be used. Array-like and dict are transformed internally to a pandas DataFrame. Optional: if missing, a DataFrame gets constr...
12,444
import pandas as pd import plotly.express as px from .common import * def github_raw_url(url): """Get the raw URL for a GitHub file. Args: url (str): The GitHub URL. Returns: str: The raw URL. """ if isinstance(url, str) and url.startswith("https://github.com/") and "blob" in url: ...
Create a plotly pie chart. Args: data: DataFrame or array-like or dict This argument needs to be passed for column names (and not keyword names) to be used. Array-like and dict are transformed internally to a pandas DataFrame. Optional: if missing, a DataFrame gets constructed under the hood using the other arguments. ...
12,445
import matplotlib as mpl import matplotlib.pyplot as plt import numpy as np from box import Box The provided code snippet includes necessary dependencies for implementing the `get_colorbar` function. Write a Python function `def get_colorbar( colors, vmin=0, vmax=1, width=6.0, height=0.4, orien...
Creates a colorbar based on custom colors. Args: colors (list): A list of hex colors. vmin (float, optional): The minimum value range. Defaults to 0. vmax (float, optional): The maximum value range. Defaults to 1.0. width (float, optional): The width of the colormap. Defaults to 6.0. height (float, optional): The heigh...
12,446
import matplotlib as mpl import matplotlib.pyplot as plt import numpy as np from box import Box The provided code snippet includes necessary dependencies for implementing the `plot_colormap` function. Write a Python function `def plot_colormap( cmap, width=8.0, height=0.4, orientation="horizontal", ...
Plot a matplotlib colormap. Args: cmap (str): The name of the colormap. width (float, optional): The width of the colormap. Defaults to 8.0. height (float, optional): The height of the colormap. Defaults to 0.4. orientation (str, optional): The orientation of the colormap. Defaults to "horizontal". vmin (float, optiona...
12,447
import matplotlib as mpl import matplotlib.pyplot as plt import numpy as np from box import Box def list_colormaps(add_extra=False, lowercase=False): """List all available colormaps. See a complete lost of colormaps at https://matplotlib.org/stable/tutorials/colors/colormaps.html. Returns: list: The lis...
Plot all available colormaps. Args: width (float, optional): Width of the colormap. Defaults to 8.0. height (float, optional): Height of the colormap. Defaults to 0.4.
12,448
import ee import pandas as pd import numpy as np from bqplot import Tooltip from bqplot import pyplot as plt from .common import ee_to_df, zonal_stats from typing import Union class Feature_ByFeature(BarChart): """A object to define variables and get_data method.""" def __init__( self, features, xProper...
Generates a Chart from a set of features. Plots the value of one or more properties for each feature. Reference: https://developers.google.com/earth-engine/guides/charts_feature#uichartfeaturebyfeature Args: features (ee.FeatureCollection): The feature collection to generate a chart from. xProperty (str): Features labe...
12,449
import ee import pandas as pd import numpy as np from bqplot import Tooltip from bqplot import pyplot as plt from .common import ee_to_df, zonal_stats from typing import Union class Feature_ByProperty(BarChart): """A object to define variables and get_data method.""" def __init__( self, features, xPrope...
Generates a Chart from a set of features. Plots property values of one or more features. Reference: https://developers.google.com/earth-engine/guides/charts_feature#uichartfeaturebyproperty Args: features (ee.FeatureCollection): The features to include in the chart. xProperties (list | dict): One of (1) a list of prope...
12,450
import ee import pandas as pd import numpy as np from bqplot import Tooltip from bqplot import pyplot as plt from .common import ee_to_df, zonal_stats from typing import Union class Feature_Groups(BarChart): """A object to define variables and get_data method.""" def __init__( self, features, ...
Generates a Chart from a set of features. Plots the value of one property for each feature. Reference: https://developers.google.com/earth-engine/guides/charts_feature#uichartfeaturegroups Args: features (ee.FeatureCollection): The feature collection to make a chart from. xProperty (str): Features labeled by xProperty....
12,451
import ee import pandas as pd import numpy as np from bqplot import Tooltip from bqplot import pyplot as plt from .common import ee_to_df, zonal_stats from typing import Union The provided code snippet includes necessary dependencies for implementing the `feature_histogram` function. Write a Python function `def featu...
Generates a Chart from a set of features. Computes and plots a histogram of the given property. - X-axis = Histogram buckets (of property value). - Y-axis = Frequency Reference: https://developers.google.com/earth-engine/guides/charts_feature#uichartfeaturehistogram Args: features (ee.FeatureCollection): The features t...
12,452
import ee import pandas as pd import numpy as np from bqplot import Tooltip from bqplot import pyplot as plt from .common import ee_to_df, zonal_stats from typing import Union def image_byClass( image, classBand, region, reducer, scale, classLabels, xLabels, **kwargs ): # TODO pass
null
12,453
import ee import pandas as pd import numpy as np from bqplot import Tooltip from bqplot import pyplot as plt from .common import ee_to_df, zonal_stats from typing import Union def image_byRegion(image, regions, reducer, scale, xProperty, **kwargs): # TODO pass
null
12,454
import ee import pandas as pd import numpy as np from bqplot import Tooltip from bqplot import pyplot as plt from .common import ee_to_df, zonal_stats from typing import Union def image_doySeries( imageCollection, region, regionReducer, scale, yearReducer, startDay, endDay, **kwargs, ):...
null
12,455
import ee import pandas as pd import numpy as np from bqplot import Tooltip from bqplot import pyplot as plt from .common import ee_to_df, zonal_stats from typing import Union def image_doySeriesByRegion( imageCollection, bandName, regions, regionReducer, scale, yearReducer, seriesProperty,...
null
12,456
import ee import pandas as pd import numpy as np from bqplot import Tooltip from bqplot import pyplot as plt from .common import ee_to_df, zonal_stats from typing import Union def image_doySeriesByYear( imageCollection, bandName, region, regionReducer, scale, sameDayReducer, startDay, e...
null
12,457
import ee import pandas as pd import numpy as np from bqplot import Tooltip from bqplot import pyplot as plt from .common import ee_to_df, zonal_stats from typing import Union def image_histogram( image, region, scale, maxBuckets, minBucketWidth, maxRaw, maxPixels, **kwargs ): # TODO pass
null
12,458
import ee import pandas as pd import numpy as np from bqplot import Tooltip from bqplot import pyplot as plt from .common import ee_to_df, zonal_stats from typing import Union def image_regions(image, regions, reducer, scale, seriesProperty, xLabels, **kwargs): # TODO pass
null
12,459
import ee import pandas as pd import numpy as np from bqplot import Tooltip from bqplot import pyplot as plt from .common import ee_to_df, zonal_stats from typing import Union def image_series(imageCollection, region, reducer, scale, xProperty, **kwargs): # TODO pass
null
12,460
import ee import pandas as pd import numpy as np from bqplot import Tooltip from bqplot import pyplot as plt from .common import ee_to_df, zonal_stats from typing import Union def image_seriesByRegion( imageCollection, regions, reducer, band, scale, xProperty, seriesProperty, **kwargs ): # TODO pass
null
12,461
import os from dataclasses import dataclass import ee import ipyevents import ipyleaflet import ipywidgets as widgets from ipyfilechooser import FileChooser from IPython.core.display import display from typing import Any, Callable, Optional from .common import * from .timelapse import * from . import map_widgets The p...
Create a toolbar widget. Args: m (geemap.Map, optional): The geemap.Map instance. Defaults to None. opened (bool, optional): Whether to open the toolbar. Defaults to True.
12,462
import os from dataclasses import dataclass import ee import ipyevents import ipyleaflet import ipywidgets as widgets from ipyfilechooser import FileChooser from IPython.core.display import display from typing import Any, Callable, Optional from .common import * from .timelapse import * from . import map_widgets The p...
Create a toolbar widget. Args: m (geemap.Map, optional): The geemap.Map instance. Defaults to None. opened (bool, optional): Whether to open the toolbar. Defaults to True. show_close_button (bool, optional): Whether to show the close button. Defaults to True.
12,463
import os from dataclasses import dataclass import ee import ipyevents import ipyleaflet import ipywidgets as widgets from ipyfilechooser import FileChooser from IPython.core.display import display from typing import Any, Callable, Optional from .common import * from .timelapse import * from . import map_widgets def sp...
null
12,464
import os from dataclasses import dataclass import ee import ipyevents import ipyleaflet import ipywidgets as widgets from ipyfilechooser import FileChooser from IPython.core.display import display from typing import Any, Callable, Optional from .common import * from .timelapse import * from . import map_widgets def _...
null
12,465
import os from dataclasses import dataclass import ee import ipyevents import ipyleaflet import ipywidgets as widgets from ipyfilechooser import FileChooser from IPython.core.display import display from typing import Any, Callable, Optional from .common import * from .timelapse import * from . import map_widgets The p...
Wraps a toolbar item callback to clean up the widget when unselected.
12,466
import os from dataclasses import dataclass import ee import ipyevents import ipyleaflet import ipywidgets as widgets from ipyfilechooser import FileChooser from IPython.core.display import display from typing import Any, Callable, Optional from .common import * from .timelapse import * from . import map_widgets def _...
null
12,467
import os from dataclasses import dataclass import ee import ipyevents import ipyleaflet import ipywidgets as widgets from ipyfilechooser import FileChooser from IPython.core.display import display from typing import Any, Callable, Optional from .common import * from .timelapse import * from . import map_widgets def ee...
null
12,468
import os from dataclasses import dataclass import ee import ipyevents import ipyleaflet import ipywidgets as widgets from ipyfilechooser import FileChooser from IPython.core.display import display from typing import Any, Callable, Optional from .common import * from .timelapse import * from . import map_widgets def ti...
null
12,469
import os from dataclasses import dataclass import ee import ipyevents import ipyleaflet import ipywidgets as widgets from ipyfilechooser import FileChooser from IPython.core.display import display from typing import Any, Callable, Optional from .common import * from .timelapse import * from . import map_widgets def co...
null
12,470
import os from dataclasses import dataclass import ee import ipyevents import ipyleaflet import ipywidgets as widgets from ipyfilechooser import FileChooser from IPython.core.display import display from typing import Any, Callable, Optional from .common import * from .timelapse import * from . import map_widgets def _...
null
12,471
import os from dataclasses import dataclass import ee import ipyevents import ipyleaflet import ipywidgets as widgets from ipyfilechooser import FileChooser from IPython.core.display import display from typing import Any, Callable, Optional from .common import * from .timelapse import * from . import map_widgets def op...
null
12,472
import os from dataclasses import dataclass import ee import ipyevents import ipyleaflet import ipywidgets as widgets from ipyfilechooser import FileChooser from IPython.core.display import display from typing import Any, Callable, Optional from .common import * from .timelapse import * from . import map_widgets def bu...
null
12,473
import os from dataclasses import dataclass import ee import ipyevents import ipyleaflet import ipywidgets as widgets from ipyfilechooser import FileChooser from IPython.core.display import display from typing import Any, Callable, Optional from .common import * from .timelapse import * from . import map_widgets def ge...
null
12,474
import os from dataclasses import dataclass import ee import ipyevents import ipyleaflet import ipywidgets as widgets from ipyfilechooser import FileChooser from IPython.core.display import display from typing import Any, Callable, Optional from .common import * from .timelapse import * from . import map_widgets def ti...
null
12,475
import os from dataclasses import dataclass import ee import ipyevents import ipyleaflet import ipywidgets as widgets from ipyfilechooser import FileChooser from IPython.core.display import display from typing import Any, Callable, Optional from .common import * from .timelapse import * from . import map_widgets def co...
null
12,476
import os from dataclasses import dataclass import ee import ipyevents import ipyleaflet import ipywidgets as widgets from ipyfilechooser import FileChooser from IPython.core.display import display from typing import Any, Callable, Optional from .common import * from .timelapse import * from . import map_widgets def pl...
null
12,477
import os from dataclasses import dataclass import ee import ipyevents import ipyleaflet import ipywidgets as widgets from ipyfilechooser import FileChooser from IPython.core.display import display from typing import Any, Callable, Optional from .common import * from .timelapse import * from . import map_widgets def sa...
null
12,478
import os from dataclasses import dataclass import ee import ipyevents import ipyleaflet import ipywidgets as widgets from ipyfilechooser import FileChooser from IPython.core.display import display from typing import Any, Callable, Optional from .common import * from .timelapse import * from . import map_widgets def in...
null
12,479
import os from dataclasses import dataclass import ee import ipyevents import ipyleaflet import ipywidgets as widgets from ipyfilechooser import FileChooser from IPython.core.display import display from typing import Any, Callable, Optional from .common import * from .timelapse import * from . import map_widgets def pl...
Creates the main toolbar and adds it to the map. Args: m (plotlymap.Map): The plotly Map object.
12,480
from playwright.sync_api import sync_playwright import time from sys import argv, exit, platform import openai import os def print_help(): print( "(g) to visit url\n(u) scroll up\n(d) scroll down\n(c) to click\n(t) to type\n" + "(h) to view commands again\n(r/enter) to run suggested command\n(o) change objecti...
null
12,481
from playwright.sync_api import sync_playwright import time from sys import argv, exit, platform import openai import os prompt_template = """ You are an agent controlling a browser. You are given: (1) an objective that you are trying to achieve (2) the URL of your current web page (3) a simplified text description ...
null
12,482
from playwright.sync_api import sync_playwright import time from sys import argv, exit, platform import openai import os def run_cmd(cmd): cmd = cmd.split("\n")[0] if cmd.startswith("SCROLL UP"): _crawler.scroll("up") elif cmd.startswith("SCROLL DOWN"): _crawler.scroll("down") elif cmd.startswith("CLICK...
null
12,483
import os import time import h5py import math import numpy as np The provided code snippet includes necessary dependencies for implementing the `write_hdf5` function. Write a Python function `def write_hdf5(file, tensor, key = 'tensor')` to solve the following problem: Write a simple tensor, i.e. numpy array ,to HDF5....
Write a simple tensor, i.e. numpy array ,to HDF5. :param file: path to file to write :type file: str :param tensor: tensor to write :type tensor: numpy.ndarray :param key: key to use for tensor :type key: str
12,484
import os import time import h5py import math import numpy as np The provided code snippet includes necessary dependencies for implementing the `read_hdf5` function. Write a Python function `def read_hdf5(file, key = 'tensor')` to solve the following problem: Read a tensor, i.e. numpy array, from HDF5. :param file: pa...
Read a tensor, i.e. numpy array, from HDF5. :param file: path to file to read :type file: str :param key: key to read :type key: str :return: tensor :rtype: numpy.ndarray
12,485
import os import time import h5py import math import numpy as np The provided code snippet includes necessary dependencies for implementing the `write_off` function. Write a Python function `def write_off(file, vertices, faces)` to solve the following problem: Writes the given vertices and faces to OFF. :param vertice...
Writes the given vertices and faces to OFF. :param vertices: vertices as tuples of (x, y, z) coordinates :type vertices: [(float)] :param faces: faces as tuples of (num_vertices, vertex_id_1, vertex_id_2, ...) :type faces: [(int)]
12,486
import os import time import h5py import math import numpy as np The provided code snippet includes necessary dependencies for implementing the `read_off` function. Write a Python function `def read_off(file)` to solve the following problem: Reads vertices and faces from an off file. :param file: path to file to read ...
Reads vertices and faces from an off file. :param file: path to file to read :type file: str :return: vertices and faces as lists of tuples :rtype: [(float)], [(int)]
12,487
import os import time import h5py import math import numpy as np The provided code snippet includes necessary dependencies for implementing the `write_obj` function. Write a Python function `def write_obj(file, vertices, faces)` to solve the following problem: Writes the given vertices and faces to OBJ. :param vertice...
Writes the given vertices and faces to OBJ. :param vertices: vertices as tuples of (x, y, z) coordinates :type vertices: [(float)] :param faces: faces as tuples of (num_vertices, vertex_id_1, vertex_id_2, ...) :type faces: [(int)]
12,488
import os import time import h5py import math import numpy as np The provided code snippet includes necessary dependencies for implementing the `read_obj` function. Write a Python function `def read_obj(file)` to solve the following problem: Reads vertices and faces from an obj file. :param file: path to file to read ...
Reads vertices and faces from an obj file. :param file: path to file to read :type file: str :return: vertices and faces as lists of tuples :rtype: [(float)], [(int)]
12,489
import os import time import h5py import math import numpy as np The provided code snippet includes necessary dependencies for implementing the `makedir` function. Write a Python function `def makedir(dir)` to solve the following problem: Creates directory if it does not exist. :param dir: directory path :type dir: st...
Creates directory if it does not exist. :param dir: directory path :type dir: str
12,490
import numpy as np The provided code snippet includes necessary dependencies for implementing the `export_obj` function. Write a Python function `def export_obj(vertices, triangles, filename)` to solve the following problem: Exports a mesh in the (.obj) format. Here is the function: def export_obj(vertices, triangle...
Exports a mesh in the (.obj) format.
12,491
import numpy as np The provided code snippet includes necessary dependencies for implementing the `export_off` function. Write a Python function `def export_off(vertices, triangles, filename)` to solve the following problem: Exports a mesh in the (.off) format. Here is the function: def export_off(vertices, triangle...
Exports a mesh in the (.off) format.
12,492
import numpy as np The provided code snippet includes necessary dependencies for implementing the `export_mesh` function. Write a Python function `def export_mesh(vertices, triangles, filename, mesh_name="mcubes_mesh")` to solve the following problem: Exports a mesh in the COLLADA (.dae) format. Needs PyCollada (https...
Exports a mesh in the COLLADA (.dae) format. Needs PyCollada (https://github.com/pycollada/pycollada).
12,493
import os from im2mesh.encoder import encoder_dict from im2mesh.r2n2 import models, training, generation from im2mesh import data encoder_dict = { 'simple_conv': conv.ConvEncoder, 'resnet18': conv.Resnet18, 'resnet34': conv.Resnet34, 'resnet50': conv.Resnet50, 'resnet101': conv.Resnet101, 'r2n2...
Return the model. Args: cfg (dict): loaded yaml config device (device): pytorch device
12,494
import os from im2mesh.encoder import encoder_dict from im2mesh.r2n2 import models, training, generation from im2mesh import data The provided code snippet includes necessary dependencies for implementing the `get_trainer` function. Write a Python function `def get_trainer(model, optimizer, cfg, device, **kwargs)` to ...
Returns the trainer object. Args: model (nn.Module): R2N2 model optimizer (optimizer): pytorch optimizer cfg (dict): loaded yaml config device (device): pytorch device
12,495
import os from im2mesh.encoder import encoder_dict from im2mesh.r2n2 import models, training, generation from im2mesh import data The provided code snippet includes necessary dependencies for implementing the `get_generator` function. Write a Python function `def get_generator(model, cfg, device, **kwargs)` to solve t...
Returns the generator object. Args: model (nn.Module): R2N2 model cfg (dict): loaded yaml config device (device): pytorch device
12,496
import os from im2mesh.encoder import encoder_dict from im2mesh.r2n2 import models, training, generation from im2mesh import data The provided code snippet includes necessary dependencies for implementing the `get_data_fields` function. Write a Python function `def get_data_fields(split, cfg, **kwargs)` to solve the f...
Returns the data fields. Args: split (str): the split which should be used cfg (dict): loaded yaml config
12,497
import os import logging from torch.utils import data import numpy as np import yaml The provided code snippet includes necessary dependencies for implementing the `collate_remove_none` function. Write a Python function `def collate_remove_none(batch)` to solve the following problem: Collater that puts each data field...
Collater that puts each data field into a tensor with outer dimension batch size. Args: batch: batch
12,498
import os import logging from torch.utils import data import numpy as np import yaml The provided code snippet includes necessary dependencies for implementing the `worker_init_fn` function. Write a Python function `def worker_init_fn(worker_id)` to solve the following problem: Worker init function to ensure true rand...
Worker init function to ensure true randomness.
12,499
import os import urllib import torch from torch.utils import model_zoo def is_url(url): scheme = urllib.parse.urlparse(url).scheme return scheme in ('http', 'https')
null
12,500
import yaml from torchvision import transforms from im2mesh import data from im2mesh import onet, r2n2, psgn, pix2mesh, dmc from im2mesh import preprocess def update_recursive(dict1, dict2): ''' Update two config dictionaries recursively. Args: dict1 (dict): first dictionary to be updated dict2 ...
Loads config file. Args: path (str): path to config file default_path (bool): whether to use default path
12,501
import yaml from torchvision import transforms from im2mesh import data from im2mesh import onet, r2n2, psgn, pix2mesh, dmc from im2mesh import preprocess method_dict = { 'onet': onet, 'r2n2': r2n2, 'psgn': psgn, 'pix2mesh': pix2mesh, 'dmc': dmc, } The provided code snippet includes necessary depen...
Returns the model instance. Args: cfg (dict): config dictionary device (device): pytorch device dataset (dataset): dataset
12,502
import yaml from torchvision import transforms from im2mesh import data from im2mesh import onet, r2n2, psgn, pix2mesh, dmc from im2mesh import preprocess method_dict = { 'onet': onet, 'r2n2': r2n2, 'psgn': psgn, 'pix2mesh': pix2mesh, 'dmc': dmc, } The provided code snippet includes necessary depen...
Returns a trainer instance. Args: model (nn.Module): the model which is used optimizer (optimizer): pytorch optimizer cfg (dict): config dictionary device (device): pytorch device
12,503
import yaml from torchvision import transforms from im2mesh import data from im2mesh import onet, r2n2, psgn, pix2mesh, dmc from im2mesh import preprocess method_dict = { 'onet': onet, 'r2n2': r2n2, 'psgn': psgn, 'pix2mesh': pix2mesh, 'dmc': dmc, } The provided code snippet includes necessary depen...
Returns a generator instance. Args: model (nn.Module): the model which is used cfg (dict): config dictionary device (device): pytorch device
12,504
import yaml from torchvision import transforms from im2mesh import data from im2mesh import onet, r2n2, psgn, pix2mesh, dmc from im2mesh import preprocess method_dict = { 'onet': onet, 'r2n2': r2n2, 'psgn': psgn, 'pix2mesh': pix2mesh, 'dmc': dmc, } def get_inputs_field(mode, cfg): ''' Returns th...
Returns the dataset. Args: model (nn.Module): the model which is used cfg (dict): config dictionary return_idx (bool): whether to include an ID field
12,505
import os from im2mesh.dmc import models, training, generation from im2mesh import data def get_model(cfg, device=None, **kwargs): encoder = cfg['model']['encoder'] decoder = cfg['model']['decoder'] c_dim = cfg['model']['c_dim'] encoder_kwargs = cfg['model']['encoder_kwargs'] decoder_kwargs = cfg['...
null
12,506
import os from im2mesh.dmc import models, training, generation from im2mesh import data def get_trainer(model, optimizer, cfg, device, **kwargs): input_type = cfg['data']['input_type'] out_dir = cfg['training']['out_dir'] vis_dir = os.path.join(out_dir, 'vis') num_voxels = cfg['model']['num_voxels'] ...
null
12,507
import os from im2mesh.dmc import models, training, generation from im2mesh import data def get_generator(model, cfg, device, **kwargs): num_voxels = cfg['model']['num_voxels'] generator = generation.Generator3D( model, device=device, num_voxels=num_voxels ) return generator
null
12,508
import os from im2mesh.dmc import models, training, generation from im2mesh import data def get_data_fields(split, cfg, **kwargs): with_transforms = cfg['data']['with_transforms'] # TODO: put this into config pointcloud_n = 3000 pointcloud_transform = data.SubsamplePointcloud(pointcloud_n) fields ...
null
12,509
import numpy as np The provided code snippet includes necessary dependencies for implementing the `get_accept_topology` function. Write a Python function `def get_accept_topology(num_tri=3)` to solve the following problem: Get the list of the singly connected topologies up to a specified number of triangles Here is t...
Get the list of the singly connected topologies up to a specified number of triangles
12,510
import numpy as np def check_connected(triangles, v1, v2): # number of all triangles T = len(triangles) compatible_mat = np.zeros((T, T)) match = {} for ind,x in enumerate(v1): match[x] = v2[ind] for i in range(T): for j in range(T): t1 = triangles[i] t2...
return connected pairs in x, y, z directions
12,511
import numpy as np The provided code snippet includes necessary dependencies for implementing the `get_occupancy_table` function. Write a Python function `def get_occupancy_table()` to solve the following problem: Return binary occupancy status of 8 vertices for all 256 topology types Here is the function: def get_o...
Return binary occupancy status of 8 vertices for all 256 topology types
12,512
import numpy as np import torch from torch.autograd import Variable import time one = Variable(torch.ones(1).type(torch.FloatTensor), requires_grad=True) eps = 1e-8 def pointTriangleDistance(TRI, P): # function [dist,PP0] = pointTriangleDistance(TRI,P) # calculate distance between a point and a triangle in 3D ...
null
12,513
import numpy as np import torch from torch.autograd import Variable from im2mesh.dmc.utils.pointTriangleDistance import pointTriangleDistance, pointTriangleDistanceFast from im2mesh.dmc.ops.table import get_triangle_table, get_unique_triangles, vertices_on_location topologys = get_triangle_table() def dis_to_mesh(pts, ...
Return the distances from a point set to all acceptable topology types in a single cell Input: pts, (Nx3) a set of points pts_index, (Nx1) indicating if a point is in the cell or not vertices, (3x12) the 12 vertices on each edge of the cell x_, the offset of the cell in x direction y_, the offset of the cell in y direc...
12,514
import numpy as np import torch from torch.autograd import Variable from im2mesh.dmc.utils.pointTriangleDistance import pointTriangleDistance, pointTriangleDistanceFast from im2mesh.dmc.ops.table import get_triangle_table, get_unique_triangles, vertices_on_location The provided code snippet includes necessary dependen...
get the point indices incide of a given cell (pyTorch) Input: pts, a set of points in pytorch format cell, a list of 6 numbers {x1, y1, z1, x2, y2, z2} Output: inds, a list of indices for points inside the cell
12,515
import numpy as np import torch from torch.autograd import Variable from im2mesh.dmc.utils.pointTriangleDistance import pointTriangleDistance, pointTriangleDistanceFast from im2mesh.dmc.ops.table import get_triangle_table, get_unique_triangles, vertices_on_location The provided code snippet includes necessary dependen...
get the point indices incide of a given cell (numpy) Input: pts, a set of points in numpy format cell, a list of 6 numbers {x1, y1, z1, x2, y2, z2} Output: inds, a list of indices for points inside the cell
12,516
import numpy as np import torch from torch.autograd import Variable from im2mesh.dmc.utils.pointTriangleDistance import pointTriangleDistance, pointTriangleDistanceFast from im2mesh.dmc.ops.table import get_triangle_table, get_unique_triangles, vertices_on_location def offset_to_vertices(offset, x, y, z): """ get 1...
get normal vector of all triangles
12,517
import numpy as np import torch from torch.autograd import Variable from im2mesh.dmc.utils.pointTriangleDistance import pointTriangleDistance, pointTriangleDistanceFast from im2mesh.dmc.ops.table import get_triangle_table, get_unique_triangles, vertices_on_location The provided code snippet includes necessary dependen...
get the gaussian kernel https://stackoverflow.com/questions/29731726/how-to-calculate-a-gaussian-kernel-matrix-efficiently-in-numpy
12,518
import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import torch import os import numpy as np from utils.util import write_to_off, unique_rows from _ext import eval_util def write_to_off(vertices, faces, filename): """write the given vertices and faces to off""" f = open(filename, 'w') ...
save the estimated mesh with maximum likelihood as image
12,519
import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import torch import os import numpy as np from utils.util import write_to_off, unique_rows from _ext import eval_util The provided code snippet includes necessary dependencies for implementing the `save_occupancy_fig` function. Write a Python func...
save the estimated occupancy as image
12,520
import argparse import os from ConfigParser import SafeConfigParser from im2mesh.dmc.ops.table import get_triangle_table def str2bool(v): if v.lower() in ('yes', 'true', 't', 'y', '1'): return True elif v.lower() in ('no', 'false', 'f', 'n', '0'): return False else: raise argparse.Ar...
null
12,521
import torch import numpy as np from im2mesh.dmc.ops.cpp_modules import pred2mesh The provided code snippet includes necessary dependencies for implementing the `unique_rows` function. Write a Python function `def unique_rows(a)` to solve the following problem: Return the matrix with unique rows Here is the function:...
Return the matrix with unique rows
12,522
import torch import numpy as np from im2mesh.dmc.ops.cpp_modules import pred2mesh The provided code snippet includes necessary dependencies for implementing the `pred_to_mesh_max` function. Write a Python function `def pred_to_mesh_max(offset, topology)` to solve the following problem: Converts the predicted offset va...
Converts the predicted offset variable and topology to a mesh by choosing the most likely topology Input ---------- arg1 : tensor offset variables [3 x W+1 x H+1 x D+1] arg2 : tensor topology probabilities [W*H*D x T] Returns ------- trimesh format mesh
12,523
import torch import torch.distributions as dist from torch import nn import os from im2mesh.encoder import encoder_dict from im2mesh.onet import models, training, generation from im2mesh import data from im2mesh import config def get_prior_z(cfg, device, **kwargs): ''' Returns prior distribution for latent code z. ...
Return the Occupancy Network model. Args: cfg (dict): imported yaml config device (device): pytorch device dataset (dataset): dataset
12,524
import torch import torch.distributions as dist from torch import nn import os from im2mesh.encoder import encoder_dict from im2mesh.onet import models, training, generation from im2mesh import data from im2mesh import config The provided code snippet includes necessary dependencies for implementing the `get_trainer` ...
Returns the trainer object. Args: model (nn.Module): the Occupancy Network model optimizer (optimizer): pytorch optimizer object cfg (dict): imported yaml config device (device): pytorch device
12,525
import torch import torch.distributions as dist from torch import nn import os from im2mesh.encoder import encoder_dict from im2mesh.onet import models, training, generation from im2mesh import data from im2mesh import config The provided code snippet includes necessary dependencies for implementing the `get_generator...
Returns the generator object. Args: model (nn.Module): Occupancy Network model cfg (dict): imported yaml config device (device): pytorch device
12,526
import torch import torch.distributions as dist from torch import nn import os from im2mesh.encoder import encoder_dict from im2mesh.onet import models, training, generation from im2mesh import data from im2mesh import config The provided code snippet includes necessary dependencies for implementing the `get_data_fiel...
Returns the data fields. Args: mode (str): the mode which is used cfg (dict): imported yaml config
12,527
import torch import torch.nn as nn import torch.nn.functional as F def maxpool(x, dim=-1, keepdim=False): out, _ = x.max(dim=dim, keepdim=keepdim) return out
null
12,528
import torch import torch.nn as nn from im2mesh.layers import ResnetBlockFC def maxpool(x, dim=-1, keepdim=False): out, _ = x.max(dim=dim, keepdim=keepdim) return out
null
12,529
import os from im2mesh.encoder import encoder_dict from im2mesh.pix2mesh import models, training, generation from im2mesh import data import pickle import numpy as np encoder_dict = { 'simple_conv': conv.ConvEncoder, 'resnet18': conv.Resnet18, 'resnet34': conv.Resnet34, 'resnet50': conv.Resnet50, '...
Returns the Pixel2Mesh model. Args: cfg (yaml file): config file device (PyTorch device): PyTorch device
12,530
import os from im2mesh.encoder import encoder_dict from im2mesh.pix2mesh import models, training, generation from im2mesh import data import pickle import numpy as np The provided code snippet includes necessary dependencies for implementing the `get_trainer` function. Write a Python function `def get_trainer(model, o...
Return the trainer object for the Pixel2Mesh model. Args: model (PyTorch model): Pixel2Mesh model optimizer( PyTorch optimizer): The optimizer that should be used cfg (yaml file): config file device (PyTorch device): The PyTorch device that should be used
12,531
import os from im2mesh.encoder import encoder_dict from im2mesh.pix2mesh import models, training, generation from im2mesh import data import pickle import numpy as np The provided code snippet includes necessary dependencies for implementing the `get_generator` function. Write a Python function `def get_generator(mode...
Returns a generator object for the Pixel2Mesh model. Args: model (PyTorch model): Pixel2Mesh model cfg (yaml file): config file device (PyTorch device): The PyTorch device that should be used
12,532
import os from im2mesh.encoder import encoder_dict from im2mesh.pix2mesh import models, training, generation from im2mesh import data import pickle import numpy as np The provided code snippet includes necessary dependencies for implementing the `get_data_fields` function. Write a Python function `def get_data_fields(...
Returns the respective data fields. Args: mode (string): which split should be performed (train/test) cfg (yaml file): config file
12,533
import os from im2mesh.encoder import encoder_dict from im2mesh.psgn import models, training, generation from im2mesh import data encoder_dict = { 'simple_conv': conv.ConvEncoder, 'resnet18': conv.Resnet18, 'resnet34': conv.Resnet34, 'resnet50': conv.Resnet50, 'resnet101': conv.Resnet101, 'r2n2...
r''' Returns the model instance. Args: cfg (yaml object): the config file device (PyTorch device): the PyTorch device
12,534
import os from im2mesh.encoder import encoder_dict from im2mesh.psgn import models, training, generation from im2mesh import data The provided code snippet includes necessary dependencies for implementing the `get_trainer` function. Write a Python function `def get_trainer(model, optimizer, cfg, device, **kwargs)` to ...
r''' Returns the trainer instance. Args: model (nn.Module): PSGN model optimizer (PyTorch optimizer): The optimizer that should be used cfg (yaml object): the config file device (PyTorch device): the PyTorch device
12,535
import os from im2mesh.encoder import encoder_dict from im2mesh.psgn import models, training, generation from im2mesh import data The provided code snippet includes necessary dependencies for implementing the `get_generator` function. Write a Python function `def get_generator(model, cfg, device, **kwargs)` to solve t...
r''' Returns the generator instance. Args: cfg (yaml object): the config file device (PyTorch device): the PyTorch device
12,536
import os from im2mesh.encoder import encoder_dict from im2mesh.psgn import models, training, generation from im2mesh import data The provided code snippet includes necessary dependencies for implementing the `get_data_fields` function. Write a Python function `def get_data_fields(mode, cfg, **kwargs)` to solve the fo...
r''' Returns the data fields. Args: mode (string): The split that is used (train/val/test) cfg (yaml object): the config file
12,537
import torch from im2mesh.utils.io import export_pointcloud import tempfile import subprocess import os import trimesh FILTER_SCRIPT_RECONSTRUCTION = ''' <!DOCTYPE FilterScript> <FilterScript> <filter name="Surface Reconstruction: Ball Pivoting"> <Param value="0" type="RichAbsPerc" max="1.4129" name="BallRadius" des...
r''' Runs the meshlab ball pivoting algorithm. Args: pointcloud (numpy tensor): input point cloud