Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #1

Open
wants to merge 210 commits into
base: feedback
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
210 commits
Select commit Hold shift + click to select a range
6230806
Setting up GitHub Classroom Feedback
github-classroom[bot] Nov 10, 2024
5d255e7
feat : add auto GPU warning code
jung0228 Nov 11, 2024
b733e2e
Create README.md
Batwan01 Nov 12, 2024
88f394a
Update README.md
Batwan01 Nov 12, 2024
7a7d62d
Update README.md
Batwan01 Nov 12, 2024
7c8b8d7
Update README.md
Batwan01 Nov 12, 2024
c0eb7fe
Update README.md
Batwan01 Nov 12, 2024
bb54379
Update README.md
Batwan01 Nov 12, 2024
1636b29
Update README.md
Batwan01 Nov 12, 2024
91a6c90
feat : 29 classes #3
Batwan01 Nov 13, 2024
805f986
feat : yolo Segmentation yolo #3
Batwan01 Nov 13, 2024
cc2ca5d
feat : gitignore
Batwan01 Nov 13, 2024
86420a4
feat : yolo Segmentation etc yolo #3
Batwan01 Nov 13, 2024
fe819e1
feat : gitignore
Batwan01 Nov 13, 2024
8aa3d11
Merge pull request #8 from boostcampaitech7:Batwan01/yolo_base
Batwan01 Nov 13, 2024
4d6699c
Merge branch 'Batwan01/yolo_base' into main
Batwan01 Nov 13, 2024
3f6ea4c
Merge branch 'main' of https://github.com/boostcampaitech7/level2-cv-…
Batwan01 Nov 13, 2024
eac5f22
feat : Add data viewer script with streamlit #10
jhuni17 Nov 13, 2024
19a5acf
feat : csv 변환 오류 해결 Fixes #9
Batwan01 Nov 13, 2024
a8fef6e
feat: custom aug 추가 yolo #3
Batwan01 Nov 13, 2024
9a207d7
Merge branch 'Batwan01/issue9' into main
Batwan01 Nov 13, 2024
b1d1df9
feat: add dataset.py
jung0228 Nov 13, 2024
fbac175
feat: add utils.py
jung0228 Nov 13, 2024
a47037e
feat: model.py
jung0228 Nov 13, 2024
194512b
feat: discord auto notifications
jung0228 Nov 14, 2024
3360ff0
feat: refactoring test
jung0228 Nov 14, 2024
27cfa9f
fix: dir root errors
jung0228 Nov 14, 2024
0119271
fix: fixes all path errors
jung0228 Nov 14, 2024
f57a4e0
fix: more clean message
jung0228 Nov 14, 2024
fe98fbf
fix: add model name to config file
jung0228 Nov 14, 2024
a0eb03a
fix: config
jung0228 Nov 14, 2024
ce7b064
Merge branch 'jhuni17/eda_with_streamlit' of https://github.com/boost…
jung0228 Nov 14, 2024
97f14da
fix: seperate server messaages
jung0228 Nov 14, 2024
fabc98e
feat : create yolo dataset #3
Batwan01 Nov 14, 2024
4c43890
fix: rm non use files
jung0228 Nov 14, 2024
870cf51
feat: ducknet test
jung0228 Nov 15, 2024
6310976
feat: smp model train
jung0228 Nov 18, 2024
a047ab9
feat: SMP Baseline code refactoring #23
jhuni17 Nov 18, 2024
65ba62e
feat: Add loss and scheduler script #23
jhuni17 Nov 18, 2024
0cccf74
feat: Fix bug in dataset and Add loss and scheduler in train, config
jhuni17 Nov 18, 2024
f863b23
feat: Fix bug in dataset and train script
jhuni17 Nov 18, 2024
0a9a890
feat: Minor fix
jhuni17 Nov 18, 2024
0eeaff2
feat: minor fix
jhuni17 Nov 18, 2024
08acfa6
chore: Update .gitignore
jhuni17 Nov 18, 2024
b020fcb
feat: Change optimizer -> AdamW
jhuni17 Nov 18, 2024
e453d83
feat: Add comment and minor fix
jhuni17 Nov 18, 2024
43a981c
feat: Add smp code
uddaniiii Nov 18, 2024
1765a4d
chore: Update .gitignore
uddaniiii Nov 18, 2024
d6ab7e2
feat: Add visualization for result csv file
uddaniiii Nov 18, 2024
658d4a9
remove: visualize_inference.py
uddaniiii Nov 18, 2024
5773cc3
chore: Update .gitignore
jhuni17 Nov 18, 2024
114d860
feat: Add wandb logging and fix config to select model in config.py
jhuni17 Nov 18, 2024
4974236
fix: wandb api key (personal key issue)
jhuni17 Nov 18, 2024
ec0b3d4
feat: Fix wandb logging step
jhuni17 Nov 18, 2024
d88dbb1
feat: Fix wandb log
jhuni17 Nov 18, 2024
9d9a200
feat: RefactoredUNet3+
Nov 19, 2024
2e73d74
remove: WrongLossFile UNet3+ #25
Nov 19, 2024
908ae00
fix: Inference
Nov 20, 2024
4e354c8
feat: UNet3+CGM
Nov 20, 2024
9362692
Merge remote-tracking branch 'origin/UNet3+' into jung0228/2-stage_le…
jung0228 Nov 20, 2024
d0da0e8
Merge branch 'main' into jhuni17/eda_with_streamlit
jhuni17 Nov 20, 2024
281c63d
fix: Dataset.py to train small object
jung0228 Nov 20, 2024
94bf94c
feat: Discord Alam code
jung0228 Nov 20, 2024
88cf1e8
fix: using relative path
jung0228 Nov 20, 2024
fc5e986
feat: Add validate script for checking
jhuni17 Nov 20, 2024
d48b5fa
rename: Chage dir name
jhuni17 Nov 20, 2024
23669a2
feat: Add test image visualization feature #10
jhuni17 Nov 20, 2024
544b425
Merge pull request #26 from boostcampaitech7/jhuni17/baseline_code_re…
jhuni17 Nov 20, 2024
8416dfa
Merge pull request #27 from boostcampaitech7/jhuni17/eda_with_streamlit
jhuni17 Nov 20, 2024
7ca1975
test: UNet3+ #25
Nov 20, 2024
1c100f1
feat: image-binary Data preprocessing #18
Nov 20, 2024
20da7d1
feat: diceLoss UNet3+ #25
Nov 20, 2024
bc39d2d
test: dice,[0.45, 0.35, 0.25, 0.2, 0.2] UNet3+ #25
Nov 20, 2024
c1d0c8e
test: iou UNet3+ #25
Nov 21, 2024
f39919f
Merge remote-tracking branch 'origin/jung0228/2-stage_learning' into …
Nov 21, 2024
147dd3d
refactor: discord URL to Config UNet3+ #25
Nov 21, 2024
b4b5866
feat: Mixed Precision UNet3+ #25
Nov 21, 2024
52a3042
feat: box detect and segmentation UNet3+ #25
Nov 21, 2024
79b3538
feat: spawn Multi Processing for yolo UNet3+ #25
Nov 21, 2024
cec78de
feat: Visualization Crop Image and Label UNet3+ #25
Nov 21, 2024
63fb211
feat: Labe Based Crop Train UNet3+ #25
Nov 21, 2024
981c532
feat: Make Dir for Visualization UNet3+ #25
Nov 21, 2024
1b34839
test: Added BottleNeck 75 UNet3+ #25
Nov 21, 2024
51412da
feat: Upsample -> ConvTranspose2dUNet3+ #25
Nov 22, 2024
286eb62
feat: ConvNext_L Backbone UNet3+ #25
Nov 22, 2024
ef0c5a8
fix: Chagne 'use column width' parameter to container
jhuni17 Nov 22, 2024
818b6f4
feat: Add val gt csv in validate script and Make val evaluate script
jhuni17 Nov 22, 2024
d9a8fa7
feat: Add option only make gt csv
jhuni17 Nov 22, 2024
7de9a06
fix: Change pred_df name
jhuni17 Nov 22, 2024
718dfe0
Merge pull request #30 from boostcampaitech7/jhuni17/baseline_code_re…
jhuni17 Nov 22, 2024
334e69e
feat: Add visualize validation data -> Not Finish
jhuni17 Nov 22, 2024
8dc0077
feat: Change image name in csv
jhuni17 Nov 22, 2024
c11c93d
Merge branch 'jhuni17/baseline_code_refactoring' into jhuni17/eda_wit…
jhuni17 Nov 22, 2024
1886ff9
Feat: Add dataset_gc.py
uddaniiii Nov 22, 2024
614f8c1
Merge branch 'main' of https://github.com/boostcampaitech7/level2-cv-…
uddaniiii Nov 22, 2024
c6159ff
test: dice_convNext UNet3+ #25
Nov 22, 2024
da95f38
feat: model_shape_check, comment CenterCrop #31
Nov 22, 2024
ec418ce
feat: Fix error and divide gt and pred
jhuni17 Nov 22, 2024
6160da5
feat: Add seed func and dataset class
jhuni17 Nov 22, 2024
9f922d1
Merge branch 'jhuni17/eda_with_streamlit' into jhuni17/baseline_code_…
jhuni17 Nov 22, 2024
1c28ed1
Merge pull request #32 from boostcampaitech7/jhuni17/baseline_code_re…
jhuni17 Nov 22, 2024
ec8a4c1
fix: focal_Loss UNet3+ #25
Nov 22, 2024
01e6845
fix: wrong weight init UNet3+ #25
Nov 22, 2024
f9af7e6
feat: Scalely Weighted Loss UNet3+ #25
Nov 22, 2024
761d90d
feat: Change scheduler and model
jhuni17 Nov 23, 2024
932c85c
Merge pull request #33 from boostcampaitech7/jhuni17/baseline_code_re…
jhuni17 Nov 23, 2024
e8f28ae
feat: Add eda ipynb #29
jhuni17 Nov 23, 2024
50935ee
feat: Add StratifiedXRayDataset with meta data in dataset.py #29
jhuni17 Nov 23, 2024
25a140b
feat: Add meta data path in config.py #29
jhuni17 Nov 23, 2024
5064b7b
feat: Add new train script with StratifiedXRayDataset and remove comm…
jhuni17 Nov 23, 2024
aa320b1
fix: Loss Bug UNet3+ #25
Nov 23, 2024
01df360
test: test UNet3+ #25
Nov 24, 2024
cd4bf4e
feat: Add StratifiedGroupKFold not post-cleansing
jhuni17 Nov 24, 2024
f7d3687
feat: Add group stratified k fold distribution
jhuni17 Nov 24, 2024
502f071
Merge pull request #34 from boostcampaitech7/jhuni17/data_cleansing_a…
jhuni17 Nov 24, 2024
26d16ab
feat: Add early stopping feature
jhuni17 Nov 24, 2024
aec0b89
feat: Refactoring mmsegmentation #23
jhuni17 Nov 24, 2024
925e705
feat: ResNet_UNet3+ UNet3+ #25
Nov 24, 2024
cf54ed2
feat: Crop Inference and Merge CSV UNet3+ #25
Nov 24, 2024
55713f6
feat: HRNet Model Create UNet3+ #25
Nov 24, 2024
4e8512e
test: test
Nov 24, 2024
6ef9b08
feat: Add wandb feature
jhuni17 Nov 25, 2024
2d33d70
Merge pull request #35 from boostcampaitech7/jhuni17/baseline_code_re…
jhuni17 Nov 25, 2024
8cbd3aa
feat: HRNet UNet3+ #25
Nov 25, 2024
b8d1360
Merge remote-tracking branch 'origin/main' into UNet3+
Nov 25, 2024
44a291f
Merge pull request #36 from boostcampaitech7/UNet3+
min000914 Nov 25, 2024
7b395b5
feat: lib UNet3+ #25
Nov 25, 2024
8b1f19b
Merge remote-tracking branch 'origin/main' into UNet3+
Nov 25, 2024
25b1921
Merge pull request #37 from boostcampaitech7/UNet3+
min000914 Nov 25, 2024
5b1621c
fix: Infebug UNet3+ #25
Nov 25, 2024
e3dbb10
fix: Scheduler UNet3+ #25
Nov 25, 2024
840b5d3
comment: filters UNet3+ #25
Nov 25, 2024
20f203c
fix: schedular bug fix max -> 'max' UNet3+ #25
Nov 25, 2024
5d332fe
fix: If Use ReduceLROnPlateau, Cant use Get_last_lr ->verbose=True
Nov 25, 2024
6412060
feat: boundary_loss to Loss.py
jung0228 Nov 25, 2024
026a876
fix: model Bug Fix UNet3+ #25
Nov 25, 2024
d83fea1
Merge branch 'main' of https://github.com/boostcampaitech7/level2-cv-…
Nov 25, 2024
a75326e
feat: SwinEncoder.py
jung0228 Nov 25, 2024
0a3168b
Merge branch 'main' of https://github.com/boostcampaitech7/level2-cv-…
jung0228 Nov 25, 2024
bd2d4df
fix: Train mode bug Fix UNet3+ #25
Nov 25, 2024
762c8d3
Merge branch 'main' of https://github.com/boostcampaitech7/level2-cv-…
Nov 25, 2024
36b3829
fix: train scheduler bug fix UNet3+ #25
Nov 25, 2024
316efaa
feat: swin encoder unet+++
jung0228 Nov 25, 2024
bc464a1
Merge remote-tracking branch 'origin/main' into main
jung0228 Nov 25, 2024
52328e1
feat: train mixed precison
jung0228 Nov 25, 2024
b3c40e6
fix: loss format error
jung0228 Nov 25, 2024
721847a
fix: main and mixed precision
jung0228 Nov 25, 2024
a3c540f
fix: discord message send
jung0228 Nov 25, 2024
ab0acc7
fix: absolute path to relative path
jung0228 Nov 25, 2024
53a54d6
feat: Revise config.py
jhuni17 Nov 25, 2024
26fcc56
feat: Add wandb, early stopping and revise config
jhuni17 Nov 25, 2024
5424576
feat: Add wandb and early stopping
jhuni17 Nov 25, 2024
b972e61
fix: Add epoch_loss
jhuni17 Nov 25, 2024
52b0f43
feat: Add wandb init
jhuni17 Nov 25, 2024
ec8e074
feat: Boundary Loss to Train
jung0228 Nov 25, 2024
ad53da9
Merge remote-tracking branch 'origin/main' into main
jung0228 Nov 25, 2024
d473345
feat: Experiment Name to Config
jung0228 Nov 25, 2024
190660b
fix: boundary Loss
jung0228 Nov 25, 2024
baf6e81
rm: scheduler bug
jung0228 Nov 25, 2024
5640343
feat: Update eda.ipynb
jhuni17 Nov 26, 2024
a0e3963
feat: Change wandb api_key
jhuni17 Nov 26, 2024
f6b2179
feat: HRNet UNet3+ #25
Nov 26, 2024
61c9d21
chore: .gitignore
chan-note Nov 26, 2024
472359a
feat: hybrid Loss
jung0228 Nov 26, 2024
039818d
Merge remote-tracking branch 'origin/main' into main
jung0228 Nov 26, 2024
df7aa86
fix: IoU Loss by -log method
jung0228 Nov 26, 2024
d7c79cb
feat: Add swin encoder #40
jhuni17 Nov 26, 2024
00fb38b
feat: Change img_size
jhuni17 Nov 26, 2024
e874cf1
Merge pull request #41 from boostcampaitech7/jhuni17/custom_encoder_smp
jhuni17 Nov 26, 2024
84ca308
feat: save split dataset list
chan-note Nov 26, 2024
0170bfb
feat: save dataset list
chan-note Nov 26, 2024
83f8c0e
feat: Change encoder name, img size
jhuni17 Nov 26, 2024
bc87cf6
Merge branch 'main' of https://github.com/boostcampaitech7/level2-cv-…
jhuni17 Nov 26, 2024
5cee377
comment: Remove needless code
jhuni17 Nov 26, 2024
de39185
feat: Add StratifiedXRayDataset
jhuni17 Nov 26, 2024
57991a9
feat: Fix StratifiedXRayDataset
jhuni17 Nov 26, 2024
679431f
feat: Edge Loss to loss.py
jung0228 Nov 26, 2024
b48f301
Merge remote-tracking branch 'origin/main' into main
jung0228 Nov 26, 2024
db027d8
fix: edge loss
jung0228 Nov 26, 2024
bdff513
feat: train for hybrid loss
jung0228 Nov 26, 2024
2746f1f
feat: goodSet UNet3+ #25
Nov 26, 2024
2fdb4c5
feat: Implement dataset cleansing functionality in data_cleansing.py #29
jhuni17 Nov 27, 2024
2c60986
feat: hybrid loss
chan-note Nov 27, 2024
1bdef1e
refactor: Remove visualization steps and specific mask removals from …
jhuni17 Nov 27, 2024
3fe7031
Merge branch 'main' of https://github.com/boostcampaitech7/level2-cv-…
jhuni17 Nov 27, 2024
e67986d
fix: train_meta_hybid.py
jung0228 Nov 27, 2024
0aeb6da
Merge remote-tracking branch 'origin/main' into main
jung0228 Nov 27, 2024
7da7177
feat: add dataset_transformed
Batwan01 Nov 27, 2024
e6933bd
feat: add dataset_transformed
Batwan01 Nov 27, 2024
01e9892
feat: get_train_transform()
Batwan01 Nov 27, 2024
aacfb69
feat: scheduler_type == "cosine"
Batwan01 Nov 27, 2024
ea51d9a
feat: for merge
jung0228 Nov 27, 2024
0277b20
Merge remote-tracking branch 'origin/main' into main
jung0228 Nov 27, 2024
dba9d1e
feat: add dataset statistics printing functionality in validate.py
jhuni17 Nov 27, 2024
6e80025
Merge remote-tracking branch 'origin/main' into main
jung0228 Nov 27, 2024
19b59f2
feat: onepiece setting
jung0228 Nov 27, 2024
e021868
feat: visualize crop Inference UNet3+ #25
Nov 29, 2024
9b0de18
test: HRNet UNet3+ UNet3+ #25
Nov 29, 2024
851aeb8
Merge branch 'main' of https://github.com/boostcampaitech7/level2-cv-…
Nov 29, 2024
9260df0
fix: loss.py
Batwan01 Nov 29, 2024
d67b5ae
Merge remote-tracking branch 'origin/main' into main
Batwan01 Nov 29, 2024
c51024e
refactor: cleaning #
Nov 30, 2024
8530094
feat: 3type_box_detect
Nov 30, 2024
5e0e6bf
refactory: clean
Nov 30, 2024
df6aabc
refactor: cleaning
Nov 30, 2024
0648431
Create z
Batwan01 Dec 9, 2024
021b7b4
Hand Bone Image Segmentation_팀 리포트(15조)
Batwan01 Dec 9, 2024
c24d63f
Delete docs/z
Batwan01 Dec 9, 2024
3a0cdf0
Rename bone_seg_CV_팀 리포트(15조).pdf to bone_seg_CV_팀 리포트.pdf
Batwan01 Dec 9, 2024
f8a13b9
Add files via upload
jung0228 Jan 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
*.txt
*.png
# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/en/_build/
docs/zh_cn/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

data/
data
.vscode
.idea
.DS_Store

# custom
*.pkl
*.pkl.json
*.log.json
*.csv
*.out
docs/modelzoo_statistics.md
mmdet/.mim
work_dirs/
wandb/

# Pytorch
*.pth
*.py~
*.sh~
*.pt
*.jpg
*.json

# wandb
wandb/

# mmsegmentation
configs/
demo/
docker/
docs/
mmseg/
projects/
resources/
tests/
tools/

*.gz
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<div align="right">
<a href="https://hits.seeyoufarm.com"><img src="https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https://github.com/boostcampaitech7/level2-cv-semanticsegmentation-cv-15-lv3&count_bg=%23C6D2FF&title_bg=%23555555&icon=&icon_color=%23FFFFFF&title=hits&edge_flat=false"/></a>
</div>

![image](https://github.com/user-attachments/assets/f328716c-8655-4068-b12d-ae5db115d497)
- 2024.11.13 10:00 ~ 2024.11.28 19:00
- X-ray 이미지에서 사람의 뼈를 Segmentation 하는 인공지능 만들기

| 커밋 유형 | 의미 |
| :-: | -|
|feat| 새로운 기능 추가|
|fix| 버그 수정|
|docs |문서 수정|
|style| 코드 formatting, 세미콜론 누락, 코드 자체의 변경이 없는 경우|
|refactor |코드 리팩토링|
|test| 테스트 코드, 리팩토링 테스트 코드 추가|
|chore| 패키지 매니저 수정, 그 외 기타 수정 ex) .gitignore|
|design| CSS 등 사용자 UI 디자인 변경|
|comment |필요한 주석 추가 및 변경|
|rename| 파일 또는 폴더 명을 수정하거나 옮기는 작업만인 경우|
|remove| 파일을 삭제하는 작업만 수행한 경우|
|!BREAKING |CHANGE 커다란 API 변경의 경우|
|!HOTFIX |급하게 치명적인 버그를 고쳐야 하는 경우|


## 팀원 소개

## :sunglasses:팀원 소개

| [![](https://avatars.githubusercontent.com/jung0228)](https://github.com/jung0228) | [![](https://avatars.githubusercontent.com/chan-note)](https://github.com/chan-note) | [![](https://avatars.githubusercontent.com/batwan01)](https://github.com/batwan01) | [![](https://avatars.githubusercontent.com/jhuni17)](https://github.com/jhuni17) | [![](https://avatars.githubusercontent.com/u/93571932?v=4)](https://github.com/uddaniiii) | [![](https://avatars.githubusercontent.com/u/48996852?v=4)](https://github.com/min000914) |
| ---------------------------------------------------- | ------------------------------------------------------ | --------------------------------------------------- | ------------------------------------------------------- | --------------------------------------------------- | ------------------------------------------------------- |
| [정현우](https://github.com/jung0228) | [임찬혁](https://github.com/chan-note) | [박지완](https://github.com/batwan01) | [최재훈](https://github.com/jhuni17) | [이단유](https://github.com/uddaniiii) | [민창기](https://github.com/min000914) |

## 대회 소개
![image](https://github.com/user-attachments/assets/4790d3af-b534-4751-b65c-a51da184ec65)


뼈는 우리 몸의 구조와 기능에 중요한 영향을 미치기 때문에, 정확한 뼈 분할은 의료 진단 및 치료 계획을 개발하는 데 필수적입니다.

Bone Segmentation은 인공지능 분야에서 중요한 응용 분야 중 하나로, 특히, 딥러닝 기술을 이용한 뼈 Segmentation은 많은 연구가 이루어지고 있으며, 다양한 목적으로 도움을 줄 수 있습니다.

질병 진단의 목적으로 뼈의 형태나 위치가 변형되거나 부러지거나 골절 등이 있을 경우, 그 부위에서 발생하는 문제를 정확하게 파악하여 적절한 치료를 시행할 수 있습니다.

수술 계획을 세우는데 도움이 됩니다. 의사들은 뼈 구조를 분석하여 어떤 종류의 수술이 필요한지, 어떤 종류의 재료가 사용될 수 있는지 등을 결정할 수 있습니다.

의료장비 제작에 필요한 정보를 제공합니다. 예를 들어, 인공 관절이나 치아 임플란트를 제작할 때 뼈 구조를 분석하여 적절한 크기와 모양을 결정할 수 있습니다.

의료 교육에서도 활용될 수 있습니다. 의사들은 병태 및 부상에 대한 이해를 높이고 수술 계획을 개발하는 데 필요한 기술을 연습할 수 있습니다.

## 사용된 데이터셋 정보

- **데이터셋 이름**:
- **출처**:

### 데이터셋 설명

Input : hand bone x-ray 객체가 담긴 이미지가 모델의 인풋으로 사용됩니다. segmentation annotation은 json file로 제공됩니다.

Output : 모델은 각 클래스(29개)에 대한 확률 맵을 갖는 멀티채널 예측을 수행하고, 이를 기반으로 각 픽셀을 해당 클래스에 할당합니다.

최종적으로 예측된 결과를 Run-Length Encoding(RLE) 형식으로 변환하여 csv 파일로 제출합니다.

---

146 changes: 146 additions & 0 deletions UNet3+/Code/CropInferecneRun.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import os
import importlib
import albumentations as A
from torch.utils.data import DataLoader
import torch
import pandas as pd
import numpy as np
import cv2
from tqdm.auto import tqdm
from ultralytics import YOLO
from torch.multiprocessing import set_start_method
import torch.nn.functional as F

import config
from DataSet.YoloInferenceDataset import XRayInferenceDataset


def keep_largest_connected_component(mask):
num_labels, labels, stats, _ = cv2.connectedComponentsWithStats(mask.astype(np.uint8), connectivity=8)
if num_labels <= 1:
return mask
largest_label = 1 + np.argmax(stats[1:, cv2.CC_STAT_AREA])
return (labels == largest_label).astype(np.uint8)


def encode_mask_to_rle(mask):
pixels = mask.flatten()
pixels = np.concatenate([[0], pixels, [0]])
runs = np.where(pixels[1:] != pixels[:-1])[0] + 1
runs[1::2] -= runs[::2]
return ' '.join(str(x) for x in runs)


def get_model_class(model_name):
module_name, class_name = model_name.rsplit(".", 1)
module = importlib.import_module(module_name)
return getattr(module, class_name)


def test(model, data_loader, thr=0.5):
model = model.cuda()
model.eval()

rles = []
filename_and_class = []
with torch.no_grad():
CLASS_COLORS = [
(255, 0, 0), (0, 255, 0), (0, 0, 255), (255, 255, 0),
(255, 0, 255), (0, 255, 255), (128, 128, 128), (255, 165, 0)
]

for step, (images, image_names, crop_boxes) in tqdm(enumerate(data_loader), total=len(data_loader)):
images = images.cuda()
outputs = model(images)

for output, image, image_name, crop_box in zip(outputs, images, image_names, crop_boxes):
start_x, start_y, end_x, end_y = crop_box
output = torch.sigmoid(output).detach().cpu().numpy()
crop_width, crop_height = end_x - start_x, end_y - start_y
output_height, output_width = output.shape[-2:]

if (output_width != crop_width) or (output_height != crop_height):
raise ValueError("Output size does not match crop size!")

image = (image.permute(1, 2, 0).cpu().numpy() * 255).astype(np.uint8)
overlay_mask = np.zeros_like(image, dtype=np.uint8)

for c, segm in enumerate(output):
binary_mask = (segm > thr).astype(np.uint8)
color = CLASS_COLORS[c]
color_mask = np.zeros_like(overlay_mask, dtype=np.uint8)
for i in range(3):
color_mask[:, :, i] = binary_mask * color[i]
overlay_mask = cv2.add(overlay_mask, color_mask)

blended_image = cv2.addWeighted(image, 0.7, overlay_mask, 0.3, 0)
clean_image_name = os.path.basename(image_name)
save_path = f"/data/ephemeral/home/MCG/YOLO_Detection_Model/test_last/{clean_image_name}"
cv2.imwrite(save_path, cv2.cvtColor(blended_image, cv2.COLOR_RGB2BGR))

for c, segm in enumerate(output):
binary_mask = (segm > thr).astype(np.uint8)
largest_component = keep_largest_connected_component(binary_mask)
full_size_mask = np.zeros((2048, 2048), dtype=np.uint8)
full_size_mask[start_y:end_y, start_x:end_x] = largest_component
rle = encode_mask_to_rle(full_size_mask)
rles.append(rle)
filename_and_class.append(f"{config.IND2CLASS[c]}_{image_name}")

return rles, filename_and_class


if __name__ == "__main__":
set_start_method("spawn", force=True)

# 동적으로 모델 로드
model_name = f"Model.{config.INFERENCE_MODEL_NAME}"
ModelClass = get_model_class(model_name)
model = ModelClass()
model.load_state_dict(torch.load(os.path.join(config.SAVED_DIR, config.INFERENCE_MODEL_NAME)))

yolo_model = YOLO("/data/ephemeral/home/MCG/YOLO_Detection_Model/best.pt")

pngs = {
os.path.relpath(os.path.join(root, fname), start=config.TEST_IMAGE_ROOT)
for root, _, files in os.walk(config.TEST_IMAGE_ROOT)
for fname in files
if os.path.splitext(fname)[1].lower() == ".png"
}

test_dataset = XRayInferenceDataset(
filenames=pngs,
yolo_model=yolo_model,
save_dir=config.SAVE_VISUALIZE_TRAIN_DATA_PATH,
draw_enabled=True
)

def custom_collate_fn(batch):
images, image_names, crop_boxes = zip(*batch)
return (
torch.stack(images),
list(image_names),
list(crop_boxes)
)

test_loader = DataLoader(
dataset=test_dataset,
batch_size=1,
shuffle=False,
num_workers=0,
drop_last=False,
collate_fn=custom_collate_fn
)

rles, filename_and_class = test(model, test_loader, thr=0.5)

classes, filename = zip(*[x.split("_") for x in filename_and_class])
image_name = [os.path.basename(f) for f in filename]

df = pd.DataFrame({
"image_name": image_name,
"class": classes,
"rle": rles,
})

df.to_csv(os.path.join(config.CSVDIR, config.CSVNAME), index=False)
Loading