Closed QinghongLin closed 1 year ago
just replace the blip2_model.py
line 12-line 30 to this. then can work.
def initialize_model(self):
if self.device == 'cpu':
self.data_type = torch.float32
else:
self.data_type = torch.float16
# processor = Blip2Processor.from_pretrained("Salesforce/blip2-opt-2.7b")
# model = Blip2ForConditionalGeneration.from_pretrained(
# "Salesforce/blip2-opt-2.7b", torch_dtype=self.data_type
# )
# for gpu with small memory
processor = BlipProcessor.from_pretrained("Salesforce/blip-image-captioning-base")
model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base")
model.to(self.device)
if self.device != 'cpu':
model.half()
return processor, model
I follow the instruction and run python main.py but meet such an error: