Skip to content

Instantly share code, notes, and snippets.

@david-littlefield
Last active November 6, 2020 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save david-littlefield/f1536abb4117aa3f857064dcbbd10208 to your computer and use it in GitHub Desktop.
Save david-littlefield/f1536abb4117aa3f857064dcbbd10208 to your computer and use it in GitHub Desktop.
# Line 61
def detect_face(image, shrink):
x = image
if shrink != 1:
x = cv2.resize(image, None, None, fx=shrink, fy=shrink, interpolation=cv2.INTER_LINEAR)
#print('shrink:{}'.format(shrink))
width = x.shape[1]
height = x.shape[0]
x = x.astype(np.float32)
x -= np.array([104, 117, 123],dtype=np.float32)
x = torch.from_numpy(x).permute(2, 0, 1)
x = x.unsqueeze(0)
with torch.no_grad(): # <----------
x = Variable(x.cuda()) # <----------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment