-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issues with using model bundle for prediction #1876
Comments
Hi, thank you for the detailed report and sorry that you're having problems with RV. Approach 1I believe this error implies you are using the model bundle from the Approach 2I think I know what is going on here. You are probably specifying The workaround is to simply specify rastervision predict \
https://s3.amazonaws.com/azavea-research-public-data/raster-vision/examples/model-zoo-0.20/isprs-potsdam-ss/model-bundle.zip \
https://s3.amazonaws.com/azavea-research-public-data/raster-vision/examples/model-zoo-0.20/isprs-potsdam-ss/sample-predictions/sample-img-isprs-potsdam-ss.tif \
prediction_output/ \
--channel-order 0 1 2 Approach 3One reason for the worse results could be that you are using different stats to normalize the images with the It is also possible that your new data is significantly different from your training set, in which case, you would see worse results if your model does not generalize well. So I would recommend predicting on images from your training/validation set as a sanity check. |
Hi @AdeelH, Thank you for the prompt reply. For approach 1, I had tried using both bundles from the Will give your suggestion on the order of the parameters a go for approach 2. As for approach 3, I also thought of using the same validation image for a sanity check. The following is a comparison of the output of the validation during training vs output of the prediction (same image). This was done using the same model. (please ignore the difference in colour as I did not play around with the colour display of the outputs, but you can notice the lack of class predictions in the predicted output from the large regions of blacks (background)). |
I gave the change of
I was using the bundle in the
Please, you don't have to apologise. I am thankful for your devotion and work on developing RV. Having done development of frameworks before, I appreciate the dedication and hardwork required for developing these frameworks. Keep up the good work! |
Interesting. That error is precisely what happens when you pass I would recommend doing a fresh run (you can just run for 1 epoch to make it go faster) and then trying with the new bundle. Also, are you able to successfully run the example predict command in my previous comment? As for approach 1, can you try visualizing the predicted scores (like in the tutorial) to check if they are messed up before they are saved to file? |
Hi @AdeelH, So after following your suggestions, I have managed to get all 3 approaches running successfully! For With Still waiting on the results from using the |
Awesome! Glad you were able to get the If you have ruled out |
I actually did not try to resize the chips, both during training and prediction. Instead, I was thinking to crop/chip them into smaller chunks of size 64. I did this during training as follows:
where
and gave it to the Config
Apologies, I digressed. As I did not do any resizing, in my prediction script in
As a sanity check, can you help verify if what I had done does what I had intended? |
Ah. If you add the resize transform in my previous comment, your approach should hopefully work better. A more automatic way to do this would be to do something like: tf, _ = learner.cfg.data.get_data_transforms()
...
ds = SemanticSegmentationSlidingWindowGeoDataset.from_uris(
...,
transform=tf
)
This is basically what Raster Vision does internally when you predict via the
Your use of |
Omg! Now everything clicks. That probably explains why I see artifacts like the the ones below in my predicted outputs (from using the Ok, I will retrain my models but this time specifying |
I should hasten to add that using an To sum up: |
Tried this and Thank you @AdeelH for your help! Now everything is working. Quick question though, what is the difference between using |
Wonderful!
They are equivalent.
It should, yes. Using |
Yes, while searching for how to tackle the boundary artifacts, I came across that post of yours. Will play around with the different parameters. Once again, thank you for your help. Much appreciated. I'll close the issue since everything's working now. |
Hi,
Thank you for the awesome work on developing raster-vision.
I had manage to trained a model for semantic segmentation on satellite images using code adapted from the ISPRS Potsdam example.
However, I had run into issues using the model bundle for prediction. I had tried several ways and had ran into either failures or a varying degree of success. I have listed each of my approach and level of success below. Would very much appreciate your views on how I can use the model bundle effectively for prediction on unseen images/data.
Regardless of approach, my goal is to predict on a list of unseen images and to generate a prediction tif and vector file for each class.
Approach 1 - Using
Predictor
classFor the 1st approach, I had tried to use the
Predictor
class. I had tried this method with RV v0.12 with success. However, come v0.20, I got the following error:Note: I redacted some of the path information so the path looks weird. Please ignore the weird file paths.
The bundle I used was the
model-bundle.zip
file in thebundle
folder, generated by the training script. I have also tried using the model bundle file found in thetrain
folder, but that too, produced the same error.For reference, key lines of the code used for this approach is as follows:
Approach 2: Using the
predict
command-line commandThe 2nd approach I tried was to use the
predict
command-line command. For this approach, I used themodel-bundle.zip
file found in thebundle
folder generated when I finish the model training. However, I did not get far with this approach as I kept getting the following error:This is despite having provided the module bundle in the following format:
model-bundle.zip
filemodel-bundle.zip
file and specify the foldermodel-bundle.zip
file and specify themodel-bundle.zip
file (there was another model-bundle.zip file in the zip file)Approach 3:
My first approach was to use the
Learner
class as suggested here. Following is the script put together:I have tried this approach with the bundle found in the
train
folder. With this approach, I can successfully run the prediction. However, the prediction results is much poorer compared to the trained results (as indicated in the validation images used during training).Environment
The text was updated successfully, but these errors were encountered: