The Captum tutorials all seem to be using .jpg images for feature attribution. Are other image formats accepted with their tutorial notebooks? If so, where can I find a list of accepted image formats? I wasn’t able to find anything in their documentation.
Can you clarify which tutorial and lines you’re talking about and whether it’s the input in the tutorials or output for attribution?
If you are referring to the input images used like in this tutorial: Captum · Model Interpretability for PyTorch where the input image is set as
img = Image.open('img/resnet/swan-3299528_1280.jpg'). There is no restriction that it has to be a jpg, since the actual model is looking for a tensor, and the image transormations in the notebook just require a PIL Image type. PIL itself supports many image formats so if you swapped that line out for a png file or other type, there shouldn’t be an issue: Image file formats - Pillow (PIL Fork) 9.2.0 documentation.
If you are referring to the output attribution figures, those aren’t jpegs, they are of type matplotlib.pyplot.figure — Matplotlib 3.5.3 documentation. From that tutorial that would be like this line
_ = viz.visualize_image_attr(np.tran... It outputs the attribution visualization and the input images in the args are numpy arrays so no specific image formats required there, you can read more on the method signature here: Captum · Model Interpretability for PyTorch.