ankurgup510 commited on
Commit
80fdbac
1 Parent(s): 4e9dbe5

Create imagegpt

Browse files
Files changed (1) hide show
  1. imagegpt +13 -0
imagegpt ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import AutoImageProcessor, ImageGPTModel
2
+ from PIL import Image
3
+ import requests
4
+
5
+ url = "http://images.cocodataset.org/val2017/000000039769.jpg"
6
+ image = Image.open(requests.get(url, stream=True).raw)
7
+
8
+ image_processor = AutoImageProcessor.from_pretrained("openai/imagegpt-small")
9
+ model = ImageGPTModel.from_pretrained("openai/imagegpt-small")
10
+
11
+ inputs = image_processor(images=image, return_tensors="pt")
12
+ outputs = model(**inputs)
13
+ last_hidden_states = outputs.last_hidden_state