Spaces:
Paused
Paused
use outdir const
Browse files- evaluate.py +10 -7
- outputs/metrics.json +1 -0
evaluate.py
CHANGED
|
@@ -14,6 +14,9 @@ import json
|
|
| 14 |
import cv2
|
| 15 |
from huggingface_hub import snapshot_download
|
| 16 |
|
|
|
|
|
|
|
|
|
|
| 17 |
# Convert PIL to numpy
|
| 18 |
def pil_to_np(img):
|
| 19 |
return np.array(img).astype(np.float32) / 255.0
|
|
@@ -125,9 +128,9 @@ def get_score(item, image_paths, video_path, train_steps=100, inference_steps=10
|
|
| 125 |
results_base = []
|
| 126 |
gt_frames = []
|
| 127 |
max_frame_count = 200
|
| 128 |
-
if os.path.isdir(
|
| 129 |
-
for filename in os.listdir(
|
| 130 |
-
img = Image.open(
|
| 131 |
if filename.startswith('result_'):
|
| 132 |
results.append(img)
|
| 133 |
elif filename.startswith('base_'):
|
|
@@ -148,16 +151,16 @@ def get_score(item, image_paths, video_path, train_steps=100, inference_steps=10
|
|
| 148 |
#results = run(images, video_path, train_steps=100, inference_steps=10, fps=12, bg_remove=False, finetune=True)
|
| 149 |
results, results_base = run_eval(images, video_path, train_steps=100, inference_steps=10, fps=12, modelId="fine_tuned_pcdms", img_width=1920, img_height=1080, bg_remove=False, resize_inputs=False)
|
| 150 |
|
| 151 |
-
os.makedirs(
|
| 152 |
|
| 153 |
for i, frame in enumerate(gt_frames):
|
| 154 |
-
frame.save(
|
| 155 |
|
| 156 |
for i, result in enumerate(results):
|
| 157 |
-
result.save(
|
| 158 |
|
| 159 |
for i, result in enumerate(results_base):
|
| 160 |
-
result.save(
|
| 161 |
|
| 162 |
ssim = []
|
| 163 |
psnr = []
|
|
|
|
| 14 |
import cv2
|
| 15 |
from huggingface_hub import snapshot_download
|
| 16 |
|
| 17 |
+
outdir = 'outputs/' #'/data/out/'
|
| 18 |
+
|
| 19 |
+
|
| 20 |
# Convert PIL to numpy
|
| 21 |
def pil_to_np(img):
|
| 22 |
return np.array(img).astype(np.float32) / 255.0
|
|
|
|
| 128 |
results_base = []
|
| 129 |
gt_frames = []
|
| 130 |
max_frame_count = 200
|
| 131 |
+
if os.path.isdir(outdir+item):
|
| 132 |
+
for filename in os.listdir(outdir+item):
|
| 133 |
+
img = Image.open(outdir+item+'/'+filename)
|
| 134 |
if filename.startswith('result_'):
|
| 135 |
results.append(img)
|
| 136 |
elif filename.startswith('base_'):
|
|
|
|
| 151 |
#results = run(images, video_path, train_steps=100, inference_steps=10, fps=12, bg_remove=False, finetune=True)
|
| 152 |
results, results_base = run_eval(images, video_path, train_steps=100, inference_steps=10, fps=12, modelId="fine_tuned_pcdms", img_width=1920, img_height=1080, bg_remove=False, resize_inputs=False)
|
| 153 |
|
| 154 |
+
os.makedirs(outdir+item, exist_ok=True)
|
| 155 |
|
| 156 |
for i, frame in enumerate(gt_frames):
|
| 157 |
+
frame.save(outdir+item+"/frame_"+str(i)+".png")
|
| 158 |
|
| 159 |
for i, result in enumerate(results):
|
| 160 |
+
result.save(outdir+item+"/result_"+str(i)+".png")
|
| 161 |
|
| 162 |
for i, result in enumerate(results_base):
|
| 163 |
+
result.save(outdir+item+"/base_"+str(i)+".png")
|
| 164 |
|
| 165 |
ssim = []
|
| 166 |
psnr = []
|
outputs/metrics.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{}
|