Spaces:
Running
Running
dev(narugo): quick webp
Browse files
app.py
CHANGED
@@ -14,7 +14,7 @@ from hfutils.operate import get_hf_fs, get_hf_client
|
|
14 |
from hfutils.utils import TemporaryDirectory
|
15 |
from imgutils.tagging import wd14
|
16 |
|
17 |
-
from pools import
|
18 |
|
19 |
_REPO_ID = 'deepghs/index_experiments'
|
20 |
|
@@ -35,13 +35,13 @@ _SITE_CLS = {
|
|
35 |
'konachan': KonachanWebpDataPool,
|
36 |
'anime_pictures': AnimePicturesWebpDataPool,
|
37 |
'rule34': Rule34WebpDataPool,
|
38 |
-
'aibooru': AIBooruWebpDataPool,
|
39 |
}
|
40 |
|
41 |
|
42 |
def _get_from_ids(site_name: str, ids: List[int]) -> Dict[int, Image.Image]:
|
43 |
with TemporaryDirectory() as td:
|
44 |
-
|
|
|
45 |
datapool.batch_download_to_directory(
|
46 |
resource_ids=ids,
|
47 |
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/index_experiments'
|
20 |
|
|
|
35 |
'konachan': KonachanWebpDataPool,
|
36 |
'anime_pictures': AnimePicturesWebpDataPool,
|
37 |
'rule34': Rule34WebpDataPool,
|
|
|
38 |
}
|
39 |
|
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
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
from cheesechaser.datapool import IncrementIDDataPool
|
2 |
|
3 |
_AIBOORU_REPO_ID = 'deepghs/aibooru-webp-4Mpixel'
|
@@ -13,3 +15,20 @@ class AIBooruWebpDataPool(IncrementIDDataPool):
|
|
13 |
idx_revision=revision,
|
14 |
base_level=3,
|
15 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import Type
|
2 |
+
|
3 |
from cheesechaser.datapool import IncrementIDDataPool
|
4 |
|
5 |
_AIBOORU_REPO_ID = 'deepghs/aibooru-webp-4Mpixel'
|
|
|
15 |
idx_revision=revision,
|
16 |
base_level=3,
|
17 |
)
|
18 |
+
|
19 |
+
|
20 |
+
def quick_webp_pool(site_name: str, level: int = 3) -> Type[IncrementIDDataPool]:
|
21 |
+
repo_id = f'deepghs/{site_name}-webp-4Mpixel'
|
22 |
+
|
23 |
+
class _QuickWebpDataPool(IncrementIDDataPool):
|
24 |
+
def __init__(self, revision: str = 'main'):
|
25 |
+
IncrementIDDataPool.__init__(
|
26 |
+
self,
|
27 |
+
data_repo_id=repo_id,
|
28 |
+
data_revision=revision,
|
29 |
+
idx_repo_id=repo_id,
|
30 |
+
idx_revision=revision,
|
31 |
+
base_level=level,
|
32 |
+
)
|
33 |
+
|
34 |
+
return _QuickWebpDataPool
|