Sort newest Hub models and run image encoder on second GPU
This commit is contained in:
+4
-3
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user