cowpuncher's picture
download
raw
28.4 kB
"""Checkpoint tab: looks each checkpoint / diffusion model up on Civitai (by hash) and Hugging Face (hash-verified
repo search), mines the author's recommended positive / negative prompts and settings out of the pages, and can
turn the result into a new AI Image Diffusion style."""
import re
import time
from pathlib import Path
try:
from PyQt5.QtCore import Qt, QThread, QUrl, pyqtSignal
from PyQt5.QtGui import QDesktopServices
from PyQt5.QtWidgets import (
QApplication, QComboBox, QDialog, QDialogButtonBox, QFormLayout, QGroupBox, QHBoxLayout, QLabel, QLineEdit,
QListWidget, QListWidgetItem, QPlainTextEdit, QPushButton, QScrollArea, QVBoxLayout, QWidget,
)
except ImportError: # Krita 6
from PyQt6.QtCore import Qt, QThread, QUrl, pyqtSignal
from PyQt6.QtGui import QDesktopServices
from PyQt6.QtWidgets import (
QApplication, QComboBox, QDialog, QDialogButtonBox, QFormLayout, QGroupBox, QHBoxLayout, QLabel, QLineEdit,
QListWidget, QListWidgetItem, QPlainTextEdit, QPushButton, QScrollArea, QVBoxLayout, QWidget,
)
from . import core
def _open(url):
if url:
QDesktopServices.openUrl(QUrl(url))
class CheckpointWorker(QThread):
progress = pyqtSignal(str)
result = pyqtSignal(str, dict)
finished_all = pyqtSignal()
def __init__(self, jobs, hash_cache, ck_cache, cache_paths, token, parent=None):
super().__init__(parent)
self.jobs = jobs # (file_id, Path)
self.hash_cache, self.ck_cache = hash_cache, ck_cache
self.hash_cache_path, self.ck_cache_path = cache_paths
self.token = token
def run(self):
for file_id, path in self.jobs:
try:
self.progress.emit(f"hashing {path.name} (a 6 GB file takes a while) ...")
digest = core.sha256_of(path, self.hash_cache)
core.save_json(self.hash_cache_path, self.hash_cache)
entry = core.build_checkpoint_entry(path, file_id, digest, self.token, self.progress.emit)
except Exception as e:
entry = {"status": f"{type(e).__name__}: {e}"}
self.ck_cache[str(path)] = entry
core.save_json(self.ck_cache_path, self.ck_cache)
self.result.emit(file_id, entry)
if len(self.jobs) > 1:
time.sleep(0.6)
self.finished_all.emit()
class HFWorker(QThread):
done = pyqtSignal(str, object, str) # file id, hf entry or None, status
def __init__(self, file_id, repo, sha256, token, parent=None):
super().__init__(parent)
self.file_id, self.repo, self.sha256, self.token = file_id, repo, sha256, token
def run(self):
try:
hf = core.hf_manual(self.repo, self.sha256, self.token)
status = ("hash verified in " if hf["verified"] else "name match only (hash not in) ") + hf["repo"]
self.done.emit(self.file_id, hf, status)
except Exception as e:
self.done.emit(self.file_id, None, f"{type(e).__name__}: {e}")
class HFPickDialog(QDialog):
"""Pick / search a Hugging Face repo for the selected file."""
def __init__(self, file_id, candidates, token, parent=None):
super().__init__(parent)
self.setWindowTitle(f"Hugging Face repo for {Path(file_id).name}")
self.resize(620, 420)
self.token = token
self.choice = ""
lay = QVBoxLayout(self)
lay.addWidget(QLabel("Repo id (owner/name) or a huggingface.co link:"))
self.repo = QLineEdit()
lay.addWidget(self.repo)
row = QHBoxLayout()
qs = core.name_queries(file_id)
self.query = QLineEdit(qs[1] if len(qs) > 1 else (qs[0] if qs else ""))
b_search = QPushButton("Search")
row.addWidget(QLabel("Search:"))
row.addWidget(self.query, 1)
row.addWidget(b_search)
lay.addLayout(row)
self.list = QListWidget()
for c in candidates:
self.list.addItem(c)
lay.addWidget(self.list, 1)
self.note = QLabel("Candidates above came from the Civitai page links and name searches (none had a matching file hash). "
"The model card of whatever you pick is used; 'verified' means the hash was found in that repo.")
self.note.setWordWrap(True)
lay.addWidget(self.note)
bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)
bb.accepted.connect(self.accept)
bb.rejected.connect(self.reject)
lay.addWidget(bb)
b_search.clicked.connect(self.search)
self.list.currentTextChanged.connect(self.repo.setText)
def search(self):
self.list.clear()
try:
for r in core.hf_search(self.query.text().strip(), limit=12, token=self.token):
self.list.addItem(r)
if self.list.count() == 0:
self.note.setText("No repos matched that search.")
except Exception as e:
self.note.setText(f"Search failed: {type(e).__name__}: {e}")
def accept(self):
self.choice = self.repo.text().strip()
super().accept()
class CandidateRow(QGroupBox):
use = pyqtSignal(str, str) # kind, text
def __init__(self, cand, parent=None):
super().__init__(f"{cand['kind']} — {cand['source']}", parent)
lay = QHBoxLayout(self)
box = QPlainTextEdit(cand["text"])
box.setReadOnly(True)
box.setMaximumHeight(64)
lay.addWidget(box, 1)
col = QVBoxLayout()
if cand["kind"] == "settings":
b = QPushButton("→ settings")
b.clicked.connect(lambda _=False: self.use.emit("settings", cand["text"]))
col.addWidget(b)
else:
bp, bn = QPushButton("→ positive"), QPushButton("→ negative")
bp.clicked.connect(lambda _=False: self.use.emit("positive", cand["text"]))
bn.clicked.connect(lambda _=False: self.use.emit("negative", cand["text"]))
col.addWidget(bp)
col.addWidget(bn)
col.addStretch()
lay.addLayout(col)
class SaveStyleDialog(QDialog):
def __init__(self, file_id, name, positive, negative, settings, presets, parent=None):
super().__init__(parent)
self.setWindowTitle("New AI Image Diffusion style")
self.resize(640, 420)
form = QFormLayout(self)
self.name = QLineEdit(name)
form.addRow("Style name", self.name)
form.addRow("Checkpoint", QLabel(file_id))
self.style_prompt = QPlainTextEdit((positive + ", {prompt}") if positive else "{prompt}")
self.style_prompt.setMaximumHeight(70)
form.addRow("Style prompt", self.style_prompt)
self.negative = QPlainTextEdit(negative)
self.negative.setMaximumHeight(70)
form.addRow("Negative prompt", self.negative)
self.sampler = QComboBox()
self.sampler.addItems(presets)
want = str(settings.get("sampler") or "")
comfy, sched = core.sampler_to_comfy(want)
idx = _match_preset(presets, comfy, sched)
if idx >= 0:
self.sampler.setCurrentIndex(idx)
form.addRow(f"Sampler preset (page said: {want or 'nothing'})", self.sampler)
self.steps = QLineEdit(str(settings.get("steps") or ""))
form.addRow("Steps (blank = preset default)", self.steps)
self.cfg = QLineEdit(str(settings.get("cfg") or ""))
form.addRow("CFG (blank = preset default)", self.cfg)
self.clip = QLineEdit(str(settings.get("clip_skip") or ""))
form.addRow("Clip skip (blank = 1)", self.clip)
note = QLabel("Writes a new .json into the AI plugin's styles folder and reloads the style list. Nothing existing is touched.")
note.setWordWrap(True)
form.addRow(note)
bb = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)
bb.accepted.connect(self.accept)
bb.rejected.connect(self.reject)
form.addRow(bb)
def _match_preset(preset_names, comfy, sched):
"""Index of the sampler preset that matches a ComfyUI sampler/scheduler pair, or -1."""
try:
from ai_diffusion.style import SamplerPresets # type: ignore
presets = getattr(SamplerPresets.instance(), "_presets", {})
except Exception:
return -1
if not comfy:
return -1
best = -1
for i, n in enumerate(preset_names):
p = presets.get(n)
if p is None or getattr(p, "hidden", False):
continue
if p.sampler == comfy and p.scheduler == sched:
return i
if p.sampler == comfy and best < 0:
best = i
return best
class CheckpointsPanel(QWidget):
def __init__(self, root, settings, cache_dir, hash_cache, hash_cache_path, parent=None):
super().__init__(parent)
self.root, self.settings = root, settings
self.cache_dir = Path(cache_dir)
self.hash_cache, self.hash_cache_path = hash_cache, hash_cache_path
self.ck_cache_path = self.cache_dir / "checkpoints.json"
self.picks_path = self.cache_dir / "checkpoint_picks.json"
self.prefs_path = self.cache_dir / "prefs.json"
self.ck_cache = core.load_json(self.ck_cache_path, {})
self.picks = core.load_json(self.picks_path, {})
self.prefs = core.load_json(self.prefs_path, {})
self._worker = self._hf_worker = None
self._current_id = None
self._rows = []
main = QHBoxLayout(self)
left, right = QVBoxLayout(), QVBoxLayout()
main.addLayout(left, 2)
main.addLayout(right, 4)
left.addWidget(QLabel("Model folders (separate with ; — checkpoints and diffusion_models):"))
server = Path(self.settings.server_path)
default_roots = ";".join(str(server / "models" / d) for d in ("checkpoints", "diffusion_models", "unet"))
self.roots_edit = QLineEdit(self.prefs.get("roots") or default_roots)
left.addWidget(self.roots_edit)
left.addWidget(QLabel("Checkpoints known to AI Image Diffusion:"))
self.list = QListWidget()
left.addWidget(self.list, 1)
left.addWidget(QLabel("Hugging Face token (optional, only needed for gated model cards):"))
self.token_edit = QLineEdit(self.prefs.get("hf_token", ""))
self.token_edit.setEchoMode(QLineEdit.EchoMode.Password)
left.addWidget(self.token_edit)
self.status = QLabel("Select a checkpoint, or press Fetch all.")
self.status.setWordWrap(True)
left.addWidget(self.status)
self.info = QLabel("")
self.info.setWordWrap(True)
right.addWidget(self.info)
links = QHBoxLayout()
self.civ_btn = QPushButton("Open Civitai page")
self.hf_btn = QPushButton("Open Hugging Face page")
self.hf_pick_btn = QPushButton("Hugging Face: pick / search repo ...")
self.refetch_btn = QPushButton("Re-fetch")
for b in (self.civ_btn, self.hf_btn, self.hf_pick_btn, self.refetch_btn):
links.addWidget(b)
right.addLayout(links)
sug = QGroupBox("Your picks for this checkpoint (prefilled from what the pages say; edit freely)")
sl = QVBoxLayout(sug)
sl.addWidget(QLabel("Positive / quality tags:"))
self.pos = QPlainTextEdit()
self.pos.setMaximumHeight(60)
sl.addWidget(self.pos)
sl.addWidget(QLabel("Negative:"))
self.neg = QPlainTextEdit()
self.neg.setMaximumHeight(60)
sl.addWidget(self.neg)
srow = QHBoxLayout()
self.s_sampler, self.s_steps, self.s_cfg, self.s_clip, self.s_size = (QLineEdit() for _ in range(5))
for label, w, width in (("sampler", self.s_sampler, 170), ("steps", self.s_steps, 60), ("cfg", self.s_cfg, 60),
("clip skip", self.s_clip, 50), ("size", self.s_size, 90)):
srow.addWidget(QLabel(label))
w.setMaximumWidth(width)
srow.addWidget(w)
srow.addStretch()
sl.addLayout(srow)
right.addWidget(sug)
right.addWidget(QLabel("Found on the pages (click → to move one into your picks):"))
self.scroll = QScrollArea()
self.scroll.setWidgetResizable(True)
self.cands_widget = QWidget()
self.cands_layout = QVBoxLayout(self.cands_widget)
self.scroll.setWidget(self.cands_widget)
right.addWidget(self.scroll, 2)
nrow = QHBoxLayout()
nrow.addWidget(QLabel("Author notes (version notes, model page, model card, file metadata):"))
self.find = QLineEdit()
self.find.setPlaceholderText("find in notes ...")
self.find.setMaximumWidth(220)
nrow.addWidget(self.find)
right.addLayout(nrow)
self.notes = QPlainTextEdit()
self.notes.setReadOnly(True)
right.addWidget(self.notes, 2)
btns = QHBoxLayout()
b_cp, b_cn = QPushButton("Copy positive"), QPushButton("Copy negative")
b_style = QPushButton("Save as new style ...")
b_all = QPushButton("Fetch all")
b_report = QPushButton("Write report")
for b in (b_cp, b_cn, b_style, b_all, b_report):
btns.addWidget(b)
right.addLayout(btns)
b_cp.clicked.connect(lambda: QApplication.clipboard().setText(self.pos.toPlainText()))
b_cn.clicked.connect(lambda: QApplication.clipboard().setText(self.neg.toPlainText()))
b_style.clicked.connect(self.save_style)
b_all.clicked.connect(self.fetch_all)
b_report.clicked.connect(self.write_report)
self.civ_btn.clicked.connect(lambda: _open(self._url("civitai")))
self.hf_btn.clicked.connect(lambda: _open(self._url("hf")))
self.hf_pick_btn.clicked.connect(self.pick_hf)
self.refetch_btn.clicked.connect(self.refetch)
self.find.returnPressed.connect(self.find_next)
self.list.currentTextChanged.connect(self.show_file)
self.roots_edit.editingFinished.connect(self.save_prefs)
self.token_edit.editingFinished.connect(self.save_prefs)
self.reload_list()
# ---- data access
def files(self):
return [f for f in self.root.files.checkpoints]
def file_by_id(self, file_id):
return self.root.files.checkpoints.find(file_id)
def roots(self):
return [r.strip() for r in self.roots_edit.text().split(";") if r.strip()]
def path_for(self, f):
return core.resolve_path(f.id, f.path, self.roots())
def token(self):
return self.token_edit.text().strip()
def save_prefs(self):
self.prefs.update({"roots": self.roots_edit.text(), "hf_token": self.token_edit.text()})
core.save_json(self.prefs_path, self.prefs)
def reload_list(self):
self.list.clear()
for f in sorted(self.files(), key=lambda f: f.id.lower()):
self.list.addItem(f.id)
def entry_for(self, file_id):
f = self.file_by_id(file_id)
p = self.path_for(f) if f else None
return (self.ck_cache.get(str(p)) if p else None), p
def _url(self, which):
entry, _ = self.entry_for(self._current_id) if self._current_id else (None, None)
if not entry:
return ""
return ((entry.get("civitai") or {}).get("url") if which == "civitai" else (entry.get("hf") or {}).get("url")) or ""
# ---- picks persistence
def stash(self):
"""Remember what is in the pick boxes for the current file."""
if not self._current_id:
return
entry, p = self.entry_for(self._current_id)
if p is None or not entry:
return
current = {
"positive": self.pos.toPlainText().strip(), "negative": self.neg.toPlainText().strip(),
"sampler": self.s_sampler.text().strip(), "steps": self.s_steps.text().strip(), "cfg": self.s_cfg.text().strip(),
"clip_skip": self.s_clip.text().strip(), "size": self.s_size.text().strip(),
}
auto, _ = core.suggest(entry)
auto = {"positive": auto["positive"].strip(), "negative": auto["negative"].strip(),
**{k: str(auto["settings"].get(k) or "").strip() for k in ("sampler", "steps", "cfg", "clip_skip", "size")}}
if current == auto:
self.picks.pop(str(p), None) # nothing hand-edited: keep following the pages
else:
self.picks[str(p)] = current
core.save_json(self.picks_path, self.picks)
def _fill_picks(self, pick):
self.pos.setPlainText(pick.get("positive", ""))
self.neg.setPlainText(pick.get("negative", ""))
st = pick.get("settings") if "settings" in pick else pick
self.s_sampler.setText(str(st.get("sampler") or ""))
self.s_steps.setText(str(st.get("steps") or ""))
self.s_cfg.setText(str(st.get("cfg") or ""))
self.s_clip.setText(str(st.get("clip_skip") or ""))
self.s_size.setText(str(st.get("size") or ""))
# ---- display
def show_file(self, file_id):
if not file_id:
return
self.stash()
self._current_id = file_id
self._clear_rows()
self.notes.setPlainText("")
self._fill_picks({})
f = self.file_by_id(file_id)
path = self.path_for(f) if f else None
if path is None:
self.info.setText(f"{file_id}\nFile not found under the model folders above (edit the folder list).")
return
entry = self.ck_cache.get(str(path))
if entry is None:
self.info.setText(f"{file_id}\nlooking up ...")
self.start_worker([(file_id, path)])
return
self.render_entry(file_id, entry)
def render_entry(self, file_id, entry):
civ, hf = entry.get("civitai") or {}, entry.get("hf") or {}
lines = [file_id]
if civ:
lines.append(f"Civitai: {civ.get('model_name')} [{civ.get('version_name')}] by {civ.get('creator') or '?'} "
f"type: {civ.get('type')} base: {civ.get('base_model')} nsfw: {civ.get('nsfw')}")
if civ.get("trained_words"):
lines.append("trained words: " + " | ".join(civ["trained_words"])[:300])
if hf:
card = hf.get("card") or {}
lines.append(f"Hugging Face: {hf.get('repo')} {'hash verified' if hf.get('verified') else 'name match only'}"
f" base: {card.get('base_model') or '?'} license: {card.get('license') or '?'}"
+ (" (gated)" if hf.get("gated") else ""))
if not civ and not hf:
lines.append(f"Not found. {entry.get('status', '')}")
else:
lines.append(entry.get("status", ""))
self.info.setText("\n".join(lines))
self.civ_btn.setEnabled(bool(civ.get("url")))
self.hf_btn.setEnabled(bool(hf.get("url")))
pick, cands = core.suggest(entry)
_, p = self.entry_for(file_id)
saved = self.picks.get(str(p)) if p else None
self._fill_picks(saved if saved else pick)
self._clear_rows()
for c in cands:
row = CandidateRow(c)
row.use.connect(self.use_candidate)
self.cands_layout.addWidget(row)
self._rows.append(row)
if not cands:
self.cands_layout.addWidget(QLabel("(nothing prompt-like found on the pages)"))
self.cands_layout.addStretch()
notes = []
if civ.get("version_text"):
notes.append("=== Civitai version notes ===\n" + civ["version_text"])
if civ.get("model_text"):
notes.append("=== Civitai model page ===\n" + civ["model_text"])
if civ.get("tags"):
notes.append("Civitai tags: " + ", ".join(civ["tags"]))
if hf.get("readme_text"):
notes.append(f"=== Hugging Face model card ({hf.get('repo')}) ===\n" + hf["readme_text"])
elif hf:
notes.append(f"=== Hugging Face ({hf.get('repo')}) ===\nmodel card: {hf.get('readme_status')}")
if entry.get("hf_candidates") and not hf:
notes.append("Hugging Face repos checked without a hash match: " + ", ".join(entry["hf_candidates"]))
fm = entry.get("file_meta") or {}
if fm:
notes.append("=== metadata inside the file ===\n" + "\n".join(f"{k}: {v}" for k, v in fm.items()))
self.notes.setPlainText("\n\n".join(notes).replace(core.CODE_MARK, ""))
def _clear_rows(self):
while self.cands_layout.count():
item = self.cands_layout.takeAt(0)
if item.widget():
item.widget().deleteLater()
self._rows = []
def use_candidate(self, kind, text):
if kind == "positive":
self.pos.setPlainText(text)
elif kind == "negative":
self.neg.setPlainText(text)
else:
st = core.parse_settings(text)
for key, w in (("sampler", self.s_sampler), ("steps", self.s_steps), ("cfg", self.s_cfg),
("clip_skip", self.s_clip), ("size", self.s_size)):
if st.get(key) not in (None, ""):
w.setText(str(st[key]))
def find_next(self):
text = self.find.text()
if text and not self.notes.find(text):
cursor = self.notes.textCursor()
cursor.movePosition(cursor.MoveOperation.Start)
self.notes.setTextCursor(cursor)
self.notes.find(text)
# ---- lookups
def start_worker(self, jobs):
if self._worker and self._worker.isRunning():
self.status.setText("A lookup is already running; wait for it to finish.")
return
self.save_prefs()
self._worker = CheckpointWorker(jobs, self.hash_cache, self.ck_cache, (self.hash_cache_path, self.ck_cache_path), self.token(), self)
self._worker.progress.connect(self.status.setText)
self._worker.result.connect(self.on_result)
self._worker.finished_all.connect(lambda: self.status.setText("Lookup finished."))
self._worker.start()
def on_result(self, file_id, entry):
if file_id == self._current_id:
self.render_entry(file_id, entry)
def fetch_all(self):
jobs = []
for f in self.files():
p = self.path_for(f)
if p is not None and str(p) not in self.ck_cache:
jobs.append((f.id, p))
if not jobs:
self.status.setText("Everything is already looked up (Re-fetch redoes the selected one).")
return
self.status.setText(f"Looking up {len(jobs)} checkpoints in the background (hashing big files is the slow part) ...")
self.start_worker(jobs)
def refetch(self):
if not self._current_id:
return
f = self.file_by_id(self._current_id)
p = self.path_for(f) if f else None
if p is None:
return
self.ck_cache.pop(str(p), None)
self.show_file(self._current_id)
def pick_hf(self):
if not self._current_id:
return
entry, p = self.entry_for(self._current_id)
if not entry or p is None:
self.status.setText("Look the file up first (it needs the hash).")
return
cands = list(entry.get("hf_candidates") or [])
if (entry.get("hf") or {}).get("repo") and entry["hf"]["repo"] not in cands:
cands.insert(0, entry["hf"]["repo"])
dlg = HFPickDialog(self._current_id, cands, self.token(), self)
if dlg.exec() and dlg.choice:
if self._hf_worker and self._hf_worker.isRunning():
self.status.setText("Still fetching the previous model card.")
return
self.status.setText(f"fetching model card from {dlg.choice} ...")
self._hf_worker = HFWorker(self._current_id, dlg.choice, entry.get("sha256", ""), self.token(), self)
self._hf_worker.done.connect(self.on_hf)
self._hf_worker.start()
def on_hf(self, file_id, hf, status):
self.status.setText(status)
entry, p = self.entry_for(file_id)
if hf is None or not entry or p is None:
return
entry["hf"] = hf
entry["hf_status"] = status
self.ck_cache[str(p)] = entry
core.save_json(self.ck_cache_path, self.ck_cache)
if file_id == self._current_id:
self.picks.pop(str(p), None) # re-suggest with the new card
self.render_entry(file_id, entry)
# ---- outputs
def save_style(self):
if not self._current_id:
return
entry, _ = self.entry_for(self._current_id)
civ = (entry or {}).get("civitai") or {}
name = civ.get("model_name") or Path(self._current_id).stem
if civ.get("version_name") and civ["version_name"].lower() not in name.lower():
name = f"{name} {civ['version_name']}"
settings = {"sampler": self.s_sampler.text(), "steps": self.s_steps.text(), "cfg": self.s_cfg.text(), "clip_skip": self.s_clip.text()}
try:
from ai_diffusion.style import SamplerPresets, Styles # type: ignore
presets = [n for n, p in getattr(SamplerPresets.instance(), "_presets", {}).items() if not getattr(p, "hidden", False)]
except Exception as e:
self.status.setText(f"Can't reach the AI plugin's style code: {type(e).__name__}: {e}")
return
dlg = SaveStyleDialog(self._current_id, name, self.pos.toPlainText().strip(), self.neg.toPlainText().strip(), settings, presets, self)
if not dlg.exec():
return
try:
styles = Styles.list()
slug = re.sub(r"[^\w\- ]+", "", dlg.name.text()).strip().replace(" ", "-").lower()[:48] or "style"
style = styles.create(f"{slug}.json", checkpoint=self._current_id)
style.name = dlg.name.text().strip() or name
style.style_prompt = dlg.style_prompt.toPlainText().strip() or "{prompt}"
style.negative_prompt = dlg.negative.toPlainText().strip()
style.sampler = dlg.sampler.currentText()
if dlg.steps.text().strip().isdigit():
style.sampler_steps = int(dlg.steps.text())
try:
if dlg.cfg.text().strip():
style.cfg_scale = float(dlg.cfg.text())
except ValueError:
pass
if dlg.clip.text().strip().isdigit():
style.clip_skip = int(dlg.clip.text())
style.save()
styles.reload()
self.stash()
self.status.setText(f"Style '{style.name}' written to {style.filepath}")
except Exception as e:
self.status.setText(f"Writing the style failed: {type(e).__name__}: {e}")
def write_report(self):
self.stash()
lines = []
for f in sorted(self.files(), key=lambda f: f.id.lower()):
p = self.path_for(f)
e = (self.ck_cache.get(str(p)) if p else None) or {}
civ, hf = e.get("civitai") or {}, e.get("hf") or {}
pick = self.picks.get(str(p)) if p else None
if not pick and e:
pick, _ = core.suggest(e)
pick = {**pick, **pick.get("settings", {})}
pick = pick or {}
lines.append(
f"{f.id}\n civitai: {civ.get('model_name') or '-'} [{civ.get('version_name', '')}] base: {civ.get('base_model', '')} url: {civ.get('url', '')}\n"
f" hugging face: {hf.get('repo') or '-'} {'(hash verified)' if hf.get('verified') else ''} url: {hf.get('url', '')}\n"
f" status: {e.get('status', 'not looked up')}\n"
f" positive: {pick.get('positive', '')}\n negative: {pick.get('negative', '')}\n"
f" settings: sampler {pick.get('sampler', '')} steps {pick.get('steps', '')} cfg {pick.get('cfg', '')} clip skip {pick.get('clip_skip', '')} size {pick.get('size', '')}\n"
)
out = self.cache_dir / "checkpoint_notes_report.txt"
out.parent.mkdir(parents=True, exist_ok=True)
out.write_text("\n".join(lines), encoding="utf-8")
self.status.setText(f"Report written: {out}")

Xet Storage Details

Size:
28.4 kB
·
Xet hash:
2e326e24954a05f4bfd2e339c708f16f984205f63f79fe19b8d3e7c4dae0dc8b

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.