Skip to content

Rastervision (Custom loss function for torch-hub models + custom model (maybe transformer based)) #2260

Answered by AdeelH
mmcs-work asked this question in Q&A
Discussion options

You must be logged in to vote

If you use a custom model or loss function, by passing it directly to the Learner constructor, you will not be able to re-construct it from the model bundle alone, as noted here:

You will need to pass it again when initializing the Learner from the model bundle:

learner = SemanticSegmentationLearner.from_model_bundle(
    model_bundle_uri='data/train-demo/model-bundle.zip',
    output_dir='data/train-demo/',
    model=my_model,
    loss=my_loss_func,
)

In the above example, the weights will be loaded from the bundle into the model that you passed in, so it's important that you pass in exactly the same model that you used for training.


If you do want the model to be re-constructable form…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@mmcs-work
Comment options

@AdeelH
Comment options

Answer selected by mmcs-work
@mmcs-work
Comment options

@AdeelH
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants