ManTD2003/MONAILabel-Tool

Python

0

2 commits

updated Jun 1, 2026

See the code

README

MONAI Label + OHIF Viewer - Hướng dẫn Deploy và Khởi chạy

Hướng dẫn này mô tả cách thiết lập và chạy OHIF Viewer tích hợp với MONAI Label để thực hiện AI segmentation trên hình ảnh y tế.

OHIF + MONAI Label


📋 Mục lục


🐳 Khởi chạy OHIF + Orthanc với Docker

1. Di chuyển vào thư mục OHIF-AI

cd OHIF-AI

2. Khởi động các services

Sử dụng script có sẵn:

bash start.sh

Hoặc chạy trực tiếp lệnh docker compose:

docker compose -f ./docker-compose.yml up --build

3. Kiểm tra các services

Sau khi khởi động, các services sẽ chạy tại:

ServiceURLMô tả
OHIF Viewerhttp://localhost:1026Giao diện web OHIF
Orthanc DICOM Serverhttp://localhost:8042DICOM Web Server
MONAI SAM2http://localhost:8002MONAI Label API (nếu dùng SAM2)

Cấu trúc Docker Compose

Docker Compose bao gồm 3 services chính:

  • ohif_viewer: OHIF Viewer với Nginx reverse proxy
  • orthanc: Orthanc DICOM Server để lưu trữ và quản lý ảnh DICOM
  • monai_sam2: MONAI Label server với hỗ trợ GPU

📤 Upload dữ liệu DICOM

Qua giao diện Orthanc Web

  1. Truy cập http://localhost:8042
  2. Click Upload ở góc trên bên trái
  3. Chọn Select files to upload và chọn tất cả các file DICOM
  4. Click Start the upload để upload lên Orthanc server

🚀 Khởi động MONAI Label Server

Lưu ý: Nếu bạn sử dụng service monai_sam2 trong Docker Compose, server đã được khởi động tự động. Phần này dành cho trường hợp bạn muốn chạy MONAI Label riêng biệt.

Chạy MONAI Label Server (ngoài Docker)

monailabel start_server \
    --app apps/radiology \
    --studies http://localhost:8042/dicom-web \
    --conf models <model_name>

Các model được hỗ trợ

Model NameMô tả
allLoad tất cả các model
segmentation_spleenPhân đoạn lá lách
segmentationSegmentation tổng quát
segmentation_vertebraPhân đoạn đốt sống
deepeditDeepEdit model
deepgrow_2dDeepGrow 2D
deepgrow_3dDeepGrow 3D
localization_spineĐịnh vị cột sống
localization_vertebraĐịnh vị đốt sống
sw_fasteditSliding Window FastEdit

Ví dụ khởi chạy

Một model:

monailabel start_server --app apps/radiology --studies http://localhost:8042/dicom-web --port 8000 --conf models segmentation_spleen

Nhiều model:

monailabel start_server --app apps/radiology --studies http://localhost:8042/dicom-web --port 8000 --conf models segmentation_spleen,deepgrow_2d

Tất cả model:

monailabel start_server --app apps/radiology --studies http://localhost:8042/dicom-web --port 8000 --conf models all

🖼️ Sử dụng OHIF Viewer kết nối với MONAI Label

Truy cập OHIF Viewer đã kết nối với MONAI Label

Mở trình duyệt và truy cập: http://localhost:8000/ohif/

Giao diện OHIF Viewer đã kết nối với MONAI Label

Sau khi mở OHIF, bạn sẽ thấy danh sách các study đã upload:

OHIF Study List

Mở MONAI Label Plugin

  1. Click vào study cần annotate
  2. Trong trang labeling, click nút MONAI Label ở góc trên bên phải

MONAI Label Plugin


🤖 Auto Segmentation

Chạy Auto Segmentation

  1. MONAI Label đã load pre-trained weights sẵn
  2. Click nút Run trong panel MONAI Label bên phải

Lưu ý: Pre-trained models sẽ được download tự động khi khởi động MONAI Label server và lưu tại thư mục apps/radiology/model/ (ví dụ: pretrained_segmentation_spleen.pt)

Kết quả Segmentation

Kết quả auto segmentation sẽ hiển thị như sau:

Auto Segmentation Result

Chỉnh sửa và Submit Label

  1. Sử dụng OHIF segmentation editor để chỉnh sửa thủ công nếu cần
  2. Click Submit Label trên panel plugin bên phải để lưu annotation

Lưu ý: Annotations sẽ được lưu tại thư mục labels/final trong dataset

Edit and Submit


📚 Training và Active Learning

MONAI Label hỗ trợ active learning và fine-tuning models trong quá trình sử dụng.

Update Model

  1. Sau khi annotate và submit labels
  2. Click nút Update Model trong MONAI Label plugin
  3. Server sẽ fetch ground truth labels và fine-tune model

Training Options

Cấu hình Training

Bạn có thể điều chỉnh các tham số training trong panel options:

  • Max epochs
  • Batch size
  • Learning rate
  • ...

Active Learning Strategy

MONAI Label hỗ trợ các chiến lược active learning:

StrategyMô tả
randomChọn ngẫu nhiên
firstChọn sample đầu tiên
lastChọn sample cuối cùng

Sau khi train, các images đã được labeled sẽ được đánh dấu và không được chọn lại trong các batch tiếp theo.

Active Learning


ManTD2003/MONAILabel-Tool

Python

0

2 commits

updated Jun 1, 2026

See the code

README

MONAI Label + OHIF Viewer - Hướng dẫn Deploy và Khởi chạy

Hướng dẫn này mô tả cách thiết lập và chạy OHIF Viewer tích hợp với MONAI Label để thực hiện AI segmentation trên hình ảnh y tế.

OHIF + MONAI Label


📋 Mục lục


🐳 Khởi chạy OHIF + Orthanc với Docker

1. Di chuyển vào thư mục OHIF-AI

cd OHIF-AI

2. Khởi động các services

Sử dụng script có sẵn:

bash start.sh

Hoặc chạy trực tiếp lệnh docker compose:

docker compose -f ./docker-compose.yml up --build

3. Kiểm tra các services

Sau khi khởi động, các services sẽ chạy tại:

ServiceURLMô tả
OHIF Viewerhttp://localhost:1026Giao diện web OHIF
Orthanc DICOM Serverhttp://localhost:8042DICOM Web Server
MONAI SAM2http://localhost:8002MONAI Label API (nếu dùng SAM2)

Cấu trúc Docker Compose

Docker Compose bao gồm 3 services chính:

  • ohif_viewer: OHIF Viewer với Nginx reverse proxy
  • orthanc: Orthanc DICOM Server để lưu trữ và quản lý ảnh DICOM
  • monai_sam2: MONAI Label server với hỗ trợ GPU

📤 Upload dữ liệu DICOM

Qua giao diện Orthanc Web

  1. Truy cập http://localhost:8042
  2. Click Upload ở góc trên bên trái
  3. Chọn Select files to upload và chọn tất cả các file DICOM
  4. Click Start the upload để upload lên Orthanc server

🚀 Khởi động MONAI Label Server

Lưu ý: Nếu bạn sử dụng service monai_sam2 trong Docker Compose, server đã được khởi động tự động. Phần này dành cho trường hợp bạn muốn chạy MONAI Label riêng biệt.

Chạy MONAI Label Server (ngoài Docker)

monailabel start_server \
    --app apps/radiology \
    --studies http://localhost:8042/dicom-web \
    --conf models <model_name>

Các model được hỗ trợ

Model NameMô tả
allLoad tất cả các model
segmentation_spleenPhân đoạn lá lách
segmentationSegmentation tổng quát
segmentation_vertebraPhân đoạn đốt sống
deepeditDeepEdit model
deepgrow_2dDeepGrow 2D
deepgrow_3dDeepGrow 3D
localization_spineĐịnh vị cột sống
localization_vertebraĐịnh vị đốt sống
sw_fasteditSliding Window FastEdit

Ví dụ khởi chạy

Một model:

monailabel start_server --app apps/radiology --studies http://localhost:8042/dicom-web --port 8000 --conf models segmentation_spleen

Nhiều model:

monailabel start_server --app apps/radiology --studies http://localhost:8042/dicom-web --port 8000 --conf models segmentation_spleen,deepgrow_2d

Tất cả model:

monailabel start_server --app apps/radiology --studies http://localhost:8042/dicom-web --port 8000 --conf models all

🖼️ Sử dụng OHIF Viewer kết nối với MONAI Label

Truy cập OHIF Viewer đã kết nối với MONAI Label

Mở trình duyệt và truy cập: http://localhost:8000/ohif/

Giao diện OHIF Viewer đã kết nối với MONAI Label

Sau khi mở OHIF, bạn sẽ thấy danh sách các study đã upload:

OHIF Study List

Mở MONAI Label Plugin

  1. Click vào study cần annotate
  2. Trong trang labeling, click nút MONAI Label ở góc trên bên phải

MONAI Label Plugin


🤖 Auto Segmentation

Chạy Auto Segmentation

  1. MONAI Label đã load pre-trained weights sẵn
  2. Click nút Run trong panel MONAI Label bên phải

Lưu ý: Pre-trained models sẽ được download tự động khi khởi động MONAI Label server và lưu tại thư mục apps/radiology/model/ (ví dụ: pretrained_segmentation_spleen.pt)

Kết quả Segmentation

Kết quả auto segmentation sẽ hiển thị như sau:

Auto Segmentation Result

Chỉnh sửa và Submit Label

  1. Sử dụng OHIF segmentation editor để chỉnh sửa thủ công nếu cần
  2. Click Submit Label trên panel plugin bên phải để lưu annotation

Lưu ý: Annotations sẽ được lưu tại thư mục labels/final trong dataset

Edit and Submit


📚 Training và Active Learning

MONAI Label hỗ trợ active learning và fine-tuning models trong quá trình sử dụng.

Update Model

  1. Sau khi annotate và submit labels
  2. Click nút Update Model trong MONAI Label plugin
  3. Server sẽ fetch ground truth labels và fine-tune model

Training Options

Cấu hình Training

Bạn có thể điều chỉnh các tham số training trong panel options:

  • Max epochs
  • Batch size
  • Learning rate
  • ...

Active Learning Strategy

MONAI Label hỗ trợ các chiến lược active learning:

StrategyMô tả
randomChọn ngẫu nhiên
firstChọn sample đầu tiên
lastChọn sample cuối cùng

Sau khi train, các images đã được labeled sẽ được đánh dấu và không được chọn lại trong các batch tiếp theo.

Active Learning