Engineer-of-Stuff / stable-diffusion-paperspace

Jupyter notebooks for Paperspace.
The Unlicense
289 stars 110 forks source link

CivitAI Automated Model Downloader #53

Closed personxyz closed 1 year ago

personxyz commented 1 year ago

Hi,

First up I acknowledge this is almost certainly an issue of my own making, I’m not very technical.

I was setting things up today on Paperspace and reached the “Automated Model Downloader” cell. My internet sucks so it’s perfect for me but I can’t get it to work

I assumed you added the model URL to the below part (between the colon and the second apostrophe):

model_uri = input(‘URI of model to download: ‘) import re import requests import gdown

However, when I do that and execute the cell a download bar appears but it never actually moves. It’s stuck on zero.

Do you know what I’m doing wrong? Say I want to download a model from CivitAI. I’ve tried using the model page: https://civitai.com/models/3850/kenshi

That didn't work so I tried using the download button web link: https://civitai.com/api/download/models/4277

That didn't work either. Am I placing them in the wrong part of the cell or should the URI I use be something else. It’s so frustrating as I’m one step away from being able to use stable diffusion for the first time!

Any help would be massively appreciated. Like I said, I’m not great with tech so this is likely some rookie mistake on my part.

Cyberes commented 1 year ago

No, just run the block and don't edit anything in it. A little textbox will appear below it which is where you put your model URL (I think that's the download bar you are referring to).

The downloader doesn't support civitai.com right now but maybe I can find the time to add it? A way to get around this is to start the download on your personal computer then go to the browser's download manager and copy the download link. Then put that URL into the model downloader and it should work. (and then cancel the download to your computer)

personxyz commented 1 year ago

Lol, I'm so dumb. Thanks for the quick response and the tip for downloading from CivitAi. If you do find the time to add civit that would be awesome considering most of the top models get posted on there but no worries if you're busy, you've already made something incredibly useful.

I'll close this issue. Thanks again.

Cyberes commented 1 year ago

Great! Glad you got it working. I'll leave the issue open so that I remember to do this.

personxyz commented 1 year ago

Hi again, sadly I'm back lol.

I'm having trouble downloading from huggingface. This time I've attached a screenshot to better illustrate the issue. I ran the cell like you said, entered my huggingface url into the box that appeared and pressed Shift+Enter. All it did was create a blank block underneath (shown in the attached screenshot).

I've probably messed something up again but can't figure out what. Do you have any ideas?

paperspace notebook

Cyberes commented 1 year ago

No, wrong box. You want to run the cell first and then this box will pop up.

Screenshot 2023-01-12 at 11-24-51 MAIN StableD… - JupyterLab

Your model link goes here.

Screenshot 2023-01-12 at 11-26-13 MAIN StableD… - JupyterLab

personxyz commented 1 year ago

Weird, that box doesn't appear for me when I run the block. Maybe I broke it when I was messing around earlier. I might just reinstall the notebook from scratch tomorrow and see if it works then. I'll report back.

personxyz commented 1 year ago

OK, I finally worked it out. Because the Automated Model Downloader section is right at the bottom of the notebook I was running it last, after cleaning up and restarting the kernel + linking the models directory.

I didn't realize you couldn't do things in that order and that's why the model downloader block wouldn't work properly. Like I said, the box in your screenshot never popped up for me.

I've just tried again and it worked! I'm currently downloading a model from huggingfaces and everything seems to be going smoothly. Apologies for taking some of your time on such a trivial matter but at least it's resolved now.

Thanks again!

Cyberes commented 1 year ago

Glad you got it working.

Everything should work after you run the cleanup+kernel restart since the variables are cached in %store. I suspect your kernel froze, next time you can try force-restarting it in Kernel > Shutdown all kernels.

personxyz commented 1 year ago

Just out of interest, does the Automated Model Downloader work with .safetensor files as well as .ckpt?

I ask because the "Link the models directory" block doesn't have a section for safetensor files. It only says Link .ckpt files.

Cyberes commented 1 year ago

It should. I guess I should update the linker.

personxyz commented 1 year ago

I just tried it out of curiosity, when I finished downloading the safetensor file I ran the linking models directory block but nothing new happened. I don't think it recognized the file because it ended in .safetensor. The model didn't load in SD either.

Who knows though, maybe I've done something wrong again!

personxyz commented 1 year ago

I got it to work by adding some more code to the linking models directory block. I basically copied the .ckpt part but replaced each .ckpt with .safetensors (screenshot below).

Miraculously it worked. safetensors code

Cyberes commented 1 year ago

Nice! That's the right way to do it.

Cyberes commented 1 year ago

Closed by https://github.com/Engineer-of-Stuff/stable-diffusion-paperspace/commit/7117369ba1615768d882c0f1af1831159950f2c4 with fixes to CivitAI and .safetensor files.

personxyz commented 1 year ago

Hi again,

I thought I'd try out the new Civit download option today but sadly it didn't work. First I updated the notebook and that seemed to work fine as shown by the below screenshot.

newnotebook

I refreshed the page but when I tried to download something from Civit I got the following error message.

civiterror

There's definitely a chance the error is my fault but do you have any ideas what went wrong?

Cyberes commented 1 year ago

Can I have the link? I got that error earlier and it may be because their backend might be having issues?

personxyz commented 1 year ago

Here's the link: https://civitai.com/api/download/models/5848

I don't think it was their backend as I started downloading a model right after I couldn't get the notebook downloader to work. It took 6 hours (because my internet sucks) but it downloaded successfully.

Cyberes commented 1 year ago

Their CDN wasn't responding correctly to HEAD requests. Fixed in abca842b30a4317462ca605ae90b709af93baa33.

personxyz commented 1 year ago

Hi Cyberes,

Sadly it still doesn't work. I tried it with 4 different Civit models, each time I got the following error (attached as two screenshots due to length).

ErrorScreenshotOne ErrorScreenshotTwo

Cyberes commented 1 year ago

Fixed.

personxyz commented 1 year ago

Haven't tested if the Civit downloader works for now as something else has come up. I tried to run the "Launch the WebUI" block and got the following error message:

LaunchError

Sorry about all these issues dude, I really appreciate your help :)

Cyberes commented 1 year ago

Try updating the notebook. The WebUI needs a specific version of PyTorch so I added a line to uninstall it before running the WebUI installer.

personxyz commented 1 year ago

Just updated the notebook and it works. I tried the Civit downloader and it works too! Downloaded a 3.9 GB model in 10 seconds, that's absolutely insane compared to my internet speed.

Thanks so much for the help, another great feature added to an already awesome notebook!

Cyberes commented 1 year ago

Great! Glad you got it working.