Comments (4)
I believe your model expects 256x256 inputs and you are passing in something larger. If you're using the code from this notebook, you might need to change 325 to 256.
P.S. please properly format your posts using GitHub markdown in the future.
from raster-vision.
TThanks you replay,i change 325 to 256,and rerun the code,and i get new error as following:
ValueError Traceback (most recent call last)
Cell In[35], [line 10](vscode-notebook-cell:?execution_count=35&line=10)
[1](vscode-notebook-cell:?execution_count=35&line=1) from rastervision.core.data import SemanticSegmentationLabels
[3](vscode-notebook-cell:?execution_count=35&line=3) predictions = learner.predict_dataset(
[4](vscode-notebook-cell:?execution_count=35&line=4) ds,
[5](vscode-notebook-cell:?execution_count=35&line=5) raw_out=True,
[6](vscode-notebook-cell:?execution_count=35&line=6) numpy_out=True,
[7](vscode-notebook-cell:?execution_count=35&line=7) predict_kw=dict(out_shape=(256, 256)),
[8](vscode-notebook-cell:?execution_count=35&line=8) progress_bar=True)
---> [10](vscode-notebook-cell:?execution_count=35&line=10) pred_labels = SemanticSegmentationLabels.from_predictions(
[11](vscode-notebook-cell:?execution_count=35&line=11) ds.windows,
[12](vscode-notebook-cell:?execution_count=35&line=12) predictions,
[13](vscode-notebook-cell:?execution_count=35&line=13) smooth=True,
[14](vscode-notebook-cell:?execution_count=35&line=14) extent=ds.scene.extent,
[15](vscode-notebook-cell:?execution_count=35&line=15) num_classes=len(class_config))
File [~/.local/lib/python3.10/site-packages/rastervision/core/data/label/semantic_segmentation_labels.py:210](https://file+.vscode-resource.vscode-cdn.net/media/lining/0BFD1A2A0BFD1A2A/mywork/rastervision/~/.local/lib/python3.10/site-packages/rastervision/core/data/label/semantic_segmentation_labels.py:210), in SemanticSegmentationLabels.from_predictions(cls, windows, predictions, extent, num_classes, smooth, crop_sz)
[184](https://file+.vscode-resource.vscode-cdn.net/media/lining/0BFD1A2A0BFD1A2A/mywork/rastervision/~/.local/lib/python3.10/site-packages/rastervision/core/data/label/semantic_segmentation_labels.py:184) """Instantiate from windows and their corresponding predictions.
[185](https://file+.vscode-resource.vscode-cdn.net/media/lining/0BFD1A2A0BFD1A2A/mywork/rastervision/~/.local/lib/python3.10/site-packages/rastervision/core/data/label/semantic_segmentation_labels.py:185)
[186](https://file+.vscode-resource.vscode-cdn.net/media/lining/0BFD1A2A0BFD1A2A/mywork/rastervision/~/.local/lib/python3.10/site-packages/rastervision/core/data/label/semantic_segmentation_labels.py:186) Args:
(...)
[207](https://file+.vscode-resource.vscode-cdn.net/media/lining/0BFD1A2A0BFD1A2A/mywork/rastervision/~/.local/lib/python3.10/site-packages/rastervision/core/data/label/semantic_segmentation_labels.py:207) Otherwise, a SemanticSegmentationDiscreteLabels.
[208](https://file+.vscode-resource.vscode-cdn.net/media/lining/0BFD1A2A0BFD1A2A/mywork/rastervision/~/.local/lib/python3.10/site-packages/rastervision/core/data/label/semantic_segmentation_labels.py:208) """
[209](https://file+.vscode-resource.vscode-cdn.net/media/lining/0BFD1A2A0BFD1A2A/mywork/rastervision/~/.local/lib/python3.10/site-packages/rastervision/core/data/label/semantic_segmentation_labels.py:209) labels = cls.make_empty(extent, num_classes, smooth=smooth)
...
[480](https://file+.vscode-resource.vscode-cdn.net/media/lining/0BFD1A2A0BFD1A2A/mywork/rastervision/~/.local/lib/python3.10/site-packages/rastervision/core/data/label/semantic_segmentation_labels.py:480) pixel_class_scores = pixel_class_scores[..., src_yslice, src_xslice]
--> [481](https://file+.vscode-resource.vscode-cdn.net/media/lining/0BFD1A2A0BFD1A2A/mywork/rastervision/~/.local/lib/python3.10/site-packages/rastervision/core/data/label/semantic_segmentation_labels.py:481) self.pixel_scores[..., dst_yslice, dst_xslice] += pixel_class_scores
[482](https://file+.vscode-resource.vscode-cdn.net/media/lining/0BFD1A2A0BFD1A2A/mywork/rastervision/~/.local/lib/python3.10/site-packages/rastervision/core/data/label/semantic_segmentation_labels.py:482) self.pixel_hits[dst_yslice, dst_xslice] += 1
ValueError: operands could not be broadcast together with shapes (3,256,256) (2,256,256) (3,256,256)
and my complete code as follow:
from rastervision.pytorch_learner import SemanticSegmentationLearner
learner = SemanticSegmentationLearner.from_model_bundle(
model_bundle_uri='./train-demo/model-bundle.zip',
output_dir='./train/',
model=model,
training=False
)
image_uri = f'longjiangbouter.tif'
label_uri = f'longjiangbouter.geojson'
from rastervision.core.data import ClassConfig
class_config = ClassConfig(
names=['building', 'background'],
colors=['orange', 'black'])
class_config.ensure_null_class()
from rastervision.core.data import ClassConfig
from rastervision.pytorch_learner import SemanticSegmentationSlidingWindowGeoDataset
import albumentations as A
ds = SemanticSegmentationSlidingWindowGeoDataset.from_uris(
class_config=class_config,
image_uri=image_uri,
size=256,
stride=256,
transform=A.Resize(256, 256))
from rastervision.core.data import SemanticSegmentationLabels
predictions = learner.predict_dataset(
ds,
raw_out=True,
numpy_out=True,
predict_kw=dict(out_shape=(256, 256)),
progress_bar=True)
pred_labels = SemanticSegmentationLabels.from_predictions(
ds.windows,
predictions,
smooth=True,
extent=ds.scene.extent,
num_classes=len(class_config))
from raster-vision.
The class config that you used to train the model and the class config you are using now are not identical. You might want to pass null_class='background'
to ClassConfig
.
from raster-vision.
thank your help,now i can run the code for prediction ,and now i retrain the model more epochs
from raster-vision.
Related Issues (20)
- Unable to install RasterVision HOT 3
- Issues with using model bundle for prediction HOT 15
- Cannot import ClassConfig on Kaggle HOT 16
- Cannot save prediction using colors from ClassConfig HOT 4
- Improve unit test coverage of CLI and `Runner`s
- Cannot plot batch with ObjectDetectionVisualizer HOT 4
- Multi-temporal raster source visualizer fails when batch size is 1 HOT 2
- Make it possible to exclude "null" class labels from the computation of metrics HOT 3
- RuntimeError: expected scalar type Long but found Int HOT 10
- Allow user to specify AOI box filtering behavior in sliding window datasets HOT 1
- self._hds cannot be converted to a Python object for pickling HOT 2
- Semantic Segmentation Labels not initializing properly from predictions when extent provided HOT 2
- use my trained modle to prediction ,has wrong happened HOT 2
- Migrate to `pydantic` v2
- MPL notice for use of everett library and LGPL for triangle
- v0.30 release checklist
- `ModuleNotFoundError: No module named 'rastervision.examples'` when running command from examples doc HOT 1
- Add ability to use different Objectdetection models than FasterRCNN HOT 1
- BATCH_CPU_JOB_QUEUE requires a value parseable by str HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from raster-vision.