Update README.md
Browse files3 unmodified lines45677891011121314141516171 unmodified line1920212223222324253 unmodified lines
This is the structure of the BLIPNet model. You can load the model with it, or you can create a bigger model for your task.
class BLIPNet(torch.nn.Module): class BLIPNet(torch.nn.Module): def __init__(self, ): super().__init__() #Generation Model self.model = BlipForConditionalGeneration.from_pretrained(MODEL_NAME, cache_dir="model") #Same with https://huggingface.co/uf-aice-lab/BLIP-Math self.ebd_dim = ebd_dim= 443136
#Classification Model fc_dim = 64 # You can choose a higher number for better performance, for example, 1024. self.head = nn.Sequential(1 unmodified line nn.ReLU(), ) self.score = nn.Linear(fc_dim, 5) #5 classes
def forward(self, pixel_values, input_ids): outputs = self.model(input_ids=input_ids, pixel_values=pixel_values, labels=input_ids) image_text_embeds = self.model.vision_model(pixel_values, return_dict=True).last_hidden_stateREADME.md+3-4