-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] lazy implementation of video predictions (#1621)
* Draft code for replacing list predictions with generator for video, mp4 * Changed types, united save_mp4, rewrote save_gif * Returned correct type inside iterables in Video(Detection)Prediction * Changed types to more correct ones * Provided similar changes to PoseEstimationVideoPrediction * Added tests of save and show for video predictions * Added example script for PE and changed detection example script * Removed test warning filter * Removed unused import * Removed duplicated import * Removed show() from video tests, not available * Fixed pretrained weights flag in test video * Replaced link with an arg for video path * Added a documentation line regarding the video predictions * Changed word in progress bar example --------- Co-authored-by: Eugene Khvedchenya <[email protected]>
- Loading branch information
1 parent
83eded4
commit d925039
Showing
8 changed files
with
172 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/super_gradients/examples/predict/pose_estimation_predict_video.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import torch | ||
from super_gradients.training import models | ||
|
||
import argparse | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("-p", "--path_to_video", type=str) | ||
|
||
if __name__ == "__main__": | ||
args = parser.parse_args() | ||
|
||
# Note that currently only YoloX, PPYoloE and YOLO-NAS are supported. | ||
model = models.get("yolo_nas_pose_l", pretrained_weights="coco_pose") | ||
|
||
# We want to use cuda if available to speed up inference. | ||
model = model.to("cuda" if torch.cuda.is_available() else "cpu") | ||
|
||
predictions = model.predict(args.path_to_video) | ||
predictions.save(f"{args.path_to_video.split('/')[-1]}_prediction.mp4") | ||
|
||
predictions = model.predict(args.path_to_video) | ||
predictions.save(f"{args.path_to_video.split('/')[-1]}_prediction.gif") # Can also be saved as a gif. | ||
|
||
predictions = model.predict(args.path_to_video) | ||
predictions.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.