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

[feature request] how to preload lineart preprocessor model #482

Open
t00350320 opened this issue Nov 11, 2024 · 0 comments
Open

[feature request] how to preload lineart preprocessor model #482

t00350320 opened this issue Nov 11, 2024 · 0 comments

Comments

@t00350320
Copy link

t00350320 commented Nov 11, 2024

can anyone has a controlnmet_aux's preload function for preprocessors of lineart and depth ,etc, thanks a lot!!!

class LineartDetector:
    def __init__(self, model, coarse_model):
        self.model = model
        self.model_coarse = coarse_model
        self.device = "cuda:0"
        print("test0,controlnet_aux,LineartDetector,cuda0:{}",time.ctime())
    @classmethod
    def from_pretrained(cls, pretrained_model_or_path=HF_MODEL_NAME, filename="sk_model.pth", coarse_filename="sk_model2.pth"):
        print("test0,controlnet_aux,LineartDetector,from_pretrained,cuda0:{}",time.ctime())
        model_path = custom_hf_download(pretrained_model_or_path, filename)
        coarse_model_path = custom_hf_download(pretrained_model_or_path, coarse_filename)

        model = Generator(3, 1, 3)
        model.load_state_dict(torch.load(model_path, map_location=torch.device('cuda:0')))
        model.eval()

        coarse_model = Generator(3, 1, 3)
        coarse_model.load_state_dict(torch.load(coarse_model_path, map_location=torch.device('cuda:0')))
        coarse_model.eval()

        return cls(model, coarse_model)
@t00350320 t00350320 changed the title [feature request] how to preload lineart model [feature request] how to preload lineart preprocessor model Nov 11, 2024
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