Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix,refactor] ImageNet HF support and fixes #30

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions examples/flava/callbacks/multimodal_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import torch
from data import default_text_transform, VL_MAX_LENGTH_DEFAULT
from imagenet_zeroshot_data import imagenet_classnames, openai_imagenet_template
from data.imagenet_zeroshot_data import imagenet_classnames, openai_imagenet_template
from pytorch_lightning import Callback, LightningDataModule
from pytorch_lightning.utilities import rank_zero_only
from tqdm import tqdm
Expand Down Expand Up @@ -50,8 +50,10 @@ def run_imagenet_zero_shot(model, dataloader, device, text_transform, *args, **k
classifier = _zero_shot_classifier(model, device, text_transform)
logger.info("Classifier built")
top1, top5, n = 0.0, 0.0, 0.0
for images, target in tqdm(dataloader):
images = images["image"].to(device)
for sample in tqdm(dataloader):
images = sample["image"]
target = sample["label"]
images = images.to(device)
target = target.to(device)

# predict
Expand Down
Loading