Skip to content

Instantly share code, notes, and snippets.

View david-littlefield's full-sized avatar

david-littlefield

View GitHub Profile
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib/modules \
-D PYTHON3_LIBRARY=`python -c 'import subprocess ; import sys ; s = subprocess.check_output("python-config --configdir", shell=True).decode("utf-8").strip() ; (M, m) = sys.version_info[:2] ; print("{}/libpython{}.{}.dylib".format(s, M, m))'` \
-D PYTHON3_INCLUDE_DIR=`python -c 'import distutils.sysconfig as s; print(s.get_python_inc())'` \
-D PYTHON3_EXECUTABLE=$VIRTUAL_ENV/bin/python \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_python3=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_C_EXAMPLES=OFF \
parser = argparse.ArgumentParser(description='DSFD:Dual Shot Face Detector')
parser.add_argument('--trained_model', default='weights/WIDERFace_DSFD_RES152.pth',
type=str, help='Trained state_dict file path to open')
parser.add_argument('--save_folder', default='eval_tools/', type=str,
help='Dir to save results')
parser.add_argument('--visual_threshold', default=0.1, type=float,
help='Final confidence threshold')
parser.add_argument('--cuda', default=False, type=bool,
help='Use cuda to train model')
{
"NotebookApp": {
"open_browser": false,
"port": 8888,
"ip": "0.0.0.0",
"allow_origin": "*",
"notebook_dir": "/mnt/c/users/admin/",
"certfile": "/home/user/.jupyter/mycert.pem",
"keyfile": "/home/user/.jupyter/mykey.key",
"allow_remote_access": true,
# Line 29
from widerface_val import bbox_vote
from warnings import filterwarnings # <----------
filterwarnings("ignore") # <----------
plt.switch_backend('agg')
# Line 231
# load net
cfg = widerface_640
num_classes = len(WIDERFace_CLASSES) + 1 # +1 background
net = build_ssd('test', cfg['min_dim'], num_classes) # initialize SSD
net.load_state_dict(torch.load(args.trained_model))
#net.cuda() # <----------
# Line 75
def infer(net , img , transform , thresh , cuda , shrink):
if shrink != 1:
img = cv2.resize(img, None, None, fx=shrink, fy=shrink, interpolation=cv2.INTER_LINEAR)
x = torch.from_numpy(transform(img)[0]).permute(2, 0, 1)
with torch.no_grad():
x = Variable(x.unsqueeze(0))
#if cuda: # <----------
# x = x.cuda() # <----------
# Line 207
def load(f, map_location="cpu", pickle_module=pickle): # <----------
# Line 83
while detections[0, i, j, 0] >= thresh:
score = detections[0, i, j, 0]
score = score.cpu().numpy() # <----------
#label_name = labelmap[i-1]
pt = (detections[0, i, j, 1:]*scale).cpu().numpy()
coords = (pt[0], pt[1], pt[2], pt[3])
det.append([pt[0], pt[1], pt[2], pt[3], score])
j += 1
# Line 13
from data import widerface_640
from ..box_utils import log_sum_exp, match, refine_match, sfd_match # <----------
# Line 25
WIDERFace_CLASSES = ['face'] # always index 0
# note: if you used our download scripts, this should be right
WIDERFace_ROOT = './data/ # <----------