Spaces:
Sleeping
Sleeping
hf app fix
Browse files
hfapp.py
CHANGED
|
@@ -33,10 +33,10 @@ def localize_anomalies(input_img, preset="edm2-img64-s-fid", load_from_hub=False
|
|
| 33 |
img = np.array(input_img)
|
| 34 |
img = torch.from_numpy(img).permute(2, 0, 1).unsqueeze(0)
|
| 35 |
img = img.float().to(device)
|
| 36 |
-
model = load_model_from_hub(preset=preset, device=device)
|
| 37 |
img_likelihood, score_norms = run_inference(model, img)
|
| 38 |
nll, pct, ref_nll = compute_gmm_likelihood(
|
| 39 |
-
score_norms, model_dir=
|
| 40 |
)
|
| 41 |
|
| 42 |
outstr = f"Anomaly score: {nll:.3f} / {pct:.2f} percentile"
|
|
|
|
| 33 |
img = np.array(input_img)
|
| 34 |
img = torch.from_numpy(img).permute(2, 0, 1).unsqueeze(0)
|
| 35 |
img = img.float().to(device)
|
| 36 |
+
model, modeldir = load_model_from_hub(preset=preset, device=device)
|
| 37 |
img_likelihood, score_norms = run_inference(model, img)
|
| 38 |
nll, pct, ref_nll = compute_gmm_likelihood(
|
| 39 |
+
score_norms, model_dir=modeldir
|
| 40 |
)
|
| 41 |
|
| 42 |
outstr = f"Anomaly score: {nll:.3f} / {pct:.2f} percentile"
|