Update app.py
Browse files
app.py
CHANGED
@@ -3,17 +3,18 @@ import torch
|
|
3 |
from transformers import AutoProcessor, AutoModelForCausalLM
|
4 |
from huggingface_hub import hf_hub_download
|
5 |
from PIL import Image
|
|
|
6 |
|
7 |
processor = AutoProcessor.from_pretrained("microsoft/git-base-vqav2")
|
8 |
-
model = AutoModelForCausalLM.from_pretrained("
|
9 |
|
10 |
-
|
|
|
|
|
11 |
image = Image.open(file_path).convert("RGB")
|
12 |
|
13 |
pixel_values = processor(images=image, return_tensors="pt").pixel_values
|
14 |
|
15 |
-
question = "How many people are there?"
|
16 |
-
|
17 |
input_ids = processor(text=question, add_special_tokens=False).input_ids
|
18 |
input_ids = [processor.tokenizer.cls_token_id] + input_ids
|
19 |
input_ids = torch.tensor(input_ids).unsqueeze(0)
|
|
|
3 |
from transformers import AutoProcessor, AutoModelForCausalLM
|
4 |
from huggingface_hub import hf_hub_download
|
5 |
from PIL import Image
|
6 |
+
from datasets import load_dataset
|
7 |
|
8 |
processor = AutoProcessor.from_pretrained("microsoft/git-base-vqav2")
|
9 |
+
model = AutoModelForCausalLM.from_pretrained("Multimodal-Fatima/OK-VQA_train")
|
10 |
|
11 |
+
dataset = load_dataset("question","answers","image")
|
12 |
+
|
13 |
+
file_path = hf_hub_download(repo_id="Multimodal-Fatima/OK-VQA_train", repo_type="dataset")
|
14 |
image = Image.open(file_path).convert("RGB")
|
15 |
|
16 |
pixel_values = processor(images=image, return_tensors="pt").pixel_values
|
17 |
|
|
|
|
|
18 |
input_ids = processor(text=question, add_special_tokens=False).input_ids
|
19 |
input_ids = [processor.tokenizer.cls_token_id] + input_ids
|
20 |
input_ids = torch.tensor(input_ids).unsqueeze(0)
|