Skip to content

Linear probing with imageGPT assertion error when using pixel_values #482

@kristosh

Description

@kristosh

I am using code for the linear_probing_with_ImageGPT.ipynb and work with linear probing. I am using python 3.10 with pytorch version 2.6.0 and transformers 4.48.3 and I am using the provided code here:

```
train_ds, test_ds = load_dataset('cifar10', split=['train[:10]', 'test[:10]'])
# split up training into training + validation
splits = train_ds.train_test_split(test_size=0.1)
train_ds = splits['train']
val_ds = splits['test']

dataset = load_dataset('cifar10')
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

feature_extractor = ImageGPTFeatureExtractor.from_pretrained("openai/imagegpt-small")
model = ImageGPTModel.from_pretrained("openai/imagegpt-small")
model.to(device)

url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
image = Image.open(requests.get(url, stream=True).raw)

encoding = feature_extractor(image, return_tensors="pt")
pixel_values = encoding.pixel_values.to(device)
```

I am facing a problem in the last line of my code, where the attribute pixel_values is not recognized and I am getting an

error: raise AttributeError.

The same issue I got when I run the code through the google colab.

I am firstly, trying to understand what this pixel_values does in general and how to solve this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions