Scalar Type Error #1950
-
Hello, I'm trying to classify objects in aerial imagery using Raster Vision, and I'm following the training example in the Raster Vision tutorials. I'm hitting an error when I train the model. My training and validation images/labels are all 326x326 pixels (starting out with small images just to figure out this library). My code is as follows: class_config = ClassConfig(
names=['background', '0'],
colors=['lightgray', 'darkred'],
null_class='background')
train_image_uri = "path_to_geotiff"
train_label_uri = "path_to_geojson"
val_image_uri = "path_to_geotiff"
val_label_uri = "path_to_geojson"
train_ds = SemanticSegmentationSlidingWindowGeoDataset.from_uris(
class_config=class_config,
image_uri=train_image_uri,
label_vector_uri=train_label_uri,
label_vector_default_class_id=class_config.get_class_id('0'),
size=163,
stride=163,
)
val_ds = SemanticSegmentationSlidingWindowGeoDataset.from_uris(
class_config=class_config,
image_uri=val_image_uri,
label_vector_uri=val_label_uri,
label_vector_default_class_id=class_config.get_class_id('0'),
size=163,
stride=163,
) For 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=(163, 163),
pretrained=True)
data_cfg = SemanticSegmentationGeoDataConfig(
class_names=class_config.names,
class_colors=class_config.colors,
num_workers=0,
)
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-test/',
model=model,
train_ds=train_ds,
valid_ds=val_ds,
) Everything runs fine up to this point. Next, I train the model and get this error: learner.train(epochs=3)
I'm not sure how I can debug this error since it seems like it's happening deeper in Pytorch. Maybe one of my parameters are of the wrong type? Wondering if anyone has any advice. (Also, this is an offshoot of a previous question I had, which @AdeelH answered 🙏) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 12 replies
-
Please share the full stack trace. |
Beta Was this translation helpful? Give feedback.
Okay, interesting. I will need to take a closer look at it then. In the meantime, something like the following might serve as a quick-and-dirty patch:
And then use
SemanticSegmentationSlidingWindowGeoDatasetCustom
in place ofSemanticSegmentationSlidingWindowGeoDataset
.The
y
returned by the dataset should now have the dtypetorch.int64
.