MCPcopy Create free account
hub / github.com/ChristianInterno/ReStraV / classify

Function classify

demo.py:58–76  ·  view source on GitHub ↗
(video_file)

Source from the content-addressed store, hash-verified

56
57#Perform classification
58def classify(video_file):
59 if video_file is None:
60 return {"No video": 1.0}
61
62 Z = d2.extract_dinov2_embeddings([video_file], device=device)
63 features = d2.features_from_Z(Z)
64
65 if isinstance(features, torch.Tensor):
66 features = features.cpu().numpy()
67
68 x = (features - mean.squeeze()) / std.squeeze()
69 x = x.astype(np.float32)
70 x_tensor = torch.from_numpy(x).unsqueeze(0).to(device)
71
72 with torch.no_grad():
73 logits = model(x_tensor)
74 prob = torch.sigmoid(logits).cpu().numpy().item()
75
76 return {"REAL": prob, "FAKE": 1 - prob}
77
78with gr.Blocks(title="ReStrav Classifier") as demo:
79

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected