# tools_zy[![Version][version-badge]][version-link] ![MIT License][license-badge]
此工具包旨在给AI工作者提供一把趁手的工具,尽量简化非核心的工作。\
其中包含深度学习模型过程中可能会用到的一些工具,比如数据整理、格式转换、划分数据集等。
因此也要注意,其中某些函数可能并没有提供过多自由度,如果需要,请自行修改。
### 安装
```bash
$ pip install tools-zy
```
### 使用
含有的功能示例如下:
```python
import tools_zy as tz
# 复制、移动文件夹中以.bmp结尾的文件。(还支持指定文件名,支持递归操作)
tz.copy_file("/home/org_folder", "/home/new_folder", format=".bmp")
tz.move_file("/home/org_folder", "/home/new_folder", format=".bmp")
# 获取(复制、移动)文件夹中以.bmp结尾的一些随机文件。
tz.copy_some_random_files("/home/org_folder", "/home/new_folder", 1000, format='.bmp')
tz.move_some_random_files("/home/org_folder", "/home/new_folder", 1000, format='.bmp')
# 划分分类数据集
img_folder = r"/home/classify/rawData" # 包含n个名称为数字序列的文件夹
out_folder = r"/home/classify/splitData" #
tz.split_classifid_images(img_folder, out_folder, (0.8, 0.2, 0), format=".bmp")
# 划分lablmes数据集 (划分图片和json文件到train, val, test文件夹)
labelme_folder = r"D:\Zhiyuan\pics_get\keypoints\20241118"
data_folder = tz.split_labelmes(labelme_folder, ratio=(0.85, 0.1, 0.05), format=".bmp")
# 将labelme的json格式转化为coco格式,要求图片和json文件名相同且在同一文件夹下
labelme_json_folder = r'D:\Zhiyuan\pics_get\keypoints\keypoints\20241030'
coco_json_path = r'D:\Zhiyuan\pics_get\keypoints\keypoints\20241030.json'
categories_json_file = r"D:\Zhiyuan\code\tz\categories_person.json"
tz.labelmes2coco(labelme_json_folder, coco_json_path, categories_json_file, bbox=[1, 1, 511, 1023])
coco_json_path = r'D:\Zhiyuan\pics_get\keypoints\keypoints\20241121.json'
labelme_json_folder = r'D:\Zhiyuan\pics_get\keypoints\keypoints\20241121'
tz.coco2labelmes(coco_json_path, labelme_json_folder)
```
#### labelme标注文件连续操作:划分labelme数据集->转化为coco格式
```python
labelme_folder = r"D:\Zhiyuan\pics_get\keypoints\20241118"
splited_labelmes_folder = tz.split_labelmes(labelme_folder, ratio=(0.85, 0.1, 0.05), format='.bmp')
categories_json_file = r"D:\Zhiyuan\code\tz\categories_person.json"
tz.splited_labelmes2cocos(splited_labelmes_folder, categories_json_file=categories_json_file)
```
### License
[MIT](https://github.com/wzy-777/tools_zy/blob/main/LICENSE)
[version-badge]: https://img.shields.io/badge/version-0.1-brightgreen.svg
[version-link]: https://pypi.org/project/tools-zy/
[license-badge]: https://img.shields.io/github/license/pythonml/douyin_image.svg
Raw data
{
"_id": null,
"home_page": "https://github.com/wzy-777/tools_zy",
"name": "tools-zy",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": null,
"author": "Zhiyuan Wang",
"author_email": "WangZhiyuan@mail.ustc.edu.cn",
"download_url": "https://files.pythonhosted.org/packages/d1/99/792edc7677994bf2ad3705c5749027b029f8bdd768ddeda9ebb23e083bc6/tools_zy-0.1.8.0.tar.gz",
"platform": null,
"description": "# tools_zy[![Version][version-badge]][version-link] ![MIT License][license-badge]\r\n\r\n\r\n\u6b64\u5de5\u5177\u5305\u65e8\u5728\u7ed9AI\u5de5\u4f5c\u8005\u63d0\u4f9b\u4e00\u628a\u8d81\u624b\u7684\u5de5\u5177\uff0c\u5c3d\u91cf\u7b80\u5316\u975e\u6838\u5fc3\u7684\u5de5\u4f5c\u3002\\\r\n\u5176\u4e2d\u5305\u542b\u6df1\u5ea6\u5b66\u4e60\u6a21\u578b\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u4f1a\u7528\u5230\u7684\u4e00\u4e9b\u5de5\u5177\uff0c\u6bd4\u5982\u6570\u636e\u6574\u7406\u3001\u683c\u5f0f\u8f6c\u6362\u3001\u5212\u5206\u6570\u636e\u96c6\u7b49\u3002\r\n\r\n\u56e0\u6b64\u4e5f\u8981\u6ce8\u610f\uff0c\u5176\u4e2d\u67d0\u4e9b\u51fd\u6570\u53ef\u80fd\u5e76\u6ca1\u6709\u63d0\u4f9b\u8fc7\u591a\u81ea\u7531\u5ea6\uff0c\u5982\u679c\u9700\u8981\uff0c\u8bf7\u81ea\u884c\u4fee\u6539\u3002\r\n\r\n### \u5b89\u88c5\r\n\r\n```bash\r\n$ pip install tools-zy\r\n```\r\n\r\n### \u4f7f\u7528\r\n\r\n\u542b\u6709\u7684\u529f\u80fd\u793a\u4f8b\u5982\u4e0b\uff1a\r\n```python\r\nimport tools_zy as tz\r\n\r\n# \u590d\u5236\u3001\u79fb\u52a8\u6587\u4ef6\u5939\u4e2d\u4ee5.bmp\u7ed3\u5c3e\u7684\u6587\u4ef6\u3002\uff08\u8fd8\u652f\u6301\u6307\u5b9a\u6587\u4ef6\u540d\uff0c\u652f\u6301\u9012\u5f52\u64cd\u4f5c\uff09\r\ntz.copy_file(\"/home/org_folder\", \"/home/new_folder\", format=\".bmp\")\r\ntz.move_file(\"/home/org_folder\", \"/home/new_folder\", format=\".bmp\")\r\n\r\n# \u83b7\u53d6\uff08\u590d\u5236\u3001\u79fb\u52a8\uff09\u6587\u4ef6\u5939\u4e2d\u4ee5.bmp\u7ed3\u5c3e\u7684\u4e00\u4e9b\u968f\u673a\u6587\u4ef6\u3002\r\ntz.copy_some_random_files(\"/home/org_folder\", \"/home/new_folder\", 1000, format='.bmp')\r\ntz.move_some_random_files(\"/home/org_folder\", \"/home/new_folder\", 1000, format='.bmp')\r\n\r\n# \u5212\u5206\u5206\u7c7b\u6570\u636e\u96c6\r\nimg_folder = r\"/home/classify/rawData\" # \u5305\u542bn\u4e2a\u540d\u79f0\u4e3a\u6570\u5b57\u5e8f\u5217\u7684\u6587\u4ef6\u5939\r\nout_folder = r\"/home/classify/splitData\" # \r\ntz.split_classifid_images(img_folder, out_folder, (0.8, 0.2, 0), format=\".bmp\")\r\n# \u5212\u5206lablmes\u6570\u636e\u96c6 (\u5212\u5206\u56fe\u7247\u548cjson\u6587\u4ef6\u5230train, val, test\u6587\u4ef6\u5939)\r\nlabelme_folder = r\"D:\\Zhiyuan\\pics_get\\keypoints\\20241118\"\r\ndata_folder = tz.split_labelmes(labelme_folder, ratio=(0.85, 0.1, 0.05), format=\".bmp\")\r\n\r\n\r\n# \u5c06labelme\u7684json\u683c\u5f0f\u8f6c\u5316\u4e3acoco\u683c\u5f0f\uff0c\u8981\u6c42\u56fe\u7247\u548cjson\u6587\u4ef6\u540d\u76f8\u540c\u4e14\u5728\u540c\u4e00\u6587\u4ef6\u5939\u4e0b\r\nlabelme_json_folder = r'D:\\Zhiyuan\\pics_get\\keypoints\\keypoints\\20241030' \r\ncoco_json_path = r'D:\\Zhiyuan\\pics_get\\keypoints\\keypoints\\20241030.json'\r\ncategories_json_file = r\"D:\\Zhiyuan\\code\\tz\\categories_person.json\"\r\ntz.labelmes2coco(labelme_json_folder, coco_json_path, categories_json_file, bbox=[1, 1, 511, 1023])\r\ncoco_json_path = r'D:\\Zhiyuan\\pics_get\\keypoints\\keypoints\\20241121.json'\r\nlabelme_json_folder = r'D:\\Zhiyuan\\pics_get\\keypoints\\keypoints\\20241121'\r\ntz.coco2labelmes(coco_json_path, labelme_json_folder)\r\n\r\n\r\n\r\n```\r\n#### labelme\u6807\u6ce8\u6587\u4ef6\u8fde\u7eed\u64cd\u4f5c\uff1a\u5212\u5206labelme\u6570\u636e\u96c6->\u8f6c\u5316\u4e3acoco\u683c\u5f0f\r\n```python\r\nlabelme_folder = r\"D:\\Zhiyuan\\pics_get\\keypoints\\20241118\"\r\nsplited_labelmes_folder = tz.split_labelmes(labelme_folder, ratio=(0.85, 0.1, 0.05), format='.bmp')\r\ncategories_json_file = r\"D:\\Zhiyuan\\code\\tz\\categories_person.json\"\r\ntz.splited_labelmes2cocos(splited_labelmes_folder, categories_json_file=categories_json_file)\r\n```\r\n\r\n\r\n### License\r\n\r\n[MIT](https://github.com/wzy-777/tools_zy/blob/main/LICENSE)\r\n\r\n\r\n[version-badge]: https://img.shields.io/badge/version-0.1-brightgreen.svg\r\n[version-link]: https://pypi.org/project/tools-zy/\r\n[license-badge]: https://img.shields.io/github/license/pythonml/douyin_image.svg\r\n",
"bugtrack_url": null,
"license": null,
"summary": "Some tools for AI model training and inference.",
"version": "0.1.8.0",
"project_urls": {
"Homepage": "https://github.com/wzy-777/tools_zy"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4fc62d94e32c0854337782eead50e39f43ff3f03c1449887d22c31619f20ff3a",
"md5": "da1f0ee385f0660bc5890bdfcf44dfd4",
"sha256": "8b22cb34efa4071526579eac13b1bc79e2dc266bdc6bfc7fe564168d258e3e04"
},
"downloads": -1,
"filename": "tools_zy-0.1.8.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "da1f0ee385f0660bc5890bdfcf44dfd4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 9316,
"upload_time": "2025-01-03T09:50:58",
"upload_time_iso_8601": "2025-01-03T09:50:58.496881Z",
"url": "https://files.pythonhosted.org/packages/4f/c6/2d94e32c0854337782eead50e39f43ff3f03c1449887d22c31619f20ff3a/tools_zy-0.1.8.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d199792edc7677994bf2ad3705c5749027b029f8bdd768ddeda9ebb23e083bc6",
"md5": "66224dfaf7290146a3ca483b779c8fe6",
"sha256": "32f96fd44d313c741b1b130c0f55423e9ab79b2ded0837fac510c3e49ffaa432"
},
"downloads": -1,
"filename": "tools_zy-0.1.8.0.tar.gz",
"has_sig": false,
"md5_digest": "66224dfaf7290146a3ca483b779c8fe6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 9850,
"upload_time": "2025-01-03T09:51:01",
"upload_time_iso_8601": "2025-01-03T09:51:01.991922Z",
"url": "https://files.pythonhosted.org/packages/d1/99/792edc7677994bf2ad3705c5749027b029f8bdd768ddeda9ebb23e083bc6/tools_zy-0.1.8.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-03 09:51:01",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "wzy-777",
"github_project": "tools_zy",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "tools-zy"
}