civitai / civitai_comfy_nodes

Comfy Nodes that make utilizing resources from Civitas easy as copying and pasting
100 stars 16 forks source link

Parse AIR from CivitAI URL #12

Open Chaoses-Ib opened 7 months ago

Chaoses-Ib commented 7 months ago

I noticed that the model id and version id can be found in CivitAI's URL to the model. For example, the AIR of https://civitai.com/models/101055?modelVersionId=128078 is 101055@128078. Compared to using AIR, using URL is more self-explanatory and can be easily accessed. Also, there is no need to change settings to copy AIR. So how about making the loaders also accept a CivitAI URL to specify the AIR?

Chaoses-Ib commented 3 months ago

I've already implemented this in my fork. If you are interested, please let me know and I will make a PR.

WASasquatch commented 3 months ago

Oh how ironic. I was just looking at adding this. Things got wonky, so I'd be interested to see your fork, can you link me?

Granted I didn't spend much time, but the version ID on the URLs is apparently different from the model versions (it's a file version I think), so I had to change a conditional.

https://github.com/civitai/civitai_comfy_nodes/pull/22

Chaoses-Ib commented 3 months ago

https://github.com/Chaoses-Ib/civitai_comfy_nodes/commit/a7dc9883d2063a9869cc68094759cdca370cb49a

I used a complex regex and didn't consider the case modelVersionId missing since I wanted to prevent myself from using a URL without the version. Your implementation looks better.

but the version ID on the URLs is apparently different from the model versions (it's a file version I think)

I don't get what you mean. They are always the same from what I can see. For example, https://civitai.com/models/101055?modelVersionId=128080:

image

Chaoses-Ib commented 3 months ago

By the way, as you may already know, the URL can be in two forms:

The sd-xl in the latter form actually can be arbitrary text, so it can be used as a comment by the user.

WASasquatch commented 3 months ago

The issue I was having, is after I parsed the model ID out, and the version ID out, it was finding no "files" matching the version (although printing the version pairs did yield a match to the files). So I had to add a condition that if the model_download_url is found, then we assume there is file info, and then proceed. Before it was explicitly looking for a if version_id == self.version and files