file
This module provides the FileWriter class, which writes predictions to files in various formats.
FileWriter
Bases: BaseWriter
Writer for saving predictions to files in various formats including tensors, images, and videos. Custom writer functions can be provided to extend supported formats. Args: path: Directory path where output files will be saved. writer: Either a string specifying a built-in writer or a custom writer function. Built-in writers: - "tensor": Saves raw tensor data (.pt) - "image": Saves as image file (.png) - "video": Saves as video file (.mp4) Custom writers must: - Accept (path, tensor) arguments - Handle single tensor input (no batch dimension) - Save output to the specified path
Source code in src/lighter/callbacks/writer/file.py
write(tensor, identifier)
Writes the tensor to a file using the specified writer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tensor
|
Tensor
|
The tensor to write. |
required |
identifier
|
int | str
|
Identifier for naming the file. |
required |
Source code in src/lighter/callbacks/writer/file.py
write_image(path, tensor)
Writes a tensor as an image file in .png format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
The path to save the image. |
required | |
tensor
|
The tensor representing the image. |
required |
Source code in src/lighter/callbacks/writer/file.py
write_tensor(path, tensor)
Writes a tensor to a file in .pt format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
The path to save the tensor. |
required | |
tensor
|
The tensor to save. |
required |
write_video(path, tensor)
Writes a tensor as a video file in .mp4 format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
The path to save the video. |
required | |
tensor
|
The tensor representing the video in CTHW format. |
required |