forked from netabecker/Stegastamp_pytorch_version
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathaccuracy_test.py
31 lines (26 loc) · 1.05 KB
/
accuracy_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import os
import yaml
import glob
import numpy as np
import torch
from torchvision import transforms
from PIL import Image, ImageOps
import matplotlib.pyplot as plt
from easydict import EasyDict
"""
Run this test in order to check if the model was successful
in encoding and decoding the images
"""
with open('cfg/setting.yaml', 'r') as f:
param = EasyDict(yaml.load(f, Loader=yaml.SafeLoader))
def main():
enc_model = os.path.join(param.checkpoints_path, "encoder_best_secret_loss.pth")
dec_model = os.path.join(param.checkpoints_path, "decoder_best_secret_loss.pth")
save_dir = os.path.join("./image"+enc_model[27:-12])
if not os.path.exists(save_dir):
os.makedirs(save_dir)
test_image = os.path.join("./small_images_dir")
os.system("python encode_image.py "+enc_model+" --images_dir="+test_image+" --secret=abcdefg "+"--save_dir="+save_dir)
os.system("python decode_image.py " + dec_model + " --images_dir=" + save_dir + " > " + save_dir + "/summary.txt")
if __name__ == "__main__":
main()