1 Star 2 Fork 0

吴起乐/ManTra-Net-pytorch

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
evaluation.py 1.32 KB
一键复制 编辑 原始数据 按行查看 历史
吴起乐 提交于 2年前 . last commit
from MantraNet.mantranet2 import pre_trained_model, check_forgery
import os
import glob
import numpy as np
import cv2
from sklearn.metrics import roc_auc_score
device = "cuda:0" # to change if you have a GPU with at least 12Go RAM (it will save you a lot of time !)
MantraNetmodel = pre_trained_model(
weight_path="MantraNet/MantraNetv4.pt", device=device
)
MantraNetmodel.eval()
root1 = r"F:\wql-Graduate\fuxian\IMD-main\COVERAGE\image"
root2 = r"F:\wql-Graduate\fuxian\IMD-main\COVERAGE\mask"
dir1 = os.listdir(root1)
dir2 = os.listdir(root2)
forged_dir1 = glob.glob(os.path.join(root1,"*t.tif"))
forged_dir2 = glob.glob(os.path.join(root2,"*forged.tif"))
all_score = 0
count = 0
for img_path,forged_path in zip(forged_dir1,forged_dir2):
fig = check_forgery(MantraNetmodel, img_path=img_path, device=device)
fig = np.asarray(fig).reshape(-1)
im = cv2.imread(forged_path)
imGray = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
imGray = imGray / 255
imGray = imGray.reshape(-1)
# fig.savefig(r'F:\wql-Graduate\fuxian\IMD-main\images_out\example4_result.jpg')
if fig.shape[0]== imGray.shape[0]:
score = roc_auc_score(imGray, fig)
print("roc score is",score)
all_score += score
count += 1
else:
print(img_path,forged_path)
avg_auc_score = all_score / 100
print(avg_auc_score)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wu_qile/ManTra-net-pytorch.git
git@gitee.com:wu_qile/ManTra-net-pytorch.git
wu_qile
ManTra-net-pytorch
ManTra-Net-pytorch
master

搜索帮助