nielsr HF staff commited on
Commit
cbdd0b8
1 Parent(s): 15b15c1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -3,6 +3,8 @@ from transformers import AutoProcessor, AutoTokenizer, AutoImageProcessor, AutoM
3
  import torch
4
  import open_clip
5
 
 
 
6
  torch.hub.download_url_to_file('http://images.cocodataset.org/val2017/000000039769.jpg', 'cats.jpg')
7
  torch.hub.download_url_to_file('https://huggingface.co/datasets/nielsr/textcaps-sample/resolve/main/stop_sign.png', 'stop_sign.png')
8
  torch.hub.download_url_to_file('https://cdn.openai.com/dall-e-2/demos/text2im/astronaut/horse/photo/0.jpg', 'astronaut.jpg')
@@ -23,9 +25,11 @@ vitgpt_processor = AutoImageProcessor.from_pretrained("nlpconnect/vit-gpt2-image
23
  vitgpt_model = VisionEncoderDecoderModel.from_pretrained("nlpconnect/vit-gpt2-image-captioning")
24
  vitgpt_tokenizer = AutoTokenizer.from_pretrained("nlpconnect/vit-gpt2-image-captioning")
25
 
 
 
26
  coca_model, _, coca_transform = open_clip.create_model_and_transforms(
27
  "coca_ViT-L-14",
28
- pretrained="laion2B-s13B-b90k-mscoco-2014.pt"
29
  )
30
 
31
  device = "cuda" if torch.cuda.is_available() else "cpu"
 
3
  import torch
4
  import open_clip
5
 
6
+ from huggingface_hub import hf_hub_download
7
+
8
  torch.hub.download_url_to_file('http://images.cocodataset.org/val2017/000000039769.jpg', 'cats.jpg')
9
  torch.hub.download_url_to_file('https://huggingface.co/datasets/nielsr/textcaps-sample/resolve/main/stop_sign.png', 'stop_sign.png')
10
  torch.hub.download_url_to_file('https://cdn.openai.com/dall-e-2/demos/text2im/astronaut/horse/photo/0.jpg', 'astronaut.jpg')
 
25
  vitgpt_model = VisionEncoderDecoderModel.from_pretrained("nlpconnect/vit-gpt2-image-captioning")
26
  vitgpt_tokenizer = AutoTokenizer.from_pretrained("nlpconnect/vit-gpt2-image-captioning")
27
 
28
+ filepath = hf_hub_download(repo_id="gpucce/CoCa", filename=""laion2B-s13B-b90k-mscoco-2014.pt")
29
+
30
  coca_model, _, coca_transform = open_clip.create_model_and_transforms(
31
  "coca_ViT-L-14",
32
+ pretrained=filepath,
33
  )
34
 
35
  device = "cuda" if torch.cuda.is_available() else "cpu"