Supplies utility function for core and controls
INFO     - The mmdet config folder already exists. No need to downloaded it. Path : /home/frederik/.icevision/mmdetection_configs/mmdetection_configs-2.20.1/configs | icevision.models.mmdet.download_configs:download_mmdet_configs:17

toggle_legend_js[source]

toggle_legend_js(figure)

Creates custom JS for bokeh to hide the legend with a double tap.

calculate_mixing_matrix[source]

calculate_mixing_matrix(data:DataFrame, mixing_col:str, mixing_objects:str, return_df:bool=True)

Calculates mixing matrix for the mixing_objects column where they mix in the mixing_col. By standard the object class mixing matrix over the images is calculated. Returns the mixing matrix and the mapping between label and mixing matrix index. If return_df is True (default) a dataframe (instead of the mixing matrix) will be returned that can be directly consumed by histogram_2d.

test_df = pd.DataFrame({"filepath": ["fileA", "fileA", "fileB",  "fileB"], "label": ["labelA", "labelB", "labelA", "labelA"]})
mixing_matrix = calculate_mixing_matrix(test_df, "filepath", "label")
assert all(mixing_matrix == pd.DataFrame({"values": [1, 1, 1, 0], "col_name": ["labelA","labelB","labelA","labelB"], "row_name": ["labelA","labelA","labelB","labelB"]}))
mixing_matrix, mapping = calculate_mixing_matrix(test_df, "filepath", "label", return_df=False)
assert mapping == {"labelA": 0, "labelB": 1}
assert (mixing_matrix == np.array([[1,1], [1,0]])).all()

get_min_and_max_dates[source]

get_min_and_max_dates(dates:Iterable[datetime])

Returns the min and max date. If all dates are the same the max date is moved one day forward.

dates_df = pd.DataFrame([datetime.datetime(2020, 1, 1), datetime.datetime(2020, 1, 1)], columns=["dates"])
min_date, max_date = get_min_and_max_dates(dates_df["dates"])
assert min_date.day == max_date.day-1

convert_rgb_image_to_bokeh_rgb_image[source]

convert_rgb_image_to_bokeh_rgb_image(img:ndarray)

Convertes a image in the form of a numpy array to an array that can be shown by bokeh.

Bokeh requries images to be in a hw format where each value is a 32bit integer where each of the 8bit sequences contains the rgb and alpha values.

draw_record_with_bokeh[source]

draw_record_with_bokeh(record, class_map=None, display_label=True, display_bbox=False, display_mask=False, display_keypoints=False, return_figure=False, width=None, height=None)

Draws a record or returns a bokeh figure containing the image.

Wrapper around the draw_record function from icevision. The aspect ratio of the image will be preserved when only width or height is given (scaling the other accordingly).