Add yolov5/ to sys.path() for *.py subdir exec (#2949)

* Add yolov5/ to sys.path() for *.py subdir exec

* Update export.py
This commit is contained in:
Glenn Jocher 2021-04-27 17:02:07 +02:00 committed by GitHub
parent 4890499344
commit 4200674a13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -7,8 +7,9 @@ Usage:
import argparse import argparse
import sys import sys
import time import time
from pathlib import Path
sys.path.append('./') # to run '$ python *.py' files in subdirectories sys.path.append(Path(__file__).parent.parent.absolute().__str__()) # to run '$ python *.py' files in subdirectories
import torch import torch
import torch.nn as nn import torch.nn as nn

View File

@ -4,8 +4,9 @@ import argparse
import logging import logging
import sys import sys
from copy import deepcopy from copy import deepcopy
from pathlib import Path
sys.path.append('./') # to run '$ python *.py' files in subdirectories sys.path.append(Path(__file__).parent.parent.absolute().__str__()) # to run '$ python *.py' files in subdirectories
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
from models.common import * from models.common import *
@ -267,7 +268,7 @@ if __name__ == '__main__':
# Create model # Create model
model = Model(opt.cfg).to(device) model = Model(opt.cfg).to(device)
model.train() model.train()
# Profile # Profile
# img = torch.rand(8 if torch.cuda.is_available() else 1, 3, 320, 320).to(device) # img = torch.rand(8 if torch.cuda.is_available() else 1, 3, 320, 320).to(device)
# y = model(img, profile=True) # y = model(img, profile=True)