question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Video inference sample code

See original GitHub issue

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

from classy_vision.generic.util import load_checkpoint
from classy_vision.models import ClassyModel

# This is important: importing models here will register your custom models with Classy Vision
# so that it can instantiate them appropriately from the checkpoint file
# See more information at https://classyvision.ai/api/models.html#classy_vision.models.register_model
from classy_vision import models


# Update this with your actual directory:
checkpoint_dir = '/home/sucom/hdd_1T/project/video_rec_0831/ClassyVision/checkpoint_hand/model_phase-2198_end.torch'
checkpoint_data = load_checkpoint(checkpoint_dir)
model = ClassyModel.from_checkpoint(checkpoint_data)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mannatsinghcommented, Jan 25, 2021

Thanks for the code sample, @shinianzhihou !

1reaction
shinianzhihoucommented, Jan 24, 2021
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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Roboflow Video Inference - GitHub
Example showing how to do inference on a video file with Roboflow Infer ... The infer script is built with argbash (a code...
Read more >
Video Inference with Roboflow
The process is simple: 1) split your video into frames, 2) get a prediction from your model from each frame, and 3) reconstruct...
Read more >
9. Inference on your own videos using pre-trained models
In this tutorial, we provide a script for you to make human activity predictions on your own videos. The only thing you need...
Read more >
Image and Video Inference using MMDetection - DebuggerCafe
Image and Video Inference using MMDetection ... In this tutorial, we will use pretrained object detection and instance segmentation models for ...
Read more >
OpenVINO Samples
Hello Classification Sample – Inference of image classification networks, ... To run the sample applications, use images and videos available online in the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found