narugo commited on
Commit
2f9df59
2 Parent(s): f8b5902 b4053ed

dev(narugo): merge from index

Browse files
Files changed (2) hide show
  1. app.py +4 -1
  2. pools.py +20 -0
app.py CHANGED
@@ -14,6 +14,8 @@ from hfutils.operate import get_hf_fs, get_hf_client
14
  from hfutils.utils import TemporaryDirectory
15
  from imgutils.tagging import wd14
16
 
 
 
17
  _REPO_ID = 'deepghs/anime_sites_indices'
18
 
19
  hf_fs = get_hf_fs()
@@ -38,7 +40,8 @@ _SITE_CLS = {
38
 
39
  def _get_from_ids(site_name: str, ids: List[int]) -> Dict[int, Image.Image]:
40
  with TemporaryDirectory() as td:
41
- datapool = _SITE_CLS[site_name]()
 
42
  datapool.batch_download_to_directory(
43
  resource_ids=ids,
44
  dst_dir=td,
 
14
  from hfutils.utils import TemporaryDirectory
15
  from imgutils.tagging import wd14
16
 
17
+ from pools import quick_webp_pool
18
+
19
  _REPO_ID = 'deepghs/anime_sites_indices'
20
 
21
  hf_fs = get_hf_fs()
 
40
 
41
  def _get_from_ids(site_name: str, ids: List[int]) -> Dict[int, Image.Image]:
42
  with TemporaryDirectory() as td:
43
+ site_cls = _SITE_CLS.get(site_name) or quick_webp_pool(site_name, 3)
44
+ datapool = site_cls()
45
  datapool.batch_download_to_directory(
46
  resource_ids=ids,
47
  dst_dir=td,
pools.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Type
2
+
3
+ from cheesechaser.datapool import IncrementIDDataPool
4
+
5
+
6
+ def quick_webp_pool(site_name: str, level: int = 3) -> Type[IncrementIDDataPool]:
7
+ repo_id = f'deepghs/{site_name}-webp-4Mpixel'
8
+
9
+ class _QuickWebpDataPool(IncrementIDDataPool):
10
+ def __init__(self, revision: str = 'main'):
11
+ IncrementIDDataPool.__init__(
12
+ self,
13
+ data_repo_id=repo_id,
14
+ data_revision=revision,
15
+ idx_repo_id=repo_id,
16
+ idx_revision=revision,
17
+ base_level=level,
18
+ )
19
+
20
+ return _QuickWebpDataPool