MinxuanQin
commited on
Commit
·
a210973
1
Parent(s):
3743c36
add cache dir
Browse files- app.py +2 -1
- model_loader.py +4 -5
app.py
CHANGED
@@ -8,7 +8,8 @@ from model_loader import *
|
|
8 |
|
9 |
|
10 |
# load dataset
|
11 |
-
ds = load_dataset("test")
|
|
|
12 |
|
13 |
# define selector
|
14 |
model_name = st.sidebar.selectbox(
|
|
|
8 |
|
9 |
|
10 |
# load dataset
|
11 |
+
#ds = load_dataset("test")
|
12 |
+
ds = load_dataset("HuggingFaceM4/VQAv2", split="validation", cache_dir="cache", streaming=False)
|
13 |
|
14 |
# define selector
|
15 |
model_name = st.sidebar.selectbox(
|
model_loader.py
CHANGED
@@ -8,7 +8,6 @@ import requests
|
|
8 |
from transformers import ViltProcessor, ViltForQuestionAnswering
|
9 |
from transformers import AutoProcessor, AutoModelForCausalLM
|
10 |
from transformers import BlipProcessor, BlipForQuestionAnswering
|
11 |
-
from nltk.corpus import wordnet
|
12 |
|
13 |
import os
|
14 |
import requests
|
@@ -25,7 +24,6 @@ import torchvision.transforms as transforms
|
|
25 |
from transformers import VisualBertForMultipleChoice, VisualBertForQuestionAnswering, BertTokenizerFast, AutoTokenizer, ViltForQuestionAnswering
|
26 |
|
27 |
from PIL import Image
|
28 |
-
from nltk.corpus import wordnet
|
29 |
import time
|
30 |
|
31 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
@@ -50,14 +48,15 @@ def load_model(name):
|
|
50 |
|
51 |
return (processor, model)
|
52 |
|
53 |
-
|
54 |
def load_dataset(type):
|
55 |
if type == "train":
|
56 |
-
return load_dataset("HuggingFaceM4/VQAv2", split="train", streaming=False)
|
57 |
elif type == "test":
|
58 |
-
return load_dataset("HuggingFaceM4/VQAv2", split="validation", streaming=False)
|
59 |
else:
|
60 |
raise ValueError("invalid dataset: ", type)
|
|
|
61 |
|
62 |
|
63 |
def tokenize_function(examples, processor):
|
|
|
8 |
from transformers import ViltProcessor, ViltForQuestionAnswering
|
9 |
from transformers import AutoProcessor, AutoModelForCausalLM
|
10 |
from transformers import BlipProcessor, BlipForQuestionAnswering
|
|
|
11 |
|
12 |
import os
|
13 |
import requests
|
|
|
24 |
from transformers import VisualBertForMultipleChoice, VisualBertForQuestionAnswering, BertTokenizerFast, AutoTokenizer, ViltForQuestionAnswering
|
25 |
|
26 |
from PIL import Image
|
|
|
27 |
import time
|
28 |
|
29 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
|
|
48 |
|
49 |
return (processor, model)
|
50 |
|
51 |
+
'''
|
52 |
def load_dataset(type):
|
53 |
if type == "train":
|
54 |
+
return load_dataset("HuggingFaceM4/VQAv2", split="train", cache_dir="cache", streaming=False)
|
55 |
elif type == "test":
|
56 |
+
return load_dataset("HuggingFaceM4/VQAv2", split="validation", cache_dir="cache", streaming=False)
|
57 |
else:
|
58 |
raise ValueError("invalid dataset: ", type)
|
59 |
+
'''
|
60 |
|
61 |
|
62 |
def tokenize_function(examples, processor):
|