Spaces:
Runtime error
Runtime error
ShreyMehra commited on
Update app.py
Browse files27 unmodified lines28293031323334352 unmodified lines3839404142434413 unmodified lines5859606162636427 unmodified lineswith st.spinner("🤖 AI is at Work! "):device = "cuda" if torch.cuda.is_available() else "cpu"print(1)inputs = processor(images=input_image, return_tensors="pt").to(device, torch.float32)print(2)pixel_values = inputs.pixel_values2 unmodified lines# pixel_values = pixel_values.to(torch.float32)print(3)generated_ids = model.to(device, torch.float32).generate(pixel_values=pixel_values, max_length=25)print(4)generated_caption = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]13 unmodified linesdef load_model(self):global modelglobal processormodel = Blip2ForConditionalGeneration.from_pretrained("Shrey23/Image-Captioning", torch_dtype=torch.float16) #, device_map="auto", load_in_8bit=Trueprocessor = AutoProcessor.from_pretrained("Salesforce/blip2-opt-2.7b")def main():27 unmodified lines28293031323334352 unmodified lines3839404142434413 unmodified lines5859606162636427 unmodified lineswith st.spinner("🤖 AI is at Work! "):device = "cuda" if torch.cuda.is_available() else "cpu"print(1, device)inputs = processor(images=input_image, return_tensors="pt").to(device, torch.float16)print(2)pixel_values = inputs.pixel_values2 unmodified lines# pixel_values = pixel_values.to(torch.float32)print(3)generated_ids = model.generate(pixel_values=pixel_values, max_length=25) #.to(device, torch.float32)print(4)generated_caption = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]13 unmodified linesdef load_model(self):global modelglobal processormodel = Blip2ForConditionalGeneration.from_pretrained("Shrey23/Image-Captioning", device_map="auto", load_in_8bit=True, torch_dtype=torch.float16) #,processor = AutoProcessor.from_pretrained("Salesforce/blip2-opt-2.7b")def main():
app.py+4-4