-
Notifications
You must be signed in to change notification settings - Fork 277
Video inference sample code #613
Comments
please help me , @mannatsingh |
@siyangbing you're right, we don't have a tutorial for inference at the moment since the API isn't finalized. If you want to evaluate a trained checkpoint on a test dataset, you can create a new task similar to the one you created for training, with the following differences - task.set_test_only(True)
task.set_num_epochs(1)
task.set_dataset(test_dataset, "test")
task.set_checkpoint("path/to/checkpoint") Note that this API is liable to change in the future. Let me know if this works for you! |
Thank you very much for your reply, but for me, the task is too complicated for me to understand. I recently have a project that needs to identify a single video. Is it possible to infer a single video directly by loading a checkpoint instead of registering a data set and using tasks. What do I need to do with a single video before I can input the model for inference, please help me! |
please help me , the project is perfect if I can infer one video with my own model! |
@stephenyan1231 do you have any suggestions for the best way to do this? |
it will get support in future relase? |
@siyangbing we have good support for this for images, but that's missing a tutorial. For videos, we need to add better support! |
If there is support for video inference in the future, please let me know @mannatsingh |
state_path = "YOUR/PATH/TO/checkpoints/checkpoint.torch"
state = torch.load(state_path)
model = ClassyModel.from_checkpoint(state)
dataset = build_dataset(state["input_args"]["config"]["dataset"]["test"])
dataset.batchsize_per_replica = 10 # to test in the single GPU with small memory
targets,outputs = [],[]
model = model.cuda().eval()
for idx,data in enumerate(dataset.iterator()):
output = model(data['input'].cuda()).argmax(dim=1)
outputs += list(output.detach().cpu().numpy())
targets += list(data["target"].numpy())
from sklearn.metrics import classification_report
print(classification_report(targets, outputs, target_names=CLASSES)) This is how I make my inference. May be useful |
Thanks for the code sample, @shinianzhihou ! |
I used my own video classification trained with the configuration of ucf101. It seems that there is a little overfitting. I want to use my code for inference, but I can't find a related tutorial. I can only find it, and I don't know what to do next. plaese help me @mannatsingh
The text was updated successfully, but these errors were encountered: