Upload folder using huggingface_hub
Browse files- README.md +55 -0
- anime-segmentation.py +74 -0
- data/bg-00.zip +3 -0
- data/bg-01.zip +3 -0
- data/bg-02.zip +3 -0
- data/bg-03.zip +3 -0
- data/bg-04.zip +3 -0
- data/fg-00.zip +3 -0
- data/fg-01.zip +3 -0
- data/fg-02.zip +3 -0
- data/fg-03.zip +3 -0
- data/fg-04.zip +3 -0
- data/fg-05.zip +3 -0
- data/imgs-masks.zip +3 -0
README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
annotations_creators: []
|
| 3 |
+
language: []
|
| 4 |
+
language_creators: []
|
| 5 |
+
license:
|
| 6 |
+
- cc0-1.0
|
| 7 |
+
multilinguality: []
|
| 8 |
+
pretty_name: Anime Segmentation
|
| 9 |
+
size_categories:
|
| 10 |
+
- 10K<n<100K
|
| 11 |
+
source_datasets:
|
| 12 |
+
- original
|
| 13 |
+
tags: []
|
| 14 |
+
task_categories:
|
| 15 |
+
- image-segmentation
|
| 16 |
+
task_ids:
|
| 17 |
+
- semantic-segmentation
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
## Dataset Description
|
| 21 |
+
|
| 22 |
+
A segmentation dataset for anime character
|
| 23 |
+
|
| 24 |
+
My project: [anime-segmentation](https://github.com/SkyTNT/anime-segmentation)
|
| 25 |
+
|
| 26 |
+
### Dataset Summary
|
| 27 |
+
|
| 28 |
+
| Dir | Description | Format | Images |
|
| 29 |
+
| ---- | ---- | ---- | ---- |
|
| 30 |
+
| bg | background images | jpg | 8057 |
|
| 31 |
+
| fg | foreground images, transparent background | png | 11802 |
|
| 32 |
+
| imgs | real images with background and foreground| jpg | 1111 |
|
| 33 |
+
| masks| labels for imgs | jpg | 1111 |
|
| 34 |
+
|
| 35 |
+
Total size: 18GB
|
| 36 |
+
|
| 37 |
+
### Collection Method
|
| 38 |
+
|
| 39 |
+
Collect background from [character_bg_seg_data](https://github.com/ShuhongChen/bizarre-pose-estimator#download)
|
| 40 |
+
|
| 41 |
+
Collect foreground from danbooru website.
|
| 42 |
+
|
| 43 |
+
Collect imgs and masks from [AniSeg](https://github.com/jerryli27/AniSeg#about-the-models) and danbooru website.
|
| 44 |
+
|
| 45 |
+
I use [Real-ESRGAN](https://github.com/xinntao/Real-ESRGAN) to restore the background images.
|
| 46 |
+
|
| 47 |
+
I clean the dataset using [DeepDanbooru](https://github.com/KichangKim/DeepDanbooru) first then manually, to make sue all foreground is anime character.
|
| 48 |
+
|
| 49 |
+
### Contributions
|
| 50 |
+
|
| 51 |
+
Thanks to [@SkyTNT](https://github.com/SkyTNT) for adding this dataset.
|
| 52 |
+
|
| 53 |
+
Thanks to [@ShuhongChen](https://github.com/ShuhongChen) for [character_bg_seg_data](https://github.com/ShuhongChen/bizarre-pose-estimator#download)
|
| 54 |
+
|
| 55 |
+
Thanks to [@jerryli27](https://github.com/jerryli27) for [AniSeg](https://github.com/jerryli27/AniSeg#about-the-models)
|
anime-segmentation.py
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import datasets
|
| 3 |
+
from datasets import DownloadManager, DatasetInfo
|
| 4 |
+
|
| 5 |
+
_DESCRIPTION = """\
|
| 6 |
+
A segmentation dataset for anime character
|
| 7 |
+
"""
|
| 8 |
+
_HOMEPAGE = "https://huggingface.co/datasets/skytnt/anime-segmentation"
|
| 9 |
+
_URL_BASE = "https://huggingface.co/datasets/skytnt/anime-segmentation/resolve/main/data/"
|
| 10 |
+
_EXTENSION = [".png", ".jpg"]
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
class AnimeSegmentationConfig(datasets.BuilderConfig):
|
| 14 |
+
|
| 15 |
+
def __init__(self, features, data_files, **kwargs):
|
| 16 |
+
super(AnimeSegmentationConfig, self).__init__(**kwargs)
|
| 17 |
+
self.features = features
|
| 18 |
+
self.data_files = data_files
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class AnimeSegmentation(datasets.GeneratorBasedBuilder):
|
| 22 |
+
BUILDER_CONFIGS = [
|
| 23 |
+
AnimeSegmentationConfig(
|
| 24 |
+
name="bg",
|
| 25 |
+
description="background",
|
| 26 |
+
features=["image"],
|
| 27 |
+
data_files=["bg-00.zip", "bg-01.zip", "bg-02.zip", "bg-03.zip", "bg-04.zip"]
|
| 28 |
+
),
|
| 29 |
+
AnimeSegmentationConfig(
|
| 30 |
+
name="fg",
|
| 31 |
+
description="foreground",
|
| 32 |
+
features=["image"],
|
| 33 |
+
data_files=["fg-00.zip", "fg-01.zip", "fg-02.zip", "fg-03.zip", "fg-04.zip", "fg-05.zip"]
|
| 34 |
+
),
|
| 35 |
+
AnimeSegmentationConfig(
|
| 36 |
+
name="imgs-masks",
|
| 37 |
+
description="real images and masks",
|
| 38 |
+
features=["image", "mask"],
|
| 39 |
+
data_files=["imgs-masks.zip"]
|
| 40 |
+
)
|
| 41 |
+
]
|
| 42 |
+
|
| 43 |
+
def _info(self) -> DatasetInfo:
|
| 44 |
+
|
| 45 |
+
features = {feature: datasets.Image() for feature in self.config.features}
|
| 46 |
+
return datasets.DatasetInfo(
|
| 47 |
+
description=_DESCRIPTION,
|
| 48 |
+
features=datasets.Features(features),
|
| 49 |
+
supervised_keys=None,
|
| 50 |
+
homepage=_HOMEPAGE,
|
| 51 |
+
citation="",
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
def _split_generators(self, dl_manager: DownloadManager):
|
| 55 |
+
urls = [_URL_BASE + data_file for data_file in self.config.data_files]
|
| 56 |
+
dirs = dl_manager.download_and_extract(urls)
|
| 57 |
+
return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"dirs": dirs})]
|
| 58 |
+
|
| 59 |
+
def _generate_examples(self, dirs):
|
| 60 |
+
if self.config.name != "imgs-masks":
|
| 61 |
+
for path in dirs:
|
| 62 |
+
all_fnames = {os.path.relpath(os.path.join(root, fname), start=path)
|
| 63 |
+
for root, _dirs, files in os.walk(path) for fname in files}
|
| 64 |
+
image_fnames = sorted(fname for fname in all_fnames if os.path.splitext(fname)[1].lower() in _EXTENSION)
|
| 65 |
+
for image_fname in image_fnames:
|
| 66 |
+
yield image_fname, {"image": os.path.join(path, image_fname)}
|
| 67 |
+
else:
|
| 68 |
+
path = dirs[0]
|
| 69 |
+
all_fnames = {os.path.relpath(os.path.join(root, fname), start=path)
|
| 70 |
+
for root, _dirs, files in os.walk(os.path.join(path, "imgs")) for fname in files}
|
| 71 |
+
image_fnames = sorted(fname for fname in all_fnames if os.path.splitext(fname)[1].lower() in _EXTENSION)
|
| 72 |
+
for image_fname in image_fnames:
|
| 73 |
+
yield image_fname, {"image": os.path.join(path, image_fname),
|
| 74 |
+
"mask": os.path.join(path, image_fname.replace("imgs", "masks"))}
|
data/bg-00.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:91fecb63f9fe4c2888f8cdef2aae7b6357c968a39c5cfd03d5080652bb6528bf
|
| 3 |
+
size 2131302329
|
data/bg-01.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:400dad07d0d3d0365da6d7df3726fab532918ee8f0d84a3cc385eb190609c1a0
|
| 3 |
+
size 2167522672
|
data/bg-02.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6b5f4ed22e79def82923ba13131b95fff99704ad1bf5d9f51905536343012d60
|
| 3 |
+
size 2104766366
|
data/bg-03.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d60c77a1c081c065439f6a66512fd5ebe9347cf193d7fba6a6b4423b58ac79ca
|
| 3 |
+
size 2108029369
|
data/bg-04.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2ce0514dd1fcb6f1ed3b5b36bed15f4d6b595524f23474570e9bf70071cd6f43
|
| 3 |
+
size 62435130
|
data/fg-00.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ddec7d4a54e2b4b8154545916cbe04055bcf6271b91d71c5fb04671516cda494
|
| 3 |
+
size 1498101493
|
data/fg-01.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c66291a0425f0103a5ada050aa91743eb96ed100328e01f80d9c5c281718c561
|
| 3 |
+
size 1482962765
|
data/fg-02.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a478fe9c87c84005c180da842fe54e0f30616f9699d2a9306ef421d8a3b91d3a
|
| 3 |
+
size 1457035557
|
data/fg-03.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4dd290a5478424a70f486c02b79f8c901430bdfe910561c125eb24a0560926f8
|
| 3 |
+
size 1447647250
|
data/fg-04.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7ee7ba08d110de4298207df432dbacf6b90fbb2283ff9d09b226a65c8bc4d7a0
|
| 3 |
+
size 1510016884
|
data/fg-05.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:abf535a8ec01b8035dcec085a6257f1a46692a96797c3f71271aeaf0d5f793b7
|
| 3 |
+
size 1335862655
|
data/imgs-masks.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e4c8abf4a978c7cabb48eed5be9d6dfeab6b4fe070705713ae20216e77d7211d
|
| 3 |
+
size 182267346
|