imagetsr / imagegpt.py
ankurgup510's picture
Rename imagegpt to imagegpt.py
760d45b
raw
history blame
491 Bytes
from transformers import AutoImageProcessor, ImageGPTModel
from PIL import Image
import requests
url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
image_processor = AutoImageProcessor.from_pretrained("openai/imagegpt-small")
model = ImageGPTModel.from_pretrained("openai/imagegpt-small")
inputs = image_processor(images=image, return_tensors="pt")
outputs = model(**inputs)
last_hidden_states = outputs.last_hidden_state