limap.line2d.SOLD2 package

Subpackages

Submodules

limap.line2d.SOLD2.experiment module

Main file to launch training and testing experiments.

limap.line2d.SOLD2.experiment.load_config(config_path)

Load configurations from a given yaml file.

limap.line2d.SOLD2.experiment.record_config(model_cfg, dataset_cfg, output_path)

Record dataset config to the log path.

limap.line2d.SOLD2.experiment.update_config(path, model_cfg=None, dataset_cfg=None)

Update configuration file from the resume path.

limap.line2d.SOLD2.sold2 module

class limap.line2d.SOLD2.sold2.SOLD2Detector(options=BaseDetectorOptions(set_gray=True, max_num_2d_segs=3000, do_merge_lines=False, visualize=False, weight_path=None))

Bases: BaseDetector

detect(camview)

Virtual method (for detector) - detect 2D line segments

Parameters:

view (limap.base.CameraView) – The limap.base.CameraView instance corresponding to the image

Returns:

line detections. Each row corresponds to x1, y1, x2, y2 and score.

Return type:

np.array of shape (N, 5)

detect_and_extract(camview)

Virtual method (for dual-functional class that can perform both detection and extraction) - Detect and extract on a single image

Parameters:

view (limap.base.CameraView) – The limap.base.CameraView instance corresponding to the image

Returns:

of shape (N, 5), line detections. Each row corresponds to x1, y1, x2, y2 and score. Computed from the detect method. descinfo: The features extracted from the function extract

Return type:

segs (np.array)

extract(camview, segs)

Virtual method (for extractor) - extract the features for the detected segments

Parameters:
  • view (limap.base.CameraView) – The limap.base.CameraView instance corresponding to the image

  • segsnp.array of shape (N, 5), line detections. Each row corresponds to x1, y1, x2, y2 and score. Computed from the detect method.

Returns:

The extracted feature

extract_heatmap(camview)
extract_heatmaps_all_images(folder, imagecols, skip_exists=False)
get_descinfo_fname(descinfo_folder, img_id)

Virtual method (for extractor) - Get the target filename of the extracted feature

Parameters:
  • descinfo_folder (str) – The output folder

  • img_id (int) – The image id

Returns:

target filename

Return type:

str

get_heatmap_fname(folder, img_id)
get_module_name()

Virtual method (need to be implemented) - return the name of the module

read_descinfo(descinfo_folder, img_id)

Virtual method (for extractor) - Read in the extracted feature. Dual function for save_descinfo.

Parameters:
  • descinfo_folder (str) – The output folder

  • img_id (int) – The image id

Returns:

The extracted feature

sample_descinfo_by_indexes(descinfo, indexes)

Virtual method (for dual-functional class that can perform both detection and extraction) - sample descriptors for a subset of images

Parameters:
  • descinfo – The features extracted from the function extract.

  • indexes (list[int]) – List of image ids for the subset.

save_descinfo(descinfo_folder, img_id, descinfo)

Virtual method (for extractor) - Save the extracted feature to the target folder

Parameters:
  • descinfo_folder (str) – The output folder

  • img_id (int) – The image id

  • descinfo – The features extracted from the function extract

class limap.line2d.SOLD2.sold2.SOLD2Matcher(extractor, options=BaseMatcherOptions(topk=10, n_neighbors=20, n_jobs=1, weight_path=None))

Bases: BaseMatcher

get_module_name()
match_pair(descinfo1, descinfo2)

limap.line2d.SOLD2.sold2_wrapper module

class limap.line2d.SOLD2.sold2_wrapper.SOLD2LineDetector(device=None, cfg_path=None, weight_path=None)

Bases: object

compute_descinfo(segs, desc)
detect(input_image, saliency=False, scale_factor=None)
get_heatmap(input_image)
initialize_line_matcher()
match(img1, img2)
match_segs_with_descinfo(descinfo1, descinfo2)
match_segs_with_descinfo_topk(descinfo1, descinfo2, topk=10)
match_segs_with_descriptor(segs1, desc1, segs2, desc2)
segstosold2segs(segs)
sold2segstosegs(segs_sold2)

limap.line2d.SOLD2.train module

This file implements the training process and all the summaries

limap.line2d.SOLD2.train.convert_junc_predictions(predictions, grid_size, detect_thresh=0.015384615384615385, topk=300)

Convert torch predictions to numpy arrays for evaluation.

limap.line2d.SOLD2.train.customized_collate_fn(batch)

Customized collate_fn.

limap.line2d.SOLD2.train.plot_junction_detection(image_tensor, junc_pred_tensor, junc_pred_nms_tensor, junc_gt_tensor)

Plot the junction points on images.

limap.line2d.SOLD2.train.record_test_summaries(writer, epoch, scalars)

Record testing summaries.

limap.line2d.SOLD2.train.record_train_summaries(writer, global_step, scalars, images)

Record training summaries.

limap.line2d.SOLD2.train.restore_weights(model, state_dict, strict=True)

Restore weights in compatible mode.

limap.line2d.SOLD2.train.train_single_epoch(model, model_cfg, optimizer, loss_func, metric_func, train_loader, writer, epoch)

Train for one epoch.

limap.line2d.SOLD2.train.validate(model, model_cfg, loss_func, metric_func, val_loader, writer, epoch)

Validation.

Module contents