-
Notifications
You must be signed in to change notification settings - Fork 271
Open
Description
import cv2
import torch
import torchvision.transforms as transforms
Load the pre-trained model
model = torch.load("hrnetv2_w18_imagenet_pretrained.pth")
Load and preprocess the input image
image = cv2.imread("images.jpg")
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) # Convert BGR to RGB
image = transforms.ToTensor()(image) # Convert image to tensor
image = transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])(image) # Normalize the image
Run the inference
output = model.forward(image)
I try something like these, but it doens't work, how to use the pre-trained model directly and detect the face in a image?
Thank you
Metadata
Metadata
Assignees
Labels
No labels