An error occurred: You have to specify input_ids
Hello,I am trying to run this code, but I encountered an unexpected error: “An error occurred: You have to specify input_ids”. This seems to come from the line of code: outputs = clip_model(**inputs). However, I have printed the previous line that determines the tensors and it looks like it correctly creates it (inputs = clip_processor(images=image, return_tensors=“pt”):!pip install --upgrade transformers!pip install --upgrade torch transformersfrom transformers import CLIPProcessor, CLIPModelfrom PIL import Imageimport torchimport numpy as npfrom sklearn.metrics.pairwise import cosine_similarityLoad CLIP model and processorclip_processor = CLIPProcessor.from_pretrained(“openai/clip-vit-base-patch32”)clip_model = CLIPModel.from_pretrained(“openai/clip-vit-base-patch32”)def get_clip_embedding(image_path):try:image = Image.open(image_path)inputs = clip_processor(images=image, return_tensors=“pt”)outputs = clip_model(**inputs)# Debugging print to check outputsprint(“Model outputs:”, outputs)embedding = outputs.last_hidden_state.mean(dim=1).squeeze().detach().numpy()return embeddingexcept Exception as e:print(f"An error occurred while processing {image_path}: {str(e)}")return Noneimage_path = “/content/drive/My Drive/COCO/sample_exp/000000580410.jpg”image_embedding = get_clip_embedding(image_path)