Datasets:

License:
admin commited on
Commit
d6a7441
·
1 Parent(s): 729b672
Files changed (3) hide show
  1. .gitignore +3 -0
  2. README.md +27 -0
  3. insecta_sounds.py +80 -0
.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ test.*
2
+ *__pycache__*
3
+ dataset_infos.json
README.md CHANGED
@@ -1,3 +1,30 @@
1
  ---
2
  license: cc-by-nc-nd-4.0
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: cc-by-nc-nd-4.0
3
+ viewer: false
4
  ---
5
+
6
+ # Intro
7
+ The insecta_sounds Video Dataset is a multimodal video library designed for intelligent recognition and ecological research, featuring high-definition field-captured footage of common insect species and genera from across China. Each video clip is annotated with both Chinese common names and Latin scientific names, supporting tasks such as object detection, behavioral analysis, fine-grained classification, and cross-modal retrieval. It is applicable to mobile insect identification application development, biodiversity monitoring, and science education scenarios, facilitating dynamic and intelligent insect cognition experiences.
8
+
9
+ ## Usage
10
+ ```python
11
+ from datasets import load_dataset
12
+
13
+ ds = load_dataset(
14
+ "Genius-Society/insecta_sounds",
15
+ split="train",
16
+ cache_dir="./__pycache__",
17
+ trust_remote_code=True,
18
+ )
19
+ for item in ds:
20
+ print(item)
21
+ ```
22
+
23
+ ## Maintenance
24
+ ```bash
25
+ git clone git@hf.co:datasets/Genius-Society/insecta_sounds
26
+ cd insecta_sounds
27
+ ```
28
+
29
+ ## Mirror
30
+ <https://www.modelscope.cn/datasets/Genius-Society/insecta_sounds>
insecta_sounds.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import random
3
+ import requests
4
+ import datasets
5
+ from tqdm import tqdm
6
+ from io import BytesIO
7
+ from PIL import Image
8
+
9
+ _HEADER = {
10
+ "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0"
11
+ }
12
+
13
+
14
+ class insecta_sounds(datasets.GeneratorBasedBuilder):
15
+ def _info(self):
16
+ return datasets.DatasetInfo(
17
+ features=datasets.Features(
18
+ {
19
+ "audio": datasets.Value("string"),
20
+ "image": datasets.Image(),
21
+ "label": datasets.Value("string"),
22
+ "latin": datasets.Value("string"),
23
+ }
24
+ ),
25
+ supervised_keys=("audio", "latin"),
26
+ homepage=f"https://www.modelscope.cn/datasets/Genius-Society/{os.path.basename(__file__)[:-3]}",
27
+ license="mit",
28
+ version="0.0.1",
29
+ )
30
+
31
+ def _get_files(self):
32
+ try:
33
+ response = requests.get(
34
+ "https://www.missevan.com/dramaapi/getdramaepisodedetails",
35
+ params={"drama_id": 73247, "p": 1, "page_size": 100},
36
+ headers=_HEADER,
37
+ )
38
+ response.raise_for_status()
39
+ return response.json()["info"]["Datas"]
40
+
41
+ except Exception as e:
42
+ print(f"{e}, retrying...")
43
+ return self._get_files()
44
+
45
+ def _dld_img(self, url: str):
46
+ try:
47
+ response = requests.get(url, headers=_HEADER)
48
+ response.raise_for_status()
49
+ return Image.open(BytesIO(response.content))
50
+
51
+ except Exception as e:
52
+ print(f"{e}, retrying...")
53
+ return self._dld_img(url)
54
+
55
+ def _split_generators(self, _):
56
+ dataset = []
57
+ files = self._get_files()
58
+ for file in tqdm(files, desc="Parsing classes"):
59
+ label, latin = str(file["soundstr"]).split(" ", 1)
60
+ dataset.append(
61
+ {
62
+ "audio": f"https://www.missevan.com/soundiframe/{file['id']}?type=small",
63
+ "image": self._dld_img(file["front_cover"]),
64
+ "label": label.strip(),
65
+ "latin": latin.strip(),
66
+ }
67
+ )
68
+
69
+ random.shuffle(dataset)
70
+
71
+ return [
72
+ datasets.SplitGenerator(
73
+ name=datasets.Split.TRAIN,
74
+ gen_kwargs={"files": dataset},
75
+ )
76
+ ]
77
+
78
+ def _generate_examples(self, files):
79
+ for i, path in enumerate(files):
80
+ yield i, path