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