Spaces:
Runtime error
Runtime error
Update app.py
Browse files3 unmodified lines456789101112131415163 unmodified linesfrom PIL import Imagefrom io import BytesIO# Load the fine-tuned modelmodel_path = '/content/model_after_5_epochs.pth'model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base")model.load_state_dict(torch.load(model_path))device = torch.device("cuda" if torch.cuda.is_available() else "cpu")model.to(device)tokenizer = AutoTokenizer.from_pretrained("Salesforce/blip-image-captioning-base")# Function to generate caption for the uploaded imagedef generate_caption(image):3 unmodified lines45678910111213141516171819203 unmodified linesfrom PIL import Imagefrom io import BytesIO# # Load the fine-tuned model# model_path = '/content/model_after_5_epochs.pth'# model = BlipForConditionalGeneration.from_pretrained("Salesforce/blip-image-captioning-base")# model.load_state_dict(torch.load(model_path))# device = torch.device("cuda" if torch.cuda.is_available() else "cpu")# model.to(device)# tokenizer = AutoTokenizer.from_pretrained("Salesforce/blip-image-captioning-base")model = BlipForConditionalGeneration.from_pretrained("MLInAi/CartoonCaptionGen")tokenizer = AutoTokenizer.from_pretrained("MLInAi/CartoonCaptionGen")# Function to generate caption for the uploaded imagedef generate_caption(image):
app.py+11-7