Description
Describe the issue
My test
#Generate the IR model
import openvino as ov
from pathlib import Path
from nncf import compress_weights
MODEL_NAME = "efficientnet_b0"
MODEL_DIR = Path("Models")
MODEL_DIR.mkdir(parents=True, existence_ok=True)
weights = models.EfficientNet_B0_Weights.DEFAULT
model = models.efficientnet_b0(weights=weights)
model.eval()
batch_size=32
ov_model = ov.convert_model(model, input=[[batch_size, 3, 224, 224]])
ov.save_model(ov_model, MODEL_DIR / f"{MODEL_NAME}_{batch_size}_static.xml")
quantized_model = compress_weights(ov_model)
ov.save_model(quantized_model, MODEL_DIR / f"{MODEL_NAME}_{batch_size}_quantized.xml")
#Implementation Testing
...
batch_size=32
num_workers=0
val_dataset = datasets.ImageNet(root=IMAGENET_VAL_DIR, split='val', transform=val_transforms)
val_loader = torch.utils.data.DataLoader(val_dataset, batch_size=batch_size, shuffle=False, num_workers=num_workers, drop_last=True)
...
compiled_model = core.compile_model(model=MODEL_PATH, device_name=device)
input_layer = compiled_model.input(0)
output_layer = compiled_model.output(0)
...
for images, labels in val_loader:
inputs = images.numpy()
results = compiled_model(inputs={input_layer: inputs})
output = results[output_layer]
top1, top5 = accuracy(output, labels)
top1_total += top1
top5_total += top5
total += labels.size(0)
Show progress bar
elapsed = time.strftime("%H:%M:%S", time.gmtime(time.time() - start_time))
num_imput = num_imput + len(images)
print(f"\rmodel: {type_model} - device : {device} - Valid [{(num_imput):>7,}/{size_test:>7,}] - Elapsed: {elapsed} - ".replace(",", "."), end="")
batch_size:32, num_workers:0
model: quantized - device : GPU - Valid [ 49.984/ 50.000] - Elapsed: 00:03:42 - accuracy - Top-1: 77.01%, Top-5: 93.24%
model: quantized - device : CPU - Valid [ 49.984/ 50.000] - Elapsed: 00:06:50 - accuracy - Top-1: 77.01%, Top-5: 93.25%
model: quantized - device : NPU - Valid [ 49.984/ 50.000] - Elapsed: 00:12:21 - accuracy - Top-1: 77.03%, Top-5: 93.23%
model: static - device : GPU - Valid [ 49.984/ 50.000] - Elapsed: 00:03:46 - accuracy - Top-1: 77.65%, Top-5: 93.58%
model: static - device : CPU - Valid [ 49.984/ 50.000] - Elapsed: 00:06:46 - accuracy - Top-1: 77.68%, Top-5: 93.58%
model: static - device : NPU - Valid [ 49.984/ 50.000] - Elapsed: 00:12:25 - accuracy - Top-1: 77.68%, Top-5: 93.58%