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

Conformance test add validation with batch_size #2652

Closed
Closed
Changes from 1 commit
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
15 changes: 9 additions & 6 deletions tests/post_training/pipelines/image_classification_timm.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,12 @@ def prepare_calibration_dataset(self):

def _validate(self):
val_dataset = datasets.ImageFolder(root=self.data_dir / "imagenet" / "val", transform=self.transform)
val_loader = torch.utils.data.DataLoader(val_dataset, batch_size=1, num_workers=2, shuffle=False)
val_loader = torch.utils.data.DataLoader(val_dataset, batch_size=self.batch_size, num_workers=2, shuffle=False)

dataset_size = len(val_loader)

# Initialize result tensors for async inference support.
predictions = np.zeros((dataset_size))
references = -1 * np.ones((dataset_size))
predictions = [[] for _ in range(dataset_size)]
references = [[] for _ in range(dataset_size)]

core = ov.Core()

Expand Down Expand Up @@ -164,8 +163,12 @@ def process_result(request, userdata):
references[i] = target

infer_queue.wait_all()

acc_top1 = accuracy_score(predictions, references)
flatten_predictions = []
flatten_references = []
for i in range(len(predictions)):
flatten_predictions.extend(predictions[i])
flatten_references.extend(references[i])
acc_top1 = accuracy_score(flatten_predictions, flatten_references)

self.run_info.metric_name = "Acc@1"
self.run_info.metric_value = acc_top1
Loading