Skip to content

remove ultralytics dependency #262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ PyYAML>=5.3.1
requests>=2.23.0
scipy>=1.4.1
thop>=0.1.1 # FLOPs computation
torch>=1.7.0 # see https://pytorch.org/get-started/locally (recommended)
torchvision>=0.8.1
torch>=2.0.0 # see https://pytorch.org/get-started/locally (recommended)
torchvision>=0.15.0
tqdm>=4.64.0
ultralytics>=8.0.100
# protobuf<=3.20.1 # https://github.com/ultralytics/yolov5/issues/8012

# Logging ---------------------------------------------------------------------
Expand Down Expand Up @@ -50,7 +49,7 @@ setuptools>=65.5.1 # Snyk vulnerability fix


# CLI
fire
fire==0.6.0
# AWS
boto3>=1.19.1
# coco to yolov5 conversion
Expand Down
2 changes: 1 addition & 1 deletion yolov5/hubconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _create(name, pretrained=True, channels=3, classes=80, autoshape=True, verbo
cfg = list((Path(__file__).parent / 'models').rglob(f'{path.stem}.yaml'))[0] # model.yaml path
model = DetectionModel(cfg, channels, classes) # create model
if pretrained:
ckpt = torch.load(attempt_download(path), map_location=device) # load
ckpt = torch.load(attempt_download(path), weights_only=False, map_location=device) # load
csd = ckpt['model'].float().state_dict() # checkpoint state_dict as FP32
csd = intersect_dicts(csd, model.state_dict(), exclude=['anchors']) # intersect
model.load_state_dict(csd, strict=False) # load
Expand Down
2 changes: 1 addition & 1 deletion yolov5/models/experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def attempt_load(weights, device=None, inplace=True, fuse=True):

model = Ensemble()
for w in weights if isinstance(weights, list) else [weights]:
ckpt = torch.load(attempt_download(w), map_location='cpu') # load
ckpt = torch.load(attempt_download(w), weights_only=False, map_location='cpu') # load
ckpt = (ckpt.get('ema') or ckpt['model']).to(device).float() # FP32 model

# Model compatibility updates
Expand Down
4 changes: 2 additions & 2 deletions yolov5/segment/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def train(hyp, opt, device, callbacks): # hyp is path/to/hyp.yaml or hyp dictio
if pretrained:
with torch_distributed_zero_first(LOCAL_RANK):
weights = attempt_download(weights) # download if not found locally
ckpt = torch.load(weights, map_location='cpu') # load checkpoint to CPU to avoid CUDA memory leak
ckpt = torch.load(weights, weights_only=False, map_location='cpu') # load checkpoint to CPU to avoid CUDA memory leak
model = SegmentationModel(cfg or ckpt['model'].yaml, ch=3, nc=nc, anchors=hyp.get('anchors')).to(device)
exclude = ['anchor'] if (cfg or hyp.get('anchors')) and not resume else [] # exclude keys
csd = ckpt['model'].float().state_dict() # checkpoint state_dict as FP32
Expand Down Expand Up @@ -544,7 +544,7 @@ def main(opt, callbacks=Callbacks()):
with open(opt_yaml, errors='ignore') as f:
d = yaml.safe_load(f)
else:
d = torch.load(last, map_location='cpu')['opt']
d = torch.load(last, weights_only=False, map_location='cpu')['opt']
opt = argparse.Namespace(**d) # replace
opt.cfg, opt.weights, opt.resume = '', str(last), True # reinstate
if is_url(opt_data):
Expand Down
4 changes: 2 additions & 2 deletions yolov5/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def train(hyp, opt, device, callbacks): # hyp is path/to/hyp.yaml or hyp dictio
if pretrained:
with torch_distributed_zero_first(LOCAL_RANK):
weights = attempt_download(weights) # download if not found locally
ckpt = torch.load(weights, map_location='cpu') # load checkpoint to CPU to avoid CUDA memory leak
ckpt = torch.load(weights, weights_only=False, map_location='cpu') # load checkpoint to CPU to avoid CUDA memory leak
model = Model(cfg or ckpt['model'].yaml, ch=3, nc=nc, anchors=hyp.get('anchors')).to(device) # create
exclude = ['anchor'] if (cfg or hyp.get('anchors')) and not resume else [] # exclude keys
csd = ckpt['model'].float().state_dict() # checkpoint state_dict as FP32
Expand Down Expand Up @@ -578,7 +578,7 @@ def main(opt, callbacks=Callbacks()):
with open(opt_yaml, errors='ignore') as f:
d = yaml.safe_load(f)
else:
d = torch.load(last, map_location='cpu')['opt']
d = torch.load(last, weights_only=False, map_location='cpu')['opt']
if opt.neptune_resume_id is not None:
d["neptune_resume_id"] = opt.neptune_resume_id
opt = argparse.Namespace(**d) # replace
Expand Down
Loading
Loading