src.runtime.runtime module

supports multiple input modules images: image dataset from a text file containing a list of paths to images video: video input stream: eg webcam supports multiple output modules video - generates an output video; same as demo.py test - compares result with labels; same as test.py prod - will probably only log results, in future you will put your production code here i will not provide multi-gpu support. See test.py as a reference but it might be more complicated in the end as i dont plan to support multi gpu in any way

A note on performance: This code should provide acceptable performance, but it was not developed with the target of achieving the best performance. The main goal is to provide a good understandable and expandable / adaptable code base.

class src.runtime.runtime.FrameProcessor(net, output_method)[source]

Bases: object

helper class to process frame

provides simplified access to process_frame() method or a better encapsulation compared to functional approach (depending on implementation ;))

process_frames(frames: torch.Tensor, names: List[str] = None, source_frames: List[numpy.ndarray] = None, tqdm_bar=None)[source]

process frames and pass result to output_method.

Note: length of all supplied arrays (frames, names, source_frames) must be of the same length.

Parameters
  • frames – frames to process, have to be preprocessed (scaled, as tensor, normalized)

  • names – file paths - provide if possible, used by some out-modules

  • source_frames – source images (only scaled to img_height & img_width, but not further processed, eg from camera) - provide if possible - used by some out modules

  • tqdm_bar – if using a tqdm progress bar in an input module pass it via this variable for better performance logging (if measure_time is eanbled)

src.runtime.runtime.main()[source]

Entry method for this package.

src.runtime.runtime.setup_input(process_frames: Callable[[torch.Tensor, List[str], List[numpy.ndarray]], None])[source]

setup data input (where the frames come from)

Parameters

process_frames – function taking list of frames and a corresponding list of filenames

src.runtime.runtime.setup_net()[source]

setup neural network load config and net (from hdd) Returns: neural network (torch.nn.Module)

src.runtime.runtime.setup_out_method()[source]

setup the output method

Returns: method/function reference to a function taking

  • a list of predictions

  • a list of corresponding filenames (if available)

  • a list of source_frames (if available)