Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use this pre-trainmodel? #96

Open
EZEROR opened this issue Jun 7, 2024 · 0 comments
Open

How to use this pre-trainmodel? #96

EZEROR opened this issue Jun 7, 2024 · 0 comments

Comments

@EZEROR
Copy link

EZEROR commented Jun 7, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant