Spaces:
Running
Running
Output path
Browse files- inference_img.py +16 -12
inference_img.py
CHANGED
@@ -5,6 +5,8 @@ import argparse
|
|
5 |
from torch.nn import functional as F
|
6 |
import warnings
|
7 |
|
|
|
|
|
8 |
warnings.filterwarnings("ignore")
|
9 |
|
10 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
@@ -92,25 +94,27 @@ else:
|
|
92 |
tmp.append(img1)
|
93 |
img_list = tmp
|
94 |
|
95 |
-
if not os.path.exists('output'):
|
96 |
-
os.mkdir('output')
|
97 |
|
98 |
print("Checkpoint reached! output folder ok")
|
99 |
|
100 |
for i in range(len(img_list)):
|
|
|
|
|
|
|
101 |
if args.img[0].endswith('.exr') and args.img[1].endswith('.exr'):
|
102 |
-
cv2.imwrite(
|
103 |
-
|
104 |
-
success = cv2.imwrite(
|
105 |
-
print(f"Saving to {
|
106 |
-
print("Saving to:", os.path.abspath(
|
107 |
|
108 |
else:
|
109 |
-
cv2.imwrite(
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
print("Saving to:", os.path.abspath(save_path))
|
114 |
|
115 |
|
116 |
print("Checkpoint reached!")
|
|
|
5 |
from torch.nn import functional as F
|
6 |
import warnings
|
7 |
|
8 |
+
OUTPUT_PATH = "output/"
|
9 |
+
|
10 |
warnings.filterwarnings("ignore")
|
11 |
|
12 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
94 |
tmp.append(img1)
|
95 |
img_list = tmp
|
96 |
|
97 |
+
if not os.path.exists('/output'):
|
98 |
+
os.mkdir('/output')
|
99 |
|
100 |
print("Checkpoint reached! output folder ok")
|
101 |
|
102 |
for i in range(len(img_list)):
|
103 |
+
filename_exr = os.path.join(OUTPUT_PATH, f"img{i}.exr")
|
104 |
+
filename_png = os.path.join(OUTPUT_PATH, f"img{i}.png")
|
105 |
+
|
106 |
if args.img[0].endswith('.exr') and args.img[1].endswith('.exr'):
|
107 |
+
cv2.imwrite(filename_exr, (img_list[i][0]).cpu().numpy().transpose(1, 2, 0)[:h, :w], [cv2.IMWRITE_EXR_TYPE, cv2.IMWRITE_EXR_TYPE_HALF])
|
108 |
+
|
109 |
+
success = cv2.imwrite(filename_png, (img_list[i][0] * 255).byte().cpu().numpy().transpose(1, 2, 0)[:h, :w])
|
110 |
+
print(f"Saving to {filename_png} β success: {success}")
|
111 |
+
print("Saving to:", os.path.abspath(filename_png))
|
112 |
|
113 |
else:
|
114 |
+
success = cv2.imwrite(filename_png, (img_list[i][0] * 255).byte().cpu().numpy().transpose(1, 2, 0)[:h, :w])
|
115 |
+
print(f"Saving to {filename_png} β success: {success}")
|
116 |
+
print("Saving to:", os.path.abspath(filename_png))
|
117 |
+
|
|
|
118 |
|
119 |
|
120 |
print("Checkpoint reached!")
|