Name | augmentationer JSON |
Version |
0.4.2
JSON |
| download |
home_page | None |
Summary | None |
upload_time | 2024-10-31 08:28:35 |
maintainer | None |
docs_url | None |
author | hyeonho cho |
requires_python | <4.0,>=3.8 |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Augmentationer
Augmentationer는 이미지와 해당 라벨을 다양한 방식으로 증강하는 파이썬 라이브러리입니다.
## 주요 기능
- 이미지 회전
- 가우시안 노이즈 추가
- 블러 효과 적용
- 그레이스케일 변환
- 랜덤 크롭
- 투시 변환
- 대비 조정
- 소금-후추 노이즈 추가
- 이미지 좌우 반전
- 밝기 조정
- 색상 지터링
- 채널 셔플
## 설치 방법
```
pip install augmentationer
```
## 사용 방법
### 기본 사용법
```python
from augmentationer import augmentationer
from augmentationer.function import *
# 증강 함수 정의
augmentation_functions = [
lambda img, lbl: rotate_image_and_labels(img, lbl, 30, 0.3),
lambda img, lbl: (add_gaussian_noise(img)),
lambda img, lbl: (apply_blur(img)),
lambda img, lbl: (convert_color(img)),
lambda img, lbl: apply_random_crop(img, lbl, 0.8),
lambda img, lbl: apply_perspective_transform(img, lbl, 0.2),
lambda img, lbl: (change_contrast(img)),
lambda img, lbl: (add_salt_pepper_noise(img)),
lambda img, lbl: (flip_image_and_labels(img, lbl)),
lambda img, lbl: (adjust_brightness(img)),
lambda img, lbl: (color_jitter(img)),
lambda img, lbl: (channel_shuffle(img)),
]
# augmentationer 실행
augmentationer("images", "labels", "output", augmentation_functions, "aug_prefix")
```
### 멀티 사용법
여러 가지 증강 설정을 적용하려면 다음과 같이 사용할 수 있습니다:
```python
from augmentationer import augmentationer
from augmentationer.function import *
# 증강 함수 세트 정의
augmentation_functions_1 = [
lambda img, lbl: rotate_image_and_labels(img, lbl, 30, 0.3),
lambda img, lbl: (add_gaussian_noise(img)),
lambda img, lbl: (apply_blur(img)),
lambda img, lbl: (convert_color(img)),
lambda img, lbl: apply_random_crop(img, lbl, 0.8),
lambda img, lbl: apply_perspective_transform(img, lbl, 0.2),
]
augmentation_functions_2 = [
lambda img, lbl: (change_contrast(img)),
lambda img, lbl: (add_salt_pepper_noise(img)),
lambda img, lbl: (flip_image_and_labels(img, lbl)),
lambda img, lbl: (adjust_brightness(img)),
lambda img, lbl: (color_jitter(img)),
lambda img, lbl: (channel_shuffle(img)),
]
augmentation_functions_3 = [
lambda img, lbl: (add_gaussian_noise(img)),
lambda img, lbl: (apply_blur(img)),
lambda img, lbl: (convert_color(img)),
lambda img, lbl: apply_random_crop(img, lbl, 0.8),
lambda img, lbl: apply_perspective_transform(img, lbl, 0.2),
]
# 여러 증강 설정 적용
augmentationer("images", "labels", "output", augmentation_functions_1, "augmentation_1")
augmentationer("images", "labels", "output", augmentation_functions_2, "augmentation_2")
augmentationer("images", "labels", "output", augmentation_functions_3, "augmentation_3")
```
이 방법을 사용하면 여러 가지 증강 설정을 독립적으로 적용할 수 있으며, 각 설정에 대해 접두사가 붙은 이름의 파일이 생성됩니다.
### Visualizer 사용법
증강된 이미지와 라벨을 시각화하려면 다음과 같이 `visualizer` 함수를 사용할 수 있습니다:
```python
from augmentationer import visualizer
# 이미지와 라벨 파일 경로 지정
image_path = 'output/images/image2_augmentation_3.jpg'
label_path = 'output/labels/image2_augmentation_3.txt'
# visualizer 실행 (class_colors 지정은 선택. 선택 안할 시 랜덤으로 컬러 지정됨.)
visualizer(image_path, label_path, target_class_ids=[0,1], text=False, class_colors={0: (255, 0, 0), 1: (0, 255, 0)})
# 클래스 지정없이 시각화 (기본 값 : 랜덤 컬러 지정, 모든 클래스 표시, 텍스트 표시)
visualizer(image_path, label_path)
```
이 함수는 지정된 이미지를 열고, 해당하는 라벨 정보를 이미지 위에 표시합니다. 각 객체는 녹색 폴리곤으로 표시되며, 클래스 ID도 함께 표시됩니다.
## 주요 함수 설명
### augmentationer(image_folder, txt_folder, output_folder, augmentation_functions, aug_prefix)
주어진 이미지 폴더와 라벨 폴더에서 이미지를 읽어와 다양한 증강 함수를 적용한 후, 증강된 이미지와 라벨을 출력 폴더에 저장합니다.
매개변수:
- `image_folder` (str 또는 PathLike): 원본 이미지 파일들이 저장된 폴더 경로
- `txt_folder` (str 또는 PathLike): 원본 라벨 파일들이 저장된 폴더 경로
- `output_folder` (str 또는 PathLike): 증강된 이미지와 라벨 파일들을 저장할 출력 폴더 경로
- `augmentation_functions` (List[Callable]): 이미지와 라벨에 적용할 증강 함수들의 리스트
- `aug_prefix` (str): 증강된 파일 이름에 추가할 접두사 (예: "aug_1", "aug_2" 등, 증강된 파일 구분을 위해 사용)
### rotate_image_and_labels(image, labels, angle, padding_ratio=0.1)
이미지를 회전시키고 라벨을 조정합니다.
### add_gaussian_noise(image, mean=0, std=25, weight=0.25)
이미지에 가우시안 노이즈를 추가합니다.
### apply_blur(image, kernel_size=(5, 5), sigma=0)
이미지에 블러 효과를 적용합니다.
### convert_color(image)
이미지를 그레이스케일로 변환한 후 다시 컬러로 변환합니다.
### apply_random_crop(image, labels, crop_ratio=0.8)
이미지를 랜덤하게 자르고 라벨을 조정합니다.
### apply_perspective_transform(image, labels, strength=0.05)
이미지에 투시 변환을 적용하고 라벨을 조정합니다.
### change_contrast(image, alpha=1.5, beta=0)
이미지의 대비를 조정합니다.
### add_salt_pepper_noise(image, salt_vs_pepper=0.2, amount=0.004)
이미지에 소금과 후추 노이즈를 추가합니다.
### flip_image_and_labels(image, labels)
이미지를 수평으로 뒤집고 라벨을 조정합니다.
### adjust_brightness(image, brightness_range=(0.7, 1.3))
이미지의 밝기를 조정합니다.
### color_jitter(image, hue_shift=0.1, saturation_shift=0.3, value_shift=0.3)
이미지의 색조, 채도, 명도를 무작위로 변경합니다.
### channel_shuffle(image)
이미지의 색상 채널을 무작위로 섞습니다.
## 라이선스
이 프로젝트는 MIT 라이선스 하에 있습니다.
Raw data
{
"_id": null,
"home_page": null,
"name": "augmentationer",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": null,
"keywords": null,
"author": "hyeonho cho",
"author_email": "111675679+aesthetics-of-record@users.noreply.github.com",
"download_url": "https://files.pythonhosted.org/packages/28/63/fb275367627ed6e652ecbe5e89c820e3186382716ebdf3b8ee4c0a139e61/augmentationer-0.4.2.tar.gz",
"platform": null,
"description": "# Augmentationer\n\nAugmentationer\ub294 \uc774\ubbf8\uc9c0\uc640 \ud574\ub2f9 \ub77c\ubca8\uc744 \ub2e4\uc591\ud55c \ubc29\uc2dd\uc73c\ub85c \uc99d\uac15\ud558\ub294 \ud30c\uc774\uc36c \ub77c\uc774\ube0c\ub7ec\ub9ac\uc785\ub2c8\ub2e4.\n\n## \uc8fc\uc694 \uae30\ub2a5\n\n- \uc774\ubbf8\uc9c0 \ud68c\uc804\n- \uac00\uc6b0\uc2dc\uc548 \ub178\uc774\uc988 \ucd94\uac00\n- \ube14\ub7ec \ud6a8\uacfc \uc801\uc6a9\n- \uadf8\ub808\uc774\uc2a4\ucf00\uc77c \ubcc0\ud658\n- \ub79c\ub364 \ud06c\ub86d\n- \ud22c\uc2dc \ubcc0\ud658\n- \ub300\ube44 \uc870\uc815\n- \uc18c\uae08-\ud6c4\ucd94 \ub178\uc774\uc988 \ucd94\uac00\n- \uc774\ubbf8\uc9c0 \uc88c\uc6b0 \ubc18\uc804\n- \ubc1d\uae30 \uc870\uc815\n- \uc0c9\uc0c1 \uc9c0\ud130\ub9c1\n- \ucc44\ub110 \uc154\ud50c\n\n## \uc124\uce58 \ubc29\ubc95\n\n```\npip install augmentationer\n```\n\n## \uc0ac\uc6a9 \ubc29\ubc95\n\n### \uae30\ubcf8 \uc0ac\uc6a9\ubc95\n\n```python\nfrom augmentationer import augmentationer\nfrom augmentationer.function import *\n\n# \uc99d\uac15 \ud568\uc218 \uc815\uc758\naugmentation_functions = [\n lambda img, lbl: rotate_image_and_labels(img, lbl, 30, 0.3),\n lambda img, lbl: (add_gaussian_noise(img)),\n lambda img, lbl: (apply_blur(img)),\n lambda img, lbl: (convert_color(img)),\n lambda img, lbl: apply_random_crop(img, lbl, 0.8),\n lambda img, lbl: apply_perspective_transform(img, lbl, 0.2),\n lambda img, lbl: (change_contrast(img)),\n lambda img, lbl: (add_salt_pepper_noise(img)),\n lambda img, lbl: (flip_image_and_labels(img, lbl)),\n lambda img, lbl: (adjust_brightness(img)),\n lambda img, lbl: (color_jitter(img)),\n lambda img, lbl: (channel_shuffle(img)),\n]\n\n# augmentationer \uc2e4\ud589\naugmentationer(\"images\", \"labels\", \"output\", augmentation_functions, \"aug_prefix\")\n```\n\n### \uba40\ud2f0 \uc0ac\uc6a9\ubc95\n\n\uc5ec\ub7ec \uac00\uc9c0 \uc99d\uac15 \uc124\uc815\uc744 \uc801\uc6a9\ud558\ub824\uba74 \ub2e4\uc74c\uacfc \uac19\uc774 \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4:\n\n```python\nfrom augmentationer import augmentationer\nfrom augmentationer.function import *\n\n# \uc99d\uac15 \ud568\uc218 \uc138\ud2b8 \uc815\uc758\naugmentation_functions_1 = [\n lambda img, lbl: rotate_image_and_labels(img, lbl, 30, 0.3),\n lambda img, lbl: (add_gaussian_noise(img)),\n lambda img, lbl: (apply_blur(img)),\n lambda img, lbl: (convert_color(img)),\n lambda img, lbl: apply_random_crop(img, lbl, 0.8),\n lambda img, lbl: apply_perspective_transform(img, lbl, 0.2),\n]\n\naugmentation_functions_2 = [\n lambda img, lbl: (change_contrast(img)),\n lambda img, lbl: (add_salt_pepper_noise(img)),\n lambda img, lbl: (flip_image_and_labels(img, lbl)),\n lambda img, lbl: (adjust_brightness(img)),\n lambda img, lbl: (color_jitter(img)),\n lambda img, lbl: (channel_shuffle(img)),\n]\n\naugmentation_functions_3 = [\n lambda img, lbl: (add_gaussian_noise(img)),\n lambda img, lbl: (apply_blur(img)),\n lambda img, lbl: (convert_color(img)),\n lambda img, lbl: apply_random_crop(img, lbl, 0.8),\n lambda img, lbl: apply_perspective_transform(img, lbl, 0.2),\n]\n\n# \uc5ec\ub7ec \uc99d\uac15 \uc124\uc815 \uc801\uc6a9\naugmentationer(\"images\", \"labels\", \"output\", augmentation_functions_1, \"augmentation_1\")\naugmentationer(\"images\", \"labels\", \"output\", augmentation_functions_2, \"augmentation_2\")\naugmentationer(\"images\", \"labels\", \"output\", augmentation_functions_3, \"augmentation_3\")\n```\n\n\uc774 \ubc29\ubc95\uc744 \uc0ac\uc6a9\ud558\uba74 \uc5ec\ub7ec \uac00\uc9c0 \uc99d\uac15 \uc124\uc815\uc744 \ub3c5\ub9bd\uc801\uc73c\ub85c \uc801\uc6a9\ud560 \uc218 \uc788\uc73c\uba70, \uac01 \uc124\uc815\uc5d0 \ub300\ud574 \uc811\ub450\uc0ac\uac00 \ubd99\uc740 \uc774\ub984\uc758 \ud30c\uc77c\uc774 \uc0dd\uc131\ub429\ub2c8\ub2e4.\n\n### Visualizer \uc0ac\uc6a9\ubc95\n\n\uc99d\uac15\ub41c \uc774\ubbf8\uc9c0\uc640 \ub77c\ubca8\uc744 \uc2dc\uac01\ud654\ud558\ub824\uba74 \ub2e4\uc74c\uacfc \uac19\uc774 `visualizer` \ud568\uc218\ub97c \uc0ac\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4:\n\n```python\nfrom augmentationer import visualizer\n\n# \uc774\ubbf8\uc9c0\uc640 \ub77c\ubca8 \ud30c\uc77c \uacbd\ub85c \uc9c0\uc815\nimage_path = 'output/images/image2_augmentation_3.jpg'\nlabel_path = 'output/labels/image2_augmentation_3.txt'\n\n# visualizer \uc2e4\ud589 (class_colors \uc9c0\uc815\uc740 \uc120\ud0dd. \uc120\ud0dd \uc548\ud560 \uc2dc \ub79c\ub364\uc73c\ub85c \uceec\ub7ec \uc9c0\uc815\ub428.)\nvisualizer(image_path, label_path, target_class_ids=[0,1], text=False, class_colors={0: (255, 0, 0), 1: (0, 255, 0)})\n\n# \ud074\ub798\uc2a4 \uc9c0\uc815\uc5c6\uc774 \uc2dc\uac01\ud654 (\uae30\ubcf8 \uac12 : \ub79c\ub364 \uceec\ub7ec \uc9c0\uc815, \ubaa8\ub4e0 \ud074\ub798\uc2a4 \ud45c\uc2dc, \ud14d\uc2a4\ud2b8 \ud45c\uc2dc)\nvisualizer(image_path, label_path)\n```\n\n\uc774 \ud568\uc218\ub294 \uc9c0\uc815\ub41c \uc774\ubbf8\uc9c0\ub97c \uc5f4\uace0, \ud574\ub2f9\ud558\ub294 \ub77c\ubca8 \uc815\ubcf4\ub97c \uc774\ubbf8\uc9c0 \uc704\uc5d0 \ud45c\uc2dc\ud569\ub2c8\ub2e4. \uac01 \uac1d\uccb4\ub294 \ub179\uc0c9 \ud3f4\ub9ac\uace4\uc73c\ub85c \ud45c\uc2dc\ub418\uba70, \ud074\ub798\uc2a4 ID\ub3c4 \ud568\uaed8 \ud45c\uc2dc\ub429\ub2c8\ub2e4.\n\n## \uc8fc\uc694 \ud568\uc218 \uc124\uba85\n\n### augmentationer(image_folder, txt_folder, output_folder, augmentation_functions, aug_prefix)\n\n\uc8fc\uc5b4\uc9c4 \uc774\ubbf8\uc9c0 \ud3f4\ub354\uc640 \ub77c\ubca8 \ud3f4\ub354\uc5d0\uc11c \uc774\ubbf8\uc9c0\ub97c \uc77d\uc5b4\uc640 \ub2e4\uc591\ud55c \uc99d\uac15 \ud568\uc218\ub97c \uc801\uc6a9\ud55c \ud6c4, \uc99d\uac15\ub41c \uc774\ubbf8\uc9c0\uc640 \ub77c\ubca8\uc744 \ucd9c\ub825 \ud3f4\ub354\uc5d0 \uc800\uc7a5\ud569\ub2c8\ub2e4.\n\n\ub9e4\uac1c\ubcc0\uc218:\n\n- `image_folder` (str \ub610\ub294 PathLike): \uc6d0\ubcf8 \uc774\ubbf8\uc9c0 \ud30c\uc77c\ub4e4\uc774 \uc800\uc7a5\ub41c \ud3f4\ub354 \uacbd\ub85c\n- `txt_folder` (str \ub610\ub294 PathLike): \uc6d0\ubcf8 \ub77c\ubca8 \ud30c\uc77c\ub4e4\uc774 \uc800\uc7a5\ub41c \ud3f4\ub354 \uacbd\ub85c\n- `output_folder` (str \ub610\ub294 PathLike): \uc99d\uac15\ub41c \uc774\ubbf8\uc9c0\uc640 \ub77c\ubca8 \ud30c\uc77c\ub4e4\uc744 \uc800\uc7a5\ud560 \ucd9c\ub825 \ud3f4\ub354 \uacbd\ub85c\n- `augmentation_functions` (List[Callable]): \uc774\ubbf8\uc9c0\uc640 \ub77c\ubca8\uc5d0 \uc801\uc6a9\ud560 \uc99d\uac15 \ud568\uc218\ub4e4\uc758 \ub9ac\uc2a4\ud2b8\n- `aug_prefix` (str): \uc99d\uac15\ub41c \ud30c\uc77c \uc774\ub984\uc5d0 \ucd94\uac00\ud560 \uc811\ub450\uc0ac (\uc608: \"aug_1\", \"aug_2\" \ub4f1, \uc99d\uac15\ub41c \ud30c\uc77c \uad6c\ubd84\uc744 \uc704\ud574 \uc0ac\uc6a9)\n\n### rotate_image_and_labels(image, labels, angle, padding_ratio=0.1)\n\n\uc774\ubbf8\uc9c0\ub97c \ud68c\uc804\uc2dc\ud0a4\uace0 \ub77c\ubca8\uc744 \uc870\uc815\ud569\ub2c8\ub2e4.\n\n### add_gaussian_noise(image, mean=0, std=25, weight=0.25)\n\n\uc774\ubbf8\uc9c0\uc5d0 \uac00\uc6b0\uc2dc\uc548 \ub178\uc774\uc988\ub97c \ucd94\uac00\ud569\ub2c8\ub2e4.\n\n### apply_blur(image, kernel_size=(5, 5), sigma=0)\n\n\uc774\ubbf8\uc9c0\uc5d0 \ube14\ub7ec \ud6a8\uacfc\ub97c \uc801\uc6a9\ud569\ub2c8\ub2e4.\n\n### convert_color(image)\n\n\uc774\ubbf8\uc9c0\ub97c \uadf8\ub808\uc774\uc2a4\ucf00\uc77c\ub85c \ubcc0\ud658\ud55c \ud6c4 \ub2e4\uc2dc \uceec\ub7ec\ub85c \ubcc0\ud658\ud569\ub2c8\ub2e4.\n\n### apply_random_crop(image, labels, crop_ratio=0.8)\n\n\uc774\ubbf8\uc9c0\ub97c \ub79c\ub364\ud558\uac8c \uc790\ub974\uace0 \ub77c\ubca8\uc744 \uc870\uc815\ud569\ub2c8\ub2e4.\n\n### apply_perspective_transform(image, labels, strength=0.05)\n\n\uc774\ubbf8\uc9c0\uc5d0 \ud22c\uc2dc \ubcc0\ud658\uc744 \uc801\uc6a9\ud558\uace0 \ub77c\ubca8\uc744 \uc870\uc815\ud569\ub2c8\ub2e4.\n\n### change_contrast(image, alpha=1.5, beta=0)\n\n\uc774\ubbf8\uc9c0\uc758 \ub300\ube44\ub97c \uc870\uc815\ud569\ub2c8\ub2e4.\n\n### add_salt_pepper_noise(image, salt_vs_pepper=0.2, amount=0.004)\n\n\uc774\ubbf8\uc9c0\uc5d0 \uc18c\uae08\uacfc \ud6c4\ucd94 \ub178\uc774\uc988\ub97c \ucd94\uac00\ud569\ub2c8\ub2e4.\n\n### flip_image_and_labels(image, labels)\n\n\uc774\ubbf8\uc9c0\ub97c \uc218\ud3c9\uc73c\ub85c \ub4a4\uc9d1\uace0 \ub77c\ubca8\uc744 \uc870\uc815\ud569\ub2c8\ub2e4.\n\n### adjust_brightness(image, brightness_range=(0.7, 1.3))\n\n\uc774\ubbf8\uc9c0\uc758 \ubc1d\uae30\ub97c \uc870\uc815\ud569\ub2c8\ub2e4.\n\n### color_jitter(image, hue_shift=0.1, saturation_shift=0.3, value_shift=0.3)\n\n\uc774\ubbf8\uc9c0\uc758 \uc0c9\uc870, \ucc44\ub3c4, \uba85\ub3c4\ub97c \ubb34\uc791\uc704\ub85c \ubcc0\uacbd\ud569\ub2c8\ub2e4.\n\n### channel_shuffle(image)\n\n\uc774\ubbf8\uc9c0\uc758 \uc0c9\uc0c1 \ucc44\ub110\uc744 \ubb34\uc791\uc704\ub85c \uc11e\uc2b5\ub2c8\ub2e4.\n\n## \ub77c\uc774\uc120\uc2a4\n\n\uc774 \ud504\ub85c\uc81d\ud2b8\ub294 MIT \ub77c\uc774\uc120\uc2a4 \ud558\uc5d0 \uc788\uc2b5\ub2c8\ub2e4.\n",
"bugtrack_url": null,
"license": null,
"summary": null,
"version": "0.4.2",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "22b127a5b2d23a452db690e991a0c467a6970a486cfc5648fc296ae46787cda9",
"md5": "1d514aaf9c65dd6a393339207b848dc5",
"sha256": "c9aa8f21520b1f8d63dbd5c0fd454187cddf3831ba350029ee14b199bf011a21"
},
"downloads": -1,
"filename": "augmentationer-0.4.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1d514aaf9c65dd6a393339207b848dc5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 10383,
"upload_time": "2024-10-31T08:28:34",
"upload_time_iso_8601": "2024-10-31T08:28:34.288578Z",
"url": "https://files.pythonhosted.org/packages/22/b1/27a5b2d23a452db690e991a0c467a6970a486cfc5648fc296ae46787cda9/augmentationer-0.4.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2863fb275367627ed6e652ecbe5e89c820e3186382716ebdf3b8ee4c0a139e61",
"md5": "28547ce3a67c9108d022d6a6252f88cb",
"sha256": "63738cd7f86a497e769cb02e8a7adc9f028ae7b50cd5de2e0b860d56f031b6b8"
},
"downloads": -1,
"filename": "augmentationer-0.4.2.tar.gz",
"has_sig": false,
"md5_digest": "28547ce3a67c9108d022d6a6252f88cb",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 9328,
"upload_time": "2024-10-31T08:28:35",
"upload_time_iso_8601": "2024-10-31T08:28:35.431551Z",
"url": "https://files.pythonhosted.org/packages/28/63/fb275367627ed6e652ecbe5e89c820e3186382716ebdf3b8ee4c0a139e61/augmentationer-0.4.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-31 08:28:35",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "augmentationer"
}