bes-dev / stable_diffusion.openvino

Apache License 2.0
1.54k stars 206 forks source link

how to use a model from civitai? #157

Open baselqt opened 1 year ago

baselqt commented 1 year ago

i want to use a model from civitai.com which is in .safetensors format. how can i use it with the openvino toolkit ?

RedAndr commented 1 year ago

@baselqt Convert it to OpenVINO IR format following the tutorial here: https://docs.openvino.ai/2023.1/notebooks/225-stable-diffusion-text-to-image-with-output.html And modify with the following code:

pipe1 = StableDiffusionPipeline.from_single_file('path/model.safetensors')
pipe = StableDiffusionPipeline.from_pretrained("prompthero/openjourney", unet=pipe1.unet).to("cpu")
homevk15 commented 8 months ago

@RedAndr Could you post a whole code how to convert a downloaded civitai model (based on Stable Diffusion 1-5) to OpenVINO? It would help people a lot.

baselqt commented 8 months ago

@RedAndr i don't remember where anymore but you have to use stable diffusion notebook or tinysd notebook from openvino notebooks

you can go to huggingface website and search for your model, it has to have the diffusers tag with it, then copy the parts in the link before and after the last / for example https://huggingface.co/Yntec/epiCPhotoGasm will be Yntec/epiCPhotoGasm

and then place this in a part of the code in the jupiter notebook where it has a similar syntax, i dont really remeber it exactly but it should have the name /stablediffusion or something, its in the downloading models part

and run the cells one by one from the beggining hope this helps

RedAndr commented 8 months ago

@homevk15 Sure, here's my code: https://github.com/RedAndr/SD_PyTorch2ONNX/blob/main/Convert_Civitai_OpenVINO.py Let me know if it doesn't work for you.