Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ In our original paper, we acknowledge that there were anomalies in the test data
## 👉 Train
Prepare your own dataset and refer to the samples in `SAM-Med2D/data_demo` to replace them according to your specific scenario. You need to generate the `image2label_train.json` file before running `train.py`.

If you want to use mixed-precision training, please install [Apex](https://github.com/NVIDIA/apex). If you don't want to install Apex, you can comment out the line `from apex import amp` and set `use_amp` to False.
If you want to use mixed-precision training, please install [Apex](https://github.com/NVIDIA/apex).

```bash
cd ./SAM-Med2D
Expand Down
3 changes: 2 additions & 1 deletion train.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import numpy as np
import datetime
from torch.nn import functional as F
from apex import amp
import random


Expand Down Expand Up @@ -102,6 +101,8 @@ def prompt_and_decoder(args, batched_input, model, image_embeddings, decoder_ite


def train_one_epoch(args, model, optimizer, train_loader, epoch, criterion):
if args.use_amp:
from apex import amp
train_loader = tqdm(train_loader)
train_losses = []
train_iter_metrics = [0] * len(args.metrics)
Expand Down