bjooo commited on
Commit
6c68f8d
·
verified ·
1 Parent(s): 89660de

Delete arch_logic_v16.py

Browse files
Files changed (1) hide show
  1. arch_logic_v16.py +0 -87
arch_logic_v16.py DELETED
@@ -1,87 +0,0 @@
1
- import os
2
- import comfy.sd
3
- import comfy.utils
4
- import folder_paths
5
- import json
6
- import urllib.request
7
- import urllib.parse
8
-
9
- _TRIPLE_LORA_CACHE = {}
10
- CACHE_FILE = os.path.join(os.path.dirname(__file__), "dolphin_lora_trigger_cache.json")
11
-
12
- def get_trigger_words(lora_name):
13
- if lora_name == "None": return []
14
- cache = {}
15
- if os.path.exists(CACHE_FILE):
16
- try:
17
- with open(CACHE_FILE, "r") as f: cache = json.load(f)
18
- except: pass
19
- if lora_name in cache: return cache[lora_name]
20
-
21
- try:
22
- # 💡 요청하신 civitaired.com 도메인 API로 변경
23
- # API 구조가 civitai.com과 동일하다는 가정하에 쿼리 매개변수 적용
24
- query = urllib.parse.quote(lora_name.replace(".safetensors", ""))
25
- url = f"https://civitaired.com/api/v1/model-versions/by-file?query={query}"
26
-
27
- req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'})
28
- with urllib.request.urlopen(req, timeout=5) as res:
29
- data = json.load(res)
30
- # trainedWords 키는 동일하게 유지
31
- triggers = data.get("trainedWords", [])
32
- cache[lora_name] = triggers
33
- with open(CACHE_FILE, "w") as f: json.dump(cache, f)
34
- return triggers
35
- except Exception as e:
36
- print(f"⚠️ [Dolphin] civitaired.com 트리거 워드 조회 실패: {e}")
37
- return []
38
-
39
- class DolphinTripleLoraMatrix:
40
- @classmethod
41
- def INPUT_TYPES(s):
42
- loras = ["None"] + folder_paths.get_filename_list("loras")
43
- inputs = {
44
- "model_base": ("MODEL",), "clip_base": ("CLIP",),
45
- "model_high": ("MODEL",), "clip_high": ("CLIP",),
46
- "model_low": ("MODEL",), "clip_low": ("CLIP",),
47
- }
48
- for i in range(1, 7):
49
- inputs[f"lora_{i}"] = (loras, {"default": "None"})
50
- inputs[f"weights_{i}"] = ("STRING", {"default": "0.0, 0.0, 0.0"})
51
- return {"required": inputs}
52
-
53
- RETURN_TYPES = ("MODEL", "CLIP", "MODEL", "CLIP", "MODEL", "CLIP", "STRING")
54
- RETURN_NAMES = ("M_BASE", "C_BASE", "M_HIGH", "C_HIGH", "M_LOW", "C_LOW", "trigger_words")
55
- FUNCTION = "apply_matrix"
56
- CATEGORY = "Dolphin"
57
-
58
- def apply_matrix(self, model_base, clip_base, model_high, clip_high, model_low, clip_low, **kwargs):
59
- m_b, c_b = model_base, clip_base
60
- m_h, c_h = model_high, clip_high
61
- m_l, c_l = model_low, clip_low
62
- all_triggers = []
63
-
64
- for i in range(1, 7):
65
- lora_name = kwargs.get(f"lora_{i}")
66
- w_str = kwargs.get(f"weights_{i}")
67
-
68
- if lora_name == "None": continue
69
-
70
- # 트리거 워드 수집 (civitaired.com 연동)
71
- all_triggers.extend(get_trigger_words(lora_name))
72
-
73
- try:
74
- parts = [float(x.strip()) for x in w_str.split(',')]
75
- wb, wh, wl = parts[0], parts[1], parts[2]
76
- except: continue
77
-
78
- if lora_name not in _TRIPLE_LORA_CACHE:
79
- path = folder_paths.get_full_path("loras", lora_name)
80
- _TRIPLE_LORA_CACHE[lora_name] = comfy.utils.load_torch_file(path)
81
- data = _TRIPLE_LORA_CACHE[lora_name]
82
-
83
- if wb != 0: m_b, c_b = comfy.sd.load_lora_for_models(m_b, c_b, data, wb, wb)
84
- if wh != 0: m_h, c_h = comfy.sd.load_lora_for_models(m_h, c_h, data, wh, wh)
85
- if wl != 0: m_l, c_l = comfy.sd.load_lora_for_models(m_l, c_l, data, wl, wl)
86
-
87
- return (m_b, c_b, m_h, c_h, m_l, c_l, ", ".join(list(set(all_triggers))))