Spaces:
Build error
Build error
Update app.py
Browse files17 unmodified lines181920212223242517 unmodified linesif image is None or not isinstance(image, Image.Image):return "Error: Invalid image type. Please upload a valid image."# Preprocess the image with paddingpixel_values = processor(images=image, return_tensors="pt", padding="max_length", truncation=True).pixel_values# Generate text caption with padding consideredoutput_ids = model.generate(pixel_values, max_length=16, num_beams=4, early_stopping=True)17 unmodified lines18192021222324252627282917 unmodified linesif image is None or not isinstance(image, Image.Image):return "Error: Invalid image type. Please upload a valid image."# Preprocess the image with padding and return tensorspixel_values = processor(images=image, return_tensors="pt", padding=True, truncation=True).pixel_values# Ensure the tensor is the correct sizeif pixel_values.shape[1] == 0:return "Error: Unable to create tensor. The image might be empty or invalid."# Generate text caption with padding consideredoutput_ids = model.generate(pixel_values, max_length=16, num_beams=4, early_stopping=True)
app.py+6-2