jhj0517
commited on
Commit
·
2088999
1
Parent(s):
7f08e0c
Add image saver
Browse files- modules/utils/helper.py +7 -0
modules/utils/helper.py
CHANGED
|
@@ -11,6 +11,8 @@ import torch
|
|
| 11 |
import yaml
|
| 12 |
import argparse
|
| 13 |
import locale
|
|
|
|
|
|
|
| 14 |
from rich.console import Console
|
| 15 |
from collections import OrderedDict
|
| 16 |
|
|
@@ -143,3 +145,8 @@ def str2bool(v):
|
|
| 143 |
return False
|
| 144 |
else:
|
| 145 |
raise argparse.ArgumentTypeError('Boolean value expected.')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
import yaml
|
| 12 |
import argparse
|
| 13 |
import locale
|
| 14 |
+
import numpy as np
|
| 15 |
+
from PIL import Image
|
| 16 |
from rich.console import Console
|
| 17 |
from collections import OrderedDict
|
| 18 |
|
|
|
|
| 145 |
return False
|
| 146 |
else:
|
| 147 |
raise argparse.ArgumentTypeError('Boolean value expected.')
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
def save_image(numpy_array: np.ndarray, output_path: str):
|
| 151 |
+
out = Image.fromarray(numpy_array)
|
| 152 |
+
out.save(output_path, compress_level=1, format="png")
|