Python IPython.display() Examples
The following are 30
code examples of IPython.display().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
IPython
, or try the search function
.
Example #1
Source File: test_display.py From altair with BSD 3-Clause "New" or "Revised" License | 6 votes |
def check_render_options(**options): """ Context manager that will assert that alt.renderers.options are equivalent to the given options in the IPython.display.display call """ import IPython.display def check_options(obj): assert alt.renderers.options == options _display = IPython.display.display IPython.display.display = check_options try: yield finally: IPython.display.display = _display
Example #2
Source File: visualize.py From SketchyScene with MIT License | 6 votes |
def display_images(images, titles=None, cols=4, cmap=None, norm=None, interpolation=None): """Display the given set of images, optionally with titles. images: list or array of image tensors in HWC format. titles: optional. A list of titles to display with each image. cols: number of images per row cmap: Optional. Color map to use. For example, "Blues". norm: Optional. A Normalize instance to map values to colors. interpolation: Optional. Image interporlation to use for display. """ titles = titles if titles is not None else [""] * len(images) rows = len(images) // cols + 1 plt.figure(figsize=(14, 14 * rows // cols)) i = 1 for image, title in zip(images, titles): plt.subplot(rows, cols, i) plt.title(title, fontsize=9) plt.axis('off') plt.imshow(image.astype(np.uint8), cmap=cmap, norm=norm, interpolation=interpolation) i += 1 plt.show()
Example #3
Source File: nbdisplay.py From msticpy with MIT License | 6 votes |
def display_process_tree(process_tree: pd.DataFrame): """ Display process tree data frame. (Deprecated). Parameters ---------- process_tree : pd.DataFrame Process tree DataFrame The display module expects the columns NodeRole and Level to be populated. NoteRole is one of: 'source', 'parent', 'child' or 'sibling'. Level indicates the 'hop' distance from the 'source' node. """ build_and_show_process_tree(process_tree)
Example #4
Source File: copy of visualize.py From latte with Apache License 2.0 | 6 votes |
def display_images(images, titles=None, cols=4, cmap=None, norm=None, interpolation=None): """Display the given set of images, optionally with titles. images: list or array of image tensors in HWC format. titles: optional. A list of titles to display with each image. cols: number of images per row cmap: Optional. Color map to use. For example, "Blues". norm: Optional. A Normalize instance to map values to colors. interpolation: Optional. Image interporlation to use for display. """ titles = titles if titles is not None else [""] * len(images) rows = len(images) // cols + 1 plt.figure(figsize=(14, 14 * rows // cols)) i = 1 for image, title in zip(images, titles): plt.subplot(rows, cols, i) plt.title(title, fontsize=9) plt.axis('off') plt.imshow(image.astype(np.uint8), cmap=cmap, norm=norm, interpolation=interpolation) i += 1 plt.show()
Example #5
Source File: visualize.py From cvpr-2018-autonomous-driving-autopilot-solution with MIT License | 6 votes |
def display_images(images, titles=None, cols=4, cmap=None, norm=None, interpolation=None): """Display the given set of images, optionally with titles. images: list or array of image tensors in HWC format. titles: optional. A list of titles to display with each image. cols: number of images per row cmap: Optional. Color map to use. For example, "Blues". norm: Optional. A Normalize instance to map values to colors. interpolation: Optional. Image interporlation to use for display. """ titles = titles if titles is not None else [""] * len(images) rows = len(images) // cols + 1 plt.figure(figsize=(14, 14 * rows // cols)) i = 1 for image, title in zip(images, titles): plt.subplot(rows, cols, i) plt.title(title, fontsize=9) plt.axis('off') plt.imshow(image.astype(np.uint8), cmap=cmap, norm=norm, interpolation=interpolation) i += 1 plt.show()
Example #6
Source File: nbdisplay.py From msticpy with MIT License | 6 votes |
def display_alert( alert: Union[Mapping[str, Any], SecurityAlert], show_entities: bool = False ): """ Display a Security Alert. Parameters ---------- alert : Union[Mapping[str, Any], SecurityAlert] The alert to display as Mapping (e.g. pd.Series) or SecurityAlert show_entities : bool, optional Whether to display entities (the default is False) """ output = format_alert(alert, show_entities) if not isinstance(output, tuple): output = [output] for disp_obj in output: display(disp_obj)
Example #7
Source File: visualize.py From 2018DSB with MIT License | 6 votes |
def display_images(images, titles=None, cols=4, cmap=None, norm=None, interpolation=None): """Display the given set of images, optionally with titles. images: list or array of image tensors in HWC format. titles: optional. A list of titles to display with each image. cols: number of images per row cmap: Optional. Color map to use. For example, "Blues". norm: Optional. A Normalize instance to map values to colors. interpolation: Optional. Image interporlation to use for display. """ titles = titles if titles is not None else [""] * len(images) rows = len(images) // cols + 1 plt.figure(figsize=(14, 14 * rows // cols)) i = 1 for image, title in zip(images, titles): plt.subplot(rows, cols, i) plt.title(title, fontsize=9) plt.axis('off') plt.imshow(image.astype(np.uint8), cmap=cmap, norm=norm, interpolation=interpolation) i += 1 plt.show()
Example #8
Source File: utils.py From parliament2 with Apache License 2.0 | 6 votes |
def post_execute(self): if self.isFirstPostExecute: self.isFirstPostExecute = False self.isFirstPreExecute = False return 0 self.flag = False self.asyncCapturer.Wait() self.ioHandler.Poll() self.ioHandler.EndCapture() # Print for the notebook out = self.ioHandler.GetStdout() err = self.ioHandler.GetStderr() if not transformers: sys.stdout.write(out) sys.stderr.write(err) else: for t in transformers: (out, err, otype) = t(out, err) if otype == 'html': IPython.display.display(HTML(out)) IPython.display.display(HTML(err)) return 0
Example #9
Source File: display_hooks.py From holoviews with BSD 3-Clause "New" or "Revised" License | 6 votes |
def render(obj, **kwargs): info = process_object(obj) if info: display(HTML(info)) return if render_anim is not None: return render_anim(obj) backend = Store.current_backend renderer = Store.renderers[backend] # Drop back to png if pdf selected, notebook PDF rendering is buggy if renderer.fig == 'pdf': renderer = renderer.instance(fig='png') return renderer.components(obj, **kwargs)
Example #10
Source File: visualize.py From PyTorch-Luna16 with Apache License 2.0 | 6 votes |
def display_images(images, titles=None, cols=4, cmap=None, norm=None, interpolation=None): """Display the given set of images, optionally with titles. images: list or array of image tensors in HWC format. titles: optional. A list of titles to display with each image. cols: number of images per row cmap: Optional. Color map to use. For example, "Blues". norm: Optional. A Normalize instance to map values to colors. interpolation: Optional. Image interporlation to use for display. """ titles = titles if titles is not None else [""] * len(images) rows = len(images) // cols + 1 plt.figure(figsize=(14, 14 * rows // cols)) i = 1 for image, title in zip(images, titles): plt.subplot(rows, cols, i) plt.title(title, fontsize=9) plt.axis('off') plot_area = image[:,:,0] if len(image.shape) == 3 else image plt.imshow(plot_area.astype(np.uint8), cmap=cmap, norm=norm, interpolation=interpolation) i += 1 plt.show()
Example #11
Source File: visualize.py From PanopticSegmentation with MIT License | 6 votes |
def display_images(images, titles=None, cols=4, cmap=None, norm=None, interpolation=None): """Display the given set of images, optionally with titles. images: list or array of image tensors in HWC format. titles: optional. A list of titles to display with each image. cols: number of images per row cmap: Optional. Color map to use. For example, "Blues". norm: Optional. A Normalize instance to map values to colors. interpolation: Optional. Image interpolation to use for display. """ titles = titles if titles is not None else [""] * len(images) rows = len(images) // cols + 1 plt.figure(figsize=(14, 14 * rows // cols)) i = 1 for image, title in zip(images, titles): plt.subplot(rows, cols, i) plt.title(title, fontsize=9) plt.axis('off') plt.imshow(image.astype(np.uint8), cmap=cmap, norm=norm, interpolation=interpolation) i += 1 plt.show()
Example #12
Source File: visualize.py From deepdiy with MIT License | 6 votes |
def display_images(images, titles=None, cols=4, cmap=None, norm=None, interpolation=None): """Display the given set of images, optionally with titles. images: list or array of image tensors in HWC format. titles: optional. A list of titles to display with each image. cols: number of images per row cmap: Optional. Color map to use. For example, "Blues". norm: Optional. A Normalize instance to map values to colors. interpolation: Optional. Image interpolation to use for display. """ titles = titles if titles is not None else [""] * len(images) rows = len(images) // cols + 1 plt.figure(figsize=(14, 14 * rows // cols)) i = 1 for image, title in zip(images, titles): plt.subplot(rows, cols, i) plt.title(title, fontsize=9) plt.axis('off') plt.imshow(image.astype(np.uint8), cmap=cmap, norm=norm, interpolation=interpolation) i += 1 plt.show()
Example #13
Source File: visualize.py From segmentation-unet-maskrcnn with MIT License | 6 votes |
def display_images(images, titles=None, cols=4, cmap=None, norm=None, interpolation=None): """Display the given set of images, optionally with titles. images: list or array of image tensors in HWC format. titles: optional. A list of titles to display with each image. cols: number of images per row cmap: Optional. Color map to use. For example, "Blues". norm: Optional. A Normalize instance to map values to colors. interpolation: Optional. Image interporlation to use for display. """ titles = titles if titles is not None else [""] * len(images) rows = len(images) // cols + 1 plt.figure(figsize=(14, 14 * rows // cols)) i = 1 for image, title in zip(images, titles): plt.subplot(rows, cols, i) plt.title(title, fontsize=9) plt.axis('off') plt.imshow(image.astype(np.uint8), cmap=cmap, norm=norm, interpolation=interpolation) i += 1 plt.show()
Example #14
Source File: visualize1.py From latte with Apache License 2.0 | 6 votes |
def display_images(images, titles=None, cols=4, cmap=None, norm=None, interpolation=None): """Display the given set of images, optionally with titles. images: list or array of image tensors in HWC format. titles: optional. A list of titles to display with each image. cols: number of images per row cmap: Optional. Color map to use. For example, "Blues". norm: Optional. A Normalize instance to map values to colors. interpolation: Optional. Image interporlation to use for display. """ titles = titles if titles is not None else [""] * len(images) rows = len(images) // cols + 1 plt.figure(figsize=(14, 14 * rows // cols)) i = 1 for image, title in zip(images, titles): plt.subplot(rows, cols, i) plt.title(title, fontsize=9) plt.axis('off') plt.imshow(image.astype(np.uint8), cmap=cmap, norm=norm, interpolation=interpolation) i += 1 plt.show()
Example #15
Source File: visualize.py From dataiku-contrib with Apache License 2.0 | 6 votes |
def display_images(images, titles=None, cols=4, cmap=None, norm=None, interpolation=None): """Display the given set of images, optionally with titles. images: list or array of image tensors in HWC format. titles: optional. A list of titles to display with each image. cols: number of images per row cmap: Optional. Color map to use. For example, "Blues". norm: Optional. A Normalize instance to map values to colors. interpolation: Optional. Image interpolation to use for display. """ titles = titles if titles is not None else [""] * len(images) rows = len(images) // cols + 1 plt.figure(figsize=(14, 14 * rows // cols)) i = 1 for image, title in zip(images, titles): plt.subplot(rows, cols, i) plt.title(title, fontsize=9) plt.axis('off') plt.imshow(image.astype(np.uint8), cmap=cmap, norm=norm, interpolation=interpolation) i += 1 plt.show()
Example #16
Source File: test_display.py From altair with BSD 3-Clause "New" or "Revised" License | 6 votes |
def check_render_options(**options): """ Context manager that will assert that alt.renderers.options are equivalent to the given options in the IPython.display.display call """ import IPython.display def check_options(obj): assert alt.renderers.options == options _display = IPython.display.display IPython.display.display = check_options try: yield finally: IPython.display.display = _display
Example #17
Source File: visualize.py From SpaceNet_Off_Nadir_Solutions with Apache License 2.0 | 6 votes |
def display_images(images, titles=None, cols=4, cmap=None, norm=None, interpolation=None): """Display the given set of images, optionally with titles. images: list or array of image tensors in HWC format. titles: optional. A list of titles to display with each image. cols: number of images per row cmap: Optional. Color map to use. For example, "Blues". norm: Optional. A Normalize instance to map values to colors. interpolation: Optional. Image interporlation to use for display. """ titles = titles if titles is not None else [""] * len(images) rows = len(images) // cols + 1 plt.figure(figsize=(14, 14 * rows // cols)) i = 1 for image, title in zip(images, titles): plt.subplot(rows, cols, i) plt.title(title, fontsize=9) plt.axis('off') plt.imshow(image.astype(np.uint8), cmap=cmap, norm=norm, interpolation=interpolation) i += 1 plt.show()
Example #18
Source File: ipython.py From xcube with MIT License | 6 votes |
def register_json_formatter(cls: Type, to_dict_method_name: str = 'to_dict'): """ TODO :param cls: :param to_dict_method_name: :return: """ if not hasattr(cls, to_dict_method_name) or not callable(getattr(cls, to_dict_method_name)): raise ValueError(f'{cls} must define a {to_dict_method_name}() method') try: import IPython import IPython.display if IPython.get_ipython() is not None: def obj_to_dict(obj): return getattr(obj, to_dict_method_name)() ipy_formatter = IPython.get_ipython().display_formatter.formatters['application/json'] ipy_formatter.for_type(cls, obj_to_dict) except ImportError: pass
Example #19
Source File: visualize.py From Mask-RCNN-Pedestrian-Detection with MIT License | 6 votes |
def display_images(images, titles=None, cols=4, cmap=None, norm=None, interpolation=None): """Display the given set of images, optionally with titles. images: list or array of image tensors in HWC format. titles: optional. A list of titles to display with each image. cols: number of images per row cmap: Optional. Color map to use. For example, "Blues". norm: Optional. A Normalize instance to map values to colors. interpolation: Optional. Image interporlation to use for display. """ titles = titles if titles is not None else [""] * len(images) rows = len(images) // cols + 1 plt.figure(figsize=(14, 14 * rows // cols)) i = 1 for image, title in zip(images, titles): plt.subplot(rows, cols, i) plt.title(title, fontsize=9) plt.axis('off') plt.imshow(image.astype(np.uint8), cmap=cmap, norm=norm, interpolation=interpolation) i += 1 plt.show()
Example #20
Source File: visualize.py From DeepTL-Lane-Change-Classification with MIT License | 6 votes |
def display_images(images, titles=None, cols=4, cmap=None, norm=None, interpolation=None): """Display the given set of images, optionally with titles. images: list or array of image tensors in HWC format. titles: optional. A list of titles to display with each image. cols: number of images per row cmap: Optional. Color map to use. For example, "Blues". norm: Optional. A Normalize instance to map values to colors. interpolation: Optional. Image interporlation to use for display. """ titles = titles if titles is not None else [""] * len(images) rows = len(images) // cols + 1 plt.figure(figsize=(14, 14 * rows // cols)) i = 1 for image, title in zip(images, titles): plt.subplot(rows, cols, i) plt.title(title, fontsize=9) plt.axis('off') plt.imshow(image.astype(np.uint8), cmap=cmap, norm=norm, interpolation=interpolation) i += 1 plt.show()
Example #21
Source File: td.py From pandas-td with Apache License 2.0 | 6 votes |
def wait_for_import(self, count, timeout=300): time_start = time.time() while time.time() < time_start + timeout: t = self.client.table(self.database, self.table) self.imported_count = t.count - self.initial_count if self.imported_count >= count: break self._display_progress(self.frame_size) time.sleep(2) # import finished self.imported_at = datetime.datetime.utcnow().replace(microsecond=0) # import timeout if self.imported_count < count: self.import_timeout = timeout self._display_progress(self.frame_size) # clear progress if self.clear_progress and self.imported_count == count: IPython.display.clear_output() # public methods
Example #22
Source File: visualize.py From raster-deep-learning with Apache License 2.0 | 6 votes |
def display_images(images, titles=None, cols=4, cmap=None, norm=None, interpolation=None): """Display the given set of images, optionally with titles. images: list or array of image tensors in HWC format. titles: optional. A list of titles to display with each image. cols: number of images per row cmap: Optional. Color map to use. For example, "Blues". norm: Optional. A Normalize instance to map values to colors. interpolation: Optional. Image interpolation to use for display. """ titles = titles if titles is not None else [""] * len(images) rows = len(images) // cols + 1 plt.figure(figsize=(14, 14 * rows // cols)) i = 1 for image, title in zip(images, titles): plt.subplot(rows, cols, i) plt.title(title, fontsize=9) plt.axis('off') plt.imshow(image.astype(np.uint8), cmap=cmap, norm=norm, interpolation=interpolation) i += 1 plt.show()
Example #23
Source File: visualize.py From deep-learning-explorer with Apache License 2.0 | 6 votes |
def display_images(images, titles=None, cols=4, cmap=None, norm=None, interpolation=None): """Display the given set of images, optionally with titles. images: list or array of image tensors in HWC format. titles: optional. A list of titles to display with each image. cols: number of images per row cmap: Optional. Color map to use. For example, "Blues". norm: Optional. A Normalize instance to map values to colors. interpolation: Optional. Image interporlation to use for display. """ titles = titles if titles is not None else [""] * len(images) rows = len(images) // cols + 1 plt.figure(figsize=(14, 14 * rows // cols)) i = 1 for image, title in zip(images, titles): plt.subplot(rows, cols, i) plt.title(title, fontsize=9) plt.axis('off') plt.imshow(image.astype(np.uint8), cmap=cmap, norm=norm, interpolation=interpolation) i += 1 plt.show()
Example #24
Source File: visualize.py From bird_species_classification with MIT License | 6 votes |
def display_images(images, titles=None, cols=4, cmap=None, norm=None, interpolation=None): """Display the given set of images, optionally with titles. images: list or array of image tensors in HWC format. titles: optional. A list of titles to display with each image. cols: number of images per row cmap: Optional. Color map to use. For example, "Blues". norm: Optional. A Normalize instance to map values to colors. interpolation: Optional. Image interpolation to use for display. """ titles = titles if titles is not None else [""] * len(images) rows = len(images) // cols + 1 plt.figure(figsize=(14, 14 * rows // cols)) i = 1 for image, title in zip(images, titles): plt.subplot(rows, cols, i) plt.title(title, fontsize=9) plt.axis('off') plt.imshow(image.astype(np.uint8), cmap=cmap, norm=norm, interpolation=interpolation) i += 1 plt.show()
Example #25
Source File: display_hooks.py From holoviews with BSD 3-Clause "New" or "Revised" License | 6 votes |
def image_display(element, max_frames, fmt): """ Used to render elements to an image format (svg or png) if requested in the display formats. """ if fmt not in Store.display_formats: return None info = process_object(element) if info: display(HTML(info)) return backend = Store.current_backend if type(element) not in Store.registry[backend]: return None renderer = Store.renderers[backend] plot = renderer.get_plot(element) # Current renderer does not support the image format if fmt not in renderer.param.objects('existing')['fig'].objects: return None data, info = renderer(plot, fmt=fmt) return {info['mime_type']: data}, {}
Example #26
Source File: save_and_load.py From RFHO with MIT License | 5 votes |
def save_fig(name, root_dir=None, notebook_mode=True, default_overwrite=False, extension='pdf', **savefig_kwargs): if root_dir is None: root_dir = os.getcwd() directory = check_or_create_dir(join_paths(root_dir, FOLDER_NAMINGS['PLOTS_DIR']), notebook_mode=notebook_mode) filename = join_paths(directory, '%s.%s' % (name, extension)) # directory + '/%s.pdf' % name if not default_overwrite and os.path.isfile(filename): # if IPython is not None: # IPython.display.display(tuple(IFrame(filename, width=800, height=600))) # FIXME not working! overwrite = input('A file named %s already exists. Overwrite (Leave string empty for NO!)?' % filename) if not overwrite: print('No changes done.') return plt.savefig(filename, **savefig_kwargs) # print('file saved')
Example #27
Source File: __init__.py From holoviews with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _get_resources(self, args, params): """ Finds the list of resources from the keyword parameters and pops them out of the params dictionary. """ resources = [] disabled = [] for resource in ['holoviews'] + list(Store.renderers.keys()): if resource in args: resources.append(resource) if resource in params: setting = params.pop(resource) if setting is True and resource != 'matplotlib': if resource not in resources: resources.append(resource) if setting is False: disabled.append(resource) unmatched_args = set(args) - set(resources) if unmatched_args: display(HTML('<b>Warning:</b> Unrecognized resources %s' % ', '.join(unmatched_args))) resources = [r for r in resources if r not in disabled] if ('holoviews' not in disabled) and ('holoviews' not in resources): resources = ['holoviews'] + resources return resources
Example #28
Source File: display_hooks.py From holoviews with BSD 3-Clause "New" or "Revised" License | 5 votes |
def display(obj, raw_output=False, **kwargs): """ Renders any HoloViews object to HTML and displays it using the IPython display function. If raw is enabled the raw HTML is returned instead of displaying it directly. """ if not Store.loaded_backends() and isinstance(obj, Dimensioned): raise RuntimeError('To use display on a HoloViews object ensure ' 'a backend is loaded using the holoviews ' 'extension.') raw = True if isinstance(obj, GridSpace): with option_state(obj): output = grid_display(obj) elif isinstance(obj, (CompositeOverlay, ViewableElement)): with option_state(obj): output = element_display(obj) elif isinstance(obj, (Layout, NdLayout, AdjointLayout)): with option_state(obj): output = layout_display(obj) elif isinstance(obj, (HoloMap, DynamicMap)): with option_state(obj): output = map_display(obj) elif isinstance(obj, Plot): output = render(obj) else: output = obj raw = kwargs.pop('raw', False) if raw_output: return output elif isinstance(output, tuple): data, metadata = output else: data, metadata = output, {} return IPython.display.display(data, raw=raw, metadata=metadata, **kwargs)
Example #29
Source File: visualize.py From SpaceNet_Off_Nadir_Solutions with Apache License 2.0 | 5 votes |
def display_table(table): """Display values in a table format. table: an iterable of rows, and each row is an iterable of values. """ html = "" for row in table: row_html = "" for col in row: row_html += "<td>{:40}</td>".format(str(col)) html += "<tr>" + row_html + "</tr>" html = "<table>" + html + "</table>" IPython.display.display(IPython.display.HTML(html))
Example #30
Source File: display_hooks.py From holoviews with BSD 3-Clause "New" or "Revised" License | 5 votes |
def middle_frame(obj): "Only display the (approximately) middle frame of an animated plot" plot, renderer, fmt = single_frame_plot(obj) middle_frame = int(len(plot) / 2) plot.update(middle_frame) return {'text/html': renderer.html(plot, fmt)}