Help regarding Chipped Datasets #2063
-
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
NaN loss usually means that the learning rate is too high. Try |
Beta Was this translation helpful? Give feedback.
-
Tried with 1e-4 and 1e-6 but it didn't work. Whenever i use a single image and label with the SemanticSegmentationRandomWindowGeoDataset, it seems the model is actually learning between the classes. from rastervision.core.data import ClassConfig
from rastervision.core.data.utils import make_ss_scene
import albumentations as A
import torch
from rastervision.pytorch_learner import (
SemanticSegmentationRandomWindowGeoDataset,
SemanticSegmentationSlidingWindowGeoDataset,
SemanticSegmentationVisualizer,
SemanticSegmentationGeoDataConfig,
SolverConfig,
SemanticSegmentationLearnerConfig,
SemanticSegmentationLearner)
train_image_uri = '../rasters/train-images/S23W064-245_2022-01-01_12.tif'
train_label_uri = '../rasters/train-labels/S23W064-245_2022-01-01_12.tif'
val_image_uri = '../rasters/test-images/S23W064-246_2022-01-01_2.tif'
val_label_uri = '../rasters/test-labels/S23W064-246_2022-01-01_2.tif'
class_config = ClassConfig(
names=['background', 'foreground'],
colors=['lightgray', 'darkred'],
null_class='background')
data_augmentation_transform = A.Compose([
A.Flip(),
A.ShiftScaleRotate(),
A.OneOf([
A.HueSaturationValue(hue_shift_limit=10),
A.RGBShift(),
A.ToGray(),
A.ToSepia(),
A.RandomBrightness(),
A.RandomGamma(),
]),
A.CoarseDropout(max_height=32, max_width=32, max_holes=5)
])
train_ds = SemanticSegmentationRandomWindowGeoDataset.from_uris(
class_config=class_config,
image_uri=train_image_uri,
label_raster_uri=train_label_uri,
size_lims=(150, 200),
out_size=256,
max_windows=256)
model = torch.hub.load(
'AdeelH/pytorch-fpn:0.3',
'make_fpn_resnet',
name='resnet18',
fpn_type='panoptic',
num_classes=len(class_config),
fpn_channels=128,
in_channels=3,
out_size=(256, 256),
pretrained=True)
data_cfg = SemanticSegmentationGeoDataConfig(
class_names=class_config.names,
class_colors=class_config.colors,
num_workers=10, # increase to use multi-processing
)
solver_cfg = SolverConfig(
batch_sz=8,
lr=3e-2,
class_loss_weights=[1., 10.]
)
learner_cfg = SemanticSegmentationLearnerConfig(data=data_cfg, solver=solver_cfg)
learner = SemanticSegmentationLearner(
cfg=learner_cfg,
output_dir='./train-2/',
model=model,
train_ds=train_ds,
valid_ds=val_ds,
) Do you think it might be related to using SemanticSegmentationImageDataset on the chipped datasets that might be causing the model to fail on picking up the foreground class? |
Beta Was this translation helpful? Give feedback.
-
Hey AdeelH, makes sense! I tried bumping the loss weight but even with that it was not improving precision / recall for the silo bags class. I'm trying to create a COCO dataset to work on the object detection approach. Would you have an example of this implementation with Raster Vision ? |
Beta Was this translation helpful? Give feedback.
For the specification of the format, see here or here.
For usage with RV, see this tutorial.