@@ -416,7 +416,6 @@ def from_config(
416416 model = cls .build_blocks (
417417 model_config , vocabs , running_config = running_config
418418 ) # corresponds to build_task_specific_model
419- model ._maybe_init_image_generation (model_config , running_config )
420419 # TODO: handle this better at some point?
421420 model .share_decoder_embeddings = model_config .share_decoder_embeddings
422421 # generator -> shall it be called within build_blocks?
@@ -976,7 +975,7 @@ def build_blocks(cls, model_config, vocabs, running_config=None):
976975 share_embeddings = model_config .share_embeddings ,
977976 )
978977 decoder = build_decoder (model_config , running_config = running_config )
979- return cls (
978+ model = cls (
980979 encoder = encoder ,
981980 decoder = decoder ,
982981 adapter = adapter ,
@@ -988,7 +987,9 @@ def build_blocks(cls, model_config, vocabs, running_config=None):
988987 image_end_token_id = model_config .encoder .image_end_token_id ,
989988 vit_position_embeddings = model_config .vit_position_embeddings ,
990989 )
990+ model ._maybe_init_image_generation (model_config , running_config )
991991 # from there, the base blocks exist, and the rest is done in the from_opt from base class
992+ return model
992993
993994 def embed_vision_language_features (self , src , images ):
994995 # TODO: test with batch > 1?
0 commit comments