Exemple #1
0
class OnnxModel(nn.Module):
    def __init__(self, **kwargs):
        super(OnnxModel, self).__init__()

        self.model = DBFace(**kwargs)
        self.model.load(f"{jobdir}/models/150.pth")

    def forward(self, x):
        center, box, landmark = self.model(x)
        center_sigmoid = torch.sigmoid(center)
        center_maxpool = F.max_pool2d(center_sigmoid, kernel_size=3, padding=1, stride=1)
        box = torch.exp(box)
        return center_maxpool, box, landmark
Exemple #2
0
import eval_tool
import torch
import torch.nn as nn
import logger
import numpy as np
from dbface import DBFace
from evaluate import evaluation

# create logger
trial_name = "small-H-dense-wide64-UCBA"
jobdir = f"jobs/{trial_name}"
log = logger.create(trial_name, f"{jobdir}/logs/eval.log")

# load and init model
model = DBFace(has_landmark=True, wide=64, has_ext=True, upmode="UCBA")
model.load(f"{jobdir}/models/150.pth")
model.eval()
model.cuda()

# load dataset
mean = [0.408, 0.447, 0.47]
std = [0.289, 0.274, 0.278]
files, anns = zip(
    *common.load_webface("webface/val/label.txt", "webface/WIDER_val/images"))

# forward and summary
prefix = "webface/WIDER_val/images/"
all_result_dict = {}
total_file = len(files)

for i in range(total_file):