mhh0318 / OneMoreStep

19 stars 1 forks source link

NameError: name 'get_class_obj_and_candidates' is not defined #2

Closed ZhuangLii closed 2 months ago

ZhuangLii commented 2 months ago

Hi there, how should I solve this problem NameError: name 'get_class_obj_and_candidates' is not defined

mhh0318 commented 2 months ago

may I know more detail? Currently it seems need specify get_class_obj_and_candidates when you pass sth to the UNet.

ZhuangLii commented 2 months ago

Thank you for your timely response. https://github.com/mhh0318/OneMoreStep/blob/b662f84a7d2f0b636d9ce13cb97f72857c6c56e2/diffusers_patch/pipelines/oms/pipeline_oms.py#L53 I tried to call this function but it seems not to be imported.

ZhuangLii commented 2 months ago

Thank you for your timely response.

https://github.com/mhh0318/OneMoreStep/blob/b662f84a7d2f0b636d9ce13cb97f72857c6c56e2/diffusers_patch/pipelines/oms/pipeline_oms.py#L53

I tried to call this function but it seems not to be imported.

i I encountered this error when I was running the demo_sd15_sd21.py. `from diffusers_patch import OMSPipeline

import torch from diffusers import StableDiffusionPipeline

sd_pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16, variant="fp16",safety_checker=None).to('cuda') print('successfully load pipe')

pipe = OMSPipeline.from_pretrained('h1t/oms_b_openclip_15_21', sd_pipeline = sd_pipe, torch_dtype=torch.float16, variant="fp16", trust_remote_code=True) pipe.to('cuda')

generator = torch.Generator(device=pipe.device).manual_seed(100)

prompt = "a starry night"

image = pipe(prompt, guidance_scale=7.5, num_inference_steps=20, oms_guidance_scale=1., generator=generator)

image['images'][0].save('sd15_oms_ng.png')

image = pipe(prompt, guidance_scale=7.5, num_inference_steps=20, oms_guidance_scale=1., generator=generator, oms_flag=False)

image['images'][0].save('sd15_wo_oms.png')`

mhh0318 commented 2 months ago

Oh that's because the diffusers are various in different versions. I forgot to provide a requirement file for this project.

You could try pip install diffusers==0.23.0 .

ZhuangLii commented 2 months ago

thanks, it works, the module is indeed effective, not only improving the image contrast but also enhancing the image quality, impressive work.