PRUTHVIn commited on
Commit
13a580c
·
verified ·
1 Parent(s): 08dc466

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. inference.py +17 -0
inference.py CHANGED
@@ -1,3 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from transformers import (
2
  Blip2Processor,
3
  Blip2ForConditionalGeneration,
 
1
+ import os
2
+ import torch
3
+ from huggingface_hub import hf_hub_download
4
+
5
+ # 1. Create the weights folder in the Space environment
6
+ os.makedirs("weights", exist_ok=True)
7
+
8
+ # 2. Download the heavy .pth file from your MODEL repo to the SPACE
9
+ # This only happens once when the Space starts up.
10
+ if not os.path.exists("weights/vqa_model.pth"):
11
+ print("Downloading weights from Model Hub...")
12
+ hf_hub_download(
13
+ repo_id="PRUTHVIn/vqa_project",
14
+ filename="weights/vqa_model.pth",
15
+ local_dir="."
16
+ )
17
+
18
  from transformers import (
19
  Blip2Processor,
20
  Blip2ForConditionalGeneration,