update-to-match-accuracy
#2
by
gmancino-ball
- opened
script.py
CHANGED
|
@@ -34,7 +34,7 @@ def preprocess(file_like):
|
|
| 34 |
container = av.open(file_like)
|
| 35 |
frames = []
|
| 36 |
every = 10
|
| 37 |
-
for i,frame in enumerate(container.decode(video=0)):
|
| 38 |
if i % every == 0:
|
| 39 |
frame_array = frame.to_ndarray(format="rgb24")
|
| 40 |
frame_tensor = torch.from_numpy(frame_array).permute(2, 0, 1).float()
|
|
@@ -83,11 +83,11 @@ for el in tqdm.tqdm(dataset_remote):
|
|
| 83 |
with torch.no_grad():
|
| 84 |
# soft decision (such as log likelihood score)
|
| 85 |
# positive score correspond to synthetic prediction
|
| 86 |
-
# negative score correspond to
|
| 87 |
score = model(tensor[None].to(device)).cpu().item()
|
| 88 |
|
| 89 |
# we require a hard decision to be submited. so you need to pick a threshold
|
| 90 |
-
pred = "generated" if score > model.threshold else "
|
| 91 |
|
| 92 |
# append your prediction
|
| 93 |
# "id" and "pred" are required. "score" will not be used in scoring but we encourage you to include it. We'll use it for analysis of the results
|
|
|
|
| 34 |
container = av.open(file_like)
|
| 35 |
frames = []
|
| 36 |
every = 10
|
| 37 |
+
for i, frame in enumerate(container.decode(video=0)):
|
| 38 |
if i % every == 0:
|
| 39 |
frame_array = frame.to_ndarray(format="rgb24")
|
| 40 |
frame_tensor = torch.from_numpy(frame_array).permute(2, 0, 1).float()
|
|
|
|
| 83 |
with torch.no_grad():
|
| 84 |
# soft decision (such as log likelihood score)
|
| 85 |
# positive score correspond to synthetic prediction
|
| 86 |
+
# negative score correspond to real prediction
|
| 87 |
score = model(tensor[None].to(device)).cpu().item()
|
| 88 |
|
| 89 |
# we require a hard decision to be submited. so you need to pick a threshold
|
| 90 |
+
pred = "generated" if score > model.threshold else "real"
|
| 91 |
|
| 92 |
# append your prediction
|
| 93 |
# "id" and "pred" are required. "score" will not be used in scoring but we encourage you to include it. We'll use it for analysis of the results
|