Skip to content

How to use this pre-trainmodel? #96

@EZEROR

Description

@EZEROR

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions