Project-MONAI / MONAILabel

MONAI Label is an intelligent open source image labeling and learning tool.
https://docs.monai.io/projects/label
Apache License 2.0
626 stars 196 forks source link

Deprecated `IgniteMetric` in deepedit #1731

Closed KumoLiu closed 3 months ago

KumoLiu commented 3 months ago
tests/integration/endoscopy/test_trainer.py::EndPointSession::test_deepedit_trainer [2024-08-13 11:25:00,373] [37388] [MainThread] [INFO] (monailabel.utils.async_tasks.task:41) - Train request: {'model': 'deepedit', 'max_epochs': 1, 'name': 'net_test_deepedit_trainer_01', 'val_split': 0.5, 'multi_gpu': False}
[2024-08-13 11:25:00,373] [37388] [MainThread] [INFO] (monailabel.tasks.train.basic_train:436) - Train Request (input): {'model': 'deepedit', 'max_epochs': 1, 'name': 'net_test_deepedit_trainer_01', 'val_split': 0.5, 'multi_gpu': False}
[2024-08-13 11:25:00,373] [37388] [MainThread] [INFO] (monailabel.tasks.train.basic_train:449) - CUDA_VISIBLE_DEVICES: None
[2024-08-13 11:25:00,373] [37388] [MainThread] [INFO] (monailabel.tasks.train.basic_train:469) - Distributed Training = FALSE
[2024-08-13 11:25:00,373] [37388] [MainThread] [INFO] (monailabel.tasks.train.basic_train:496) - 0 - Train Request (final): {'name': 'net_test_deepedit_trainer_01', 'pretrained': True, 'device': 'cuda:0', 'max_epochs': 1, 'early_stop_patience': -1, 'val_split': 0.5, 'train_batch_size': 8, 'val_batch_size': 4, 'multi_gpu': False, 'gpus': 'all', 'dataset': ['SmartCacheDataset', 'CacheDataset', 'PersistentDataset', 'Dataset'], 'dataloader': ['ThreadDataLoader', 'DataLoader'], 'tracking': ['mlflow', 'None'], 'tracking_uri': '', 'tracking_experiment_name': '', 'model': 'deepedit', 'run_id': '20240813_112500'}
[2024-08-13 11:25:00,373] [37388] [MainThread] [INFO] (monailabel.tasks.train.basic_train:629) - 0 - Using Device: cuda:0; IDX: 0
[2024-08-13 11:25:00,374] [37388] [MainThread] [INFO] (monailabel.tasks.train.basic_train:522) - Run/Output Path: /tmp/MONAILabel/tests/data/apps/endoscopy/model/deepedit/net_test_deepedit_trainer_01
[2024-08-13 11:25:00,374] [37388] [MainThread] [INFO] (monailabel.tasks.train.basic_train:538) - Tracking: mlflow 
[2024-08-13 11:25:00,374] [37388] [MainThread] [INFO] (monailabel.tasks.train.basic_train:539) - Tracking URI: file:///tmp/MONAILabel/tests/data/apps/endoscopy/model/deepedit/net_test_deepedit_trainer_01/mlruns; 
[2024-08-13 11:25:00,374] [37388] [MainThread] [INFO] (monailabel.tasks.train.basic_train:540) - Tracking Experiment Name: deepedit; Run Name: run_20240813_112500
[2024-08-13 11:25:00,374] [37388] [MainThread] [INFO] (monailabel.tasks.train.basic_train:414) - Total Records for Training: 3
[2024-08-13 11:25:00,374] [37388] [MainThread] [INFO] (monailabel.tasks.train.basic_train:415) - Total Records for Validation: 2
[2024-08-13 11:25:00,390] [37388] [MainThread] [INFO] (monailabel.tasks.train.basic_train:332) - 0 - Records for Validation: 2
[2024-08-13 11:25:00,392] [37388] [MainThread] [ERROR] (uvicorn.error:412) - Exception in ASGI application
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/uvicorn/protocols/http/h11_impl.py", line 407, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/usr/local/lib/python3.10/dist-packages/uvicorn/middleware/proxy_headers.py", line 69, in __call__
    return await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/applications.py", line 123, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/cors.py", line 85, in __call__
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/middleware/exceptions.py", line 65, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 756, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 776, in app
    await route.handle(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 297, in handle
    await self.app(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 77, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/usr/local/lib/python3.10/dist-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/usr/local/lib/python3.10/dist-packages/starlette/routing.py", line 72, in app
    response = await func(request)
  File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 278, in app
    raw_response = await run_endpoint_function(
  File "/usr/local/lib/python3.10/dist-packages/fastapi/routing.py", line 191, in run_endpoint_function
    return await dependant.call(**values)
  File "/tmp/MONAILabel/monailabel/endpoints/train.py", line 97, in api_run_model
    return run_model(model, params, run_sync, enqueue)
  File "/tmp/MONAILabel/monailabel/endpoints/train.py", line 56, in run_model
    res, detail = AsyncTask.run("train", request=request, params=params, force_sync=run_sync, enqueue=enqueue)
  File "/tmp/MONAILabel/monailabel/utils/async_tasks/task.py", line 48, in run
    return instance.train(request), None
  File "/tmp/MONAILabel/monailabel/interfaces/app.py", line 423, in train
    result = task(request, self.datastore())
  File "/tmp/MONAILabel/monailabel/tasks/train/basic_train.py", line 470, in __call__
    res = self.train(0, world_size, req, datalist)
  File "/tmp/MONAILabel/monailabel/tasks/train/basic_train.py", line 547, in train
    context.evaluator = self._create_evaluator(context)
  File "/tmp/MONAILabel/monailabel/tasks/train/basic_train.py", line 669, in _create_evaluator
    key_val_metric=self.val_key_metric(context),
  File "/tmp/MONAILabel/tests/data/apps/endoscopy/lib/trainers/deepedit.py", line 119, in val_key_metric
    "val_mean_iou": MeanIoUMetric(output_transform=from_engine(["pred", "label"])),
  File "/tmp/MONAILabel/tests/data/apps/endoscopy/lib/trainers/deepedit.py", line 161, in __init__
    super().__init__(metric_fn=metric_fn, output_transform=output_transform, save_details=save_details)
  File "/usr/local/lib/python3.10/dist-packages/monai/utils/deprecate_utils.py", line 109, in _wrapper
    raise DeprecatedError(msg)
monai.utils.deprecate_utils.DeprecatedError: Class `IgniteMetric` was removed in version 1.4. Use IgniteMetricHandler instead of IgniteMetric.
KumoLiu commented 3 months ago

Hi @tangy5, please help take a look at this issue. https://github.com/search?q=repo%3AProject-MONAI%2FMONAILabel%20IgniteMetric&type=code

tangy5 commented 3 months ago

Hi @tangy5, please help take a look at this issue. https://github.com/search?q=repo%3AProject-MONAI%2FMONAILabel%20IgniteMetric&type=code

Thanks Yun for this quick update.