glenn-jocher commited on
Commit
842d049
1 Parent(s): 77977e0

Suppress `torch.jit.TracerWarning` on export (#6498)

Browse files

* Suppress torch.jit.TracerWarning

TracerWarnings can be safely ignored.

* Cleanup

Files changed (1) hide show
  1. export.py +5 -2
export.py CHANGED
@@ -45,6 +45,7 @@ import platform
45
  import subprocess
46
  import sys
47
  import time
 
48
  from pathlib import Path
49
 
50
  import torch
@@ -508,8 +509,10 @@ def parse_opt():
508
 
509
 
510
  def main(opt):
511
- for opt.weights in (opt.weights if isinstance(opt.weights, list) else [opt.weights]):
512
- run(**vars(opt))
 
 
513
 
514
 
515
  if __name__ == "__main__":
 
45
  import subprocess
46
  import sys
47
  import time
48
+ import warnings
49
  from pathlib import Path
50
 
51
  import torch
 
509
 
510
 
511
  def main(opt):
512
+ with warnings.catch_warnings():
513
+ warnings.filterwarnings(action='ignore', category=torch.jit.TracerWarning) # suppress TracerWarning
514
+ for opt.weights in (opt.weights if isinstance(opt.weights, list) else [opt.weights]):
515
+ run(**vars(opt))
516
 
517
 
518
  if __name__ == "__main__":