Views
No views yet
1import torch
2from PIL import Image
3# Load an image
4input_image = Image.open("path/to/your/image.jpg")
5# Create predictor instance
6predictor = torch.hub.load("hugoycj/StableNormal", "StableNormal_turbo", trust_repo=True, yoso_version='yoso-normal-v1-8-1')
7# Generate normal map using alpha channel for masking
8normal_map = predictor(rgba_image, data_type="object") # Will mask out background, if alpha channel is avalible, else use birefnet
9# Apply the model to the image
10normal_image = predictor(input_image)
11# Save or display the result
12normal_image.save("output/normal_map.png")