Sort newest Hub models and run image encoder on second GPU

This commit is contained in:
Mikei386
2026-09-28 18:27:23 +02:00
parent fd797a6c8d
commit a0941c0549
15 changed files with 159 additions and 35 deletions
+4 -3
View File
@@ -86,10 +86,11 @@ class Catalog:
path=self.root/ident/('model'+PurePosixPath(entry['file']).suffix)
if not path.is_file() or path.stat().st_size!=entry['size']:raise ValueError('Modelldatei fehlt oder ist unvollständig.')
return entry
def search(self,q,kind):
def search(self,q,kind,sort="downloads"):
if kind not in KINDS or not isinstance(q,str) or len(q)>120:raise ValueError('Ungültige Suche.')
rows=metadata('/api/models?'+urllib.parse.urlencode(dict(search=q,filter=KINDS[kind],limit=20,sort='downloads',direction=-1)))
return {'models':[dict(repo=x['id'],downloads=x.get('downloads'),gated=x.get('gated',False)) for x in rows]}
if sort not in ('downloads','name','newest'):raise ValueError('Ungültige Sortierung.')
rows=metadata('/api/models?'+urllib.parse.urlencode(dict(search=q,filter=KINDS[kind],limit=20,sort='createdAt' if sort=='newest' else 'downloads',direction=-1)))
return {'models':[dict(repo=x['id'],downloads=x.get('downloads'),gated=x.get('gated',False),created_at=x.get('createdAt')) for x in rows]}
def files(self,repo):
repo=repo_id(repo)
with self.cache_lock: