fovi.demo

Demo utilities for FoviNet.

This module provides helper functions for quickly loading and preparing images for model inference demonstrations.

fovi.demo.get_image_as_batch(path='shark.png', device='cuda')[source]

Load an image and prepare it as a normalized batch tensor.

Loads an image, crops it to a square (center crop), converts to tensor, and applies ImageNet normalization.

Parameters:
  • path (str, optional) – Path to the image file. Defaults to ‘shark.png’.

  • device (str, optional) – Device to place the tensor on. Defaults to ‘cuda’.

Returns:

Normalized image tensor of shape (1, 3, H, W) where

H and W are equal (square crop of the minimum dimension).

Return type:

torch.Tensor

fovi.demo.load_image_for_sampling(path, device='cuda', normalize=True, center_crop=False)[source]

Load an image for foveated sampling demos.

By default keeps the native aspect ratio. Optionally center-crops to a square, matching get_image_as_batch.

Parameters:
  • path (str) – Path to the image file.

  • device (str, optional) – Device for the batch tensor. Defaults to ‘cuda’.

  • normalize (bool, optional) – Apply ImageNet normalization to the batch. Defaults to True.

  • center_crop (bool, optional) – Center-crop to a square before loading. Defaults to False.

Returns:

(batch, display_rgb, height, width) where batch has shape

(1, 3, H, W), display_rgb is (H, W, 3) float in [0, 1].

Return type:

tuple