Instructions to use georgefen/Face-Landmark-ControlNet with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use georgefen/Face-Landmark-ControlNet with Diffusers:
pip install -U diffusers transformers accelerate
from diffusers import ControlNetModel, StableDiffusionControlNetPipeline controlnet = ControlNetModel.from_pretrained("georgefen/Face-Landmark-ControlNet") pipe = StableDiffusionControlNetPipeline.from_pretrained( "fill-in-base-model", controlnet=controlnet ) - Notebooks
- Google Colab
- Kaggle
Download cldm/model.py from georgefen/Face-Landmark-ControlNet: direct link, hf CLI and curl.
- Browser
- Download file 836 Bytes
-
https://huggingface.co/georgefen/Face-Landmark-ControlNet/resolve/refs%2Fpr%2F6/cldm/model.py
- Command line
-
hf download hf://georgefen/Face-Landmark-ControlNet@refs/pr/6/cldm/model.py
-
curl -L -o model.py https://huggingface.co/georgefen/Face-Landmark-ControlNet/resolve/refs%2Fpr%2F6/cldm/model.py
836 Bytes
| import os | |
| import torch | |
| from omegaconf import OmegaConf | |
| from ldm.util import instantiate_from_config | |
| def get_state_dict(d): | |
| return d.get('state_dict', d) | |
| def load_state_dict(ckpt_path, location='cpu'): | |
| _, extension = os.path.splitext(ckpt_path) | |
| if extension.lower() == ".safetensors": | |
| import safetensors.torch | |
| state_dict = safetensors.torch.load_file(ckpt_path, device=location) | |
| else: | |
| state_dict = get_state_dict(torch.load(ckpt_path, map_location=torch.device(location))) | |
| state_dict = get_state_dict(state_dict) | |
| print(f'Loaded state_dict from [{ckpt_path}]') | |
| return state_dict | |
| def create_model(config_path): | |
| config = OmegaConf.load(config_path) | |
| model = instantiate_from_config(config.model).cpu() | |
| print(f'Loaded model config from [{config_path}]') | |
| return model | |