Update model evaluation to use gpu for on the cloud

Change model evaluation to use available device (CPU or CUDA).
This commit is contained in:
Claire Vlases
2026-06-05 13:31:33 -04:00
committed by GitHub
parent d30392c466
commit a1946f0901
+3 -2
View File
@@ -79,7 +79,8 @@ def _load_model(model_name: str):
except AttributeError:
model = constructor(pretrained=True)
model.eval().cpu()
device = "cuda" if torch.cuda.is_available() else "cpu"
model.eval().to(device)
# Deep clone all params and buffers to ensure no inference tensors remain
for param in model.parameters():
param.data = param.data.clone()
@@ -490,4 +491,4 @@ NODE_DISPLAY_NAME_MAPPINGS = {
"SaliencyMap": "Saliency Map (PAIR)",
"SaliencyComparison": "Saliency Comparison Grid (PAIR)",
"SaliencyArt": "Explainable AI",
}
}