Closed ningmenghongcha closed 1 year ago
I'm facing the same situation too. I'm also curious about this.
@MoriKen254 @ningmenghongcha
Try this...
` import torch import numpy as np import segmentation_models_pytorch as smp import segmentation_models_pytorch.utils.metrics
ENCODER = 'mit_b4' ENCODER_WEIGHTS = 'imagenet' CLASSES = ['1'] ACTIVATION = 'sigmoid' # could be None for logits or 'softmax2d' for multiclass segmentation DEVICE = 'cuda'
train_dataset = Dataset( x_train_dir, y_train_dir, augmentation=get_training_augmentation(), preprocessing=get_preprocessing(preprocessing_fn), classes=CLASSES, )
valid_dataset = Dataset( x_valid_dir, y_valid_dir, preprocessing=get_preprocessing(preprocessing_fn), classes=CLASSES, )
train_loader = DataLoader(train_dataset, batch_size=8, shuffle=True, num_workers=0) valid_loader = DataLoader(valid_dataset, batch_size=1, shuffle=False, num_workers=0)
from segmentation_models_pytorch import utils loss = utils.losses.BCELoss() metrics = [ utils.metrics.IoU(threshold=0.2), utils.metrics.Fscore(), utils.metrics.Recall(), utils.metrics.Precision(), ]
optimizer = torch.optim.Adam([ dict(params=model.parameters(), lr=0.0001), ])
`
@chefkrym
thank you so much! it looks like smp.utils is used isnt it?
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.
I am following the example cars segmentation In order to train my custom data, I have written a train.py
` if name == 'main':
` However,it shows smp.utils module is deprecated.
How to use the latest module to avoid this warning?Maybe you can update the jupyter notebook. Thank you for your attention.