Datasets:
Tasks:
Image Classification
Modalities:
Image
Sub-tasks:
multi-class-image-classification
Languages:
Chinese
Size:
10K<n<100K
License:
Commit ·
cb9e714
1
Parent(s): c30ac13
更新说明
Browse files
README.md
CHANGED
|
@@ -1,3 +1,109 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
annotations_creators:
|
| 3 |
+
- crowdsourced
|
| 4 |
+
language:
|
| 5 |
+
- zh
|
| 6 |
+
language_creators:
|
| 7 |
+
- found
|
| 8 |
+
license:
|
| 9 |
+
- apache-2.0
|
| 10 |
+
multilinguality:
|
| 11 |
+
- monolingual
|
| 12 |
+
pretty_name: "15\u79CD\u852C\u83DC\u6570\u636E\u96C6"
|
| 13 |
+
size_categories:
|
| 14 |
+
- 10K<n<100K
|
| 15 |
+
source_datasets:
|
| 16 |
+
- original
|
| 17 |
+
tags:
|
| 18 |
+
- "\u852C\u83DC"
|
| 19 |
+
- "\u56FE\u50CF\u5206\u7C7B"
|
| 20 |
+
task_categories:
|
| 21 |
+
- image-classification
|
| 22 |
+
task_ids:
|
| 23 |
+
- multi-class-image-classification
|
| 24 |
+
dataset_info:
|
| 25 |
+
features:
|
| 26 |
+
- name: image
|
| 27 |
+
dtype: image
|
| 28 |
+
- name: category
|
| 29 |
+
dtype: int64
|
| 30 |
---
|
| 31 |
+
|
| 32 |
+
## 蔬菜图像数据集
|
| 33 |
+
### 背景
|
| 34 |
+
最初的实验是用世界各地发现的15种常见蔬菜进行的。实验选择的蔬菜有:豆类、苦瓜、葫芦、茄子、西兰花、卷心菜、辣椒、胡萝卜、花椰菜、黄瓜、木瓜、土豆、南瓜、萝卜和番茄。共使用了来自15个类的21000张图像,其中每个类包含1400张尺寸为224×224、格式为*.jpg的图像。数据集中70%用于培训,15%用于验证,15%用于测试。
|
| 35 |
+
### 目录
|
| 36 |
+
此数据集包含三个文件夹:
|
| 37 |
+
- train (15000 张图像)
|
| 38 |
+
- test (3000 张图像)
|
| 39 |
+
- validation (3000 张图像)
|
| 40 |
+
### 数据收集
|
| 41 |
+
这个数据集中的图像是我们为一个项目从蔬菜农场和市场收集的。
|
| 42 |
+
### 制作元数据文件
|
| 43 |
+
运行下面`python`的代码,就可以在桌面生成三个csv格式的元数据文件、一个分类数据文件(需要放入到数据文件中)
|
| 44 |
+
```python
|
| 45 |
+
#!/usr/bin/env python3
|
| 46 |
+
# -*- coding: utf-8 -*-
|
| 47 |
+
|
| 48 |
+
"""
|
| 49 |
+
1.下载的数据文件 Vegetable Images.zip ,并解压到桌面
|
| 50 |
+
2.然后执行 python generate.py 即可生成三个元数据文件和一个分类数据文件
|
| 51 |
+
"""
|
| 52 |
+
import os
|
| 53 |
+
from pathlib import Path
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
category_dict = {
|
| 57 |
+
'Bean': '豆类',
|
| 58 |
+
'Bitter_Gourd': '苦瓜',
|
| 59 |
+
'Bottle_Gourd': '葫芦',
|
| 60 |
+
'Brinjal': '茄子',
|
| 61 |
+
'Broccoli': '西兰花',
|
| 62 |
+
'Cabbage': '卷心菜',
|
| 63 |
+
'Capsicum': '辣椒',
|
| 64 |
+
'Carrot': '胡萝卜',
|
| 65 |
+
'Cauliflower': '花椰菜',
|
| 66 |
+
'Cucumber': '黄瓜',
|
| 67 |
+
'Papaya': '木瓜',
|
| 68 |
+
'Potato': '土豆',
|
| 69 |
+
'Pumpkin': '南瓜',
|
| 70 |
+
'Radish': '萝卜',
|
| 71 |
+
'Tomato': '番茄',
|
| 72 |
+
}
|
| 73 |
+
base_path = Path.home().joinpath('desktop')
|
| 74 |
+
data = '\n'.join((item for item in category_dict.values())) # 注意:利用了python 3.6之后字典插入有序的特性
|
| 75 |
+
base_path.joinpath('classname.txt').write_text(data, encoding='utf-8')
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def create(filename):
|
| 79 |
+
csv_path = base_path.joinpath(f'{filename}.csv')
|
| 80 |
+
with csv_path.open('wt', encoding='utf-8', newline='') as csv:
|
| 81 |
+
csv.writelines([f'image,category{os.linesep}'])
|
| 82 |
+
data_path = base_path.joinpath('Vegetable Images', filename)
|
| 83 |
+
batch = 0
|
| 84 |
+
datas = []
|
| 85 |
+
keys = list(category_dict.keys())
|
| 86 |
+
for image_path in data_path.rglob('*.jpg'):
|
| 87 |
+
batch += 1
|
| 88 |
+
part1 = str(image_path).removeprefix(str(base_path)).replace('\\', '/')[1:]
|
| 89 |
+
part2 = keys.index(image_path.parents[0].name)
|
| 90 |
+
datas.append(f'{part1},{part2}{os.linesep}')
|
| 91 |
+
if batch > 100:
|
| 92 |
+
csv.writelines(datas)
|
| 93 |
+
datas.clear()
|
| 94 |
+
if datas:
|
| 95 |
+
csv.writelines(datas)
|
| 96 |
+
return csv_path.stat().st_size
|
| 97 |
+
|
| 98 |
+
|
| 99 |
+
if __name__ == '__main__':
|
| 100 |
+
print(create('train'))
|
| 101 |
+
print(create('test'))
|
| 102 |
+
print(create('validation'))
|
| 103 |
+
```
|
| 104 |
+
### 致谢
|
| 105 |
+
非常感谢原始数据集提供方 [Vegetable Image Dataset](https://www.kaggle.com/datasets/misrakahmed/vegetable-image-dataset)。
|
| 106 |
+
### 克隆数据
|
| 107 |
+
```bash
|
| 108 |
+
git clone https://huggingface.co/datasets/cc92yy3344/vegetable.git
|
| 109 |
+
```
|