From 842d049e1bbe5db87ad36f4ba86e1a9c2b6e413a Mon Sep 17 00:00:00 2001 From: Glenn Jocher <glenn.jocher@ultralytics.com> Date: Tue, 1 Feb 2022 22:59:26 +0100 Subject: [PATCH] Suppress `torch.jit.TracerWarning` on export (#6498) * Suppress torch.jit.TracerWarning TracerWarnings can be safely ignored. * Cleanup --- export.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/export.py b/export.py index bb1770382..8666f3de6 100644 --- a/export.py +++ b/export.py @@ -45,6 +45,7 @@ import platform import subprocess import sys import time +import warnings from pathlib import Path import torch @@ -508,8 +509,10 @@ def parse_opt(): def main(opt): - for opt.weights in (opt.weights if isinstance(opt.weights, list) else [opt.weights]): - run(**vars(opt)) + with warnings.catch_warnings(): + warnings.filterwarnings(action='ignore', category=torch.jit.TracerWarning) # suppress TracerWarning + for opt.weights in (opt.weights if isinstance(opt.weights, list) else [opt.weights]): + run(**vars(opt)) if __name__ == "__main__":