|
| 1 | +from typing import Union, Optional, Sequence, Tuple, Text, BinaryIO |
| 2 | +import io |
| 3 | +import pathlib |
1 | 4 | import torch
|
2 | 5 | import math
|
3 | 6 | irange = range
|
4 | 7 |
|
5 | 8 |
|
6 |
| -def make_grid(tensor, nrow=8, padding=2, |
7 |
| - normalize=False, range=None, scale_each=False, pad_value=0): |
| 9 | +def make_grid(tensor: Union[torch.Tensor, Sequence[torch.Tensor]], nrow: int = 8, |
| 10 | + padding: int = 2, normalize: bool = False, |
| 11 | + range: Optional[Tuple[int, int]] = None, scale_each: bool = False, |
| 12 | + pad_value: int = 0) -> torch.Tensor: |
8 | 13 | """Make a grid of images.
|
9 | 14 |
|
10 | 15 | Args:
|
@@ -88,8 +93,9 @@ def norm_range(t, range):
|
88 | 93 | return grid
|
89 | 94 |
|
90 | 95 |
|
91 |
| -def save_image(tensor, fp, nrow=8, padding=2, |
92 |
| - normalize=False, range=None, scale_each=False, pad_value=0, format=None): |
| 96 | +def save_image(tensor: Union[torch.Tensor, Sequence[torch.Tensor]], fp: Union[Text, pathlib.Path, BinaryIO], |
| 97 | + nrow: int = 8, padding: int = 2, normalize: bool = False, range: Optional[Tuple[int, int]] = None, |
| 98 | + scale_each: bool = False, pad_value: int = 0, format: Optional[str] = None) -> None: |
93 | 99 | """Save a given Tensor into an image file.
|
94 | 100 |
|
95 | 101 | Args:
|
|
0 commit comments