Skip to content
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

Add condlane #20

Merged
merged 15 commits into from
Sep 11, 2021
Prev Previous commit
Next Next commit
minor fix
  • Loading branch information
Turoad committed Jul 8, 2021
commit 5891920af9a96784428a7d9f06c68f5b7a66474d
1 change: 0 additions & 1 deletion lanedet/models/backbones/resnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ def forward(self, x):
def _resnet(arch, block, layers, pretrained, progress, **kwargs):
model = ResNet(block, layers, **kwargs)
if pretrained:
print('pretrained model: ', model_urls[arch])
# state_dict = torch.load(model_urls[arch])['net']
state_dict = load_state_dict_from_url(model_urls[arch])
model.load_state_dict(state_dict, strict=False)
Expand Down
4 changes: 2 additions & 2 deletions lanedet/models/heads/condlane.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,8 +1019,8 @@ def get_lanes(self, output):
result = adjust_result(
lanes=lanes,
crop_bbox=self.cfg.crop_bbox,
img_shape=self.cfg.img_scale,
tgt_shape=(590, 1640),
img_shape=(self.cfg.img_height, self.cfg.img_width),
tgt_shape=(self.cfg.ori_img_h, self.cfg.ori_img_w),
)
lanes = []
for lane in result:
Expand Down
2 changes: 1 addition & 1 deletion lanedet/models/nets/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, cfg):
self.neck = build_necks(cfg) if cfg.haskey('neck') else None
self.heads = build_heads(cfg)

def get_lanes(self):
def get_lanes(self, output):
return self.heads.get_lanes(output)

def forward(self, batch):
Expand Down
2 changes: 1 addition & 1 deletion lanedet/utils/net_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ def load_network(net, model_dir, finetune_from=None, logger=None):
load_network_specified(net, finetune_from, logger)
return
pretrained_model = torch.load(model_dir)
print(net.load_state_dict(pretrained_model['net'], strict=False))
net.load_state_dict(pretrained_model['net'], strict=False)
6 changes: 6 additions & 0 deletions tools/.ipynb_checkpoints/detect-checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 5
}
4 changes: 3 additions & 1 deletion tools/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from lanedet.utils.visualization import imshow_lanes
from lanedet.utils.net_utils import load_network
from pathlib import Path
from tqdm import tqdm

class Detect(object):
def __init__(self, cfg):
Expand All @@ -34,6 +35,7 @@ def preprocess(self, img_path):
def inference(self, data):
with torch.no_grad():
data = self.net(data)
data = self.net.module.get_lanes(data)
return data

def show(self, data):
Expand Down Expand Up @@ -69,7 +71,7 @@ def process(args):
cfg.load_from = args.load_from
detect = Detect(cfg)
paths = get_img_paths(args.img)
for p in paths:
for p in tqdm(paths):
detect.run(p)

if __name__ == '__main__':
Expand Down
26 changes: 26 additions & 0 deletions tools/update_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os
from sys import argv

def update_config(path):
with open(path) as f:
has_config=False
for line in f:
has_config = has_config | ('lr_update_by_epoch' in line)
if has_config:
return

# with open(path, 'a') as f:
# f.write('lr_update_by_epoch = False')


def main(file_path):
for root, dirs, files in os.walk(file_path):
for f in files:
path = os.path.join(root, f)
if not path.endswith('.py'):
continue
update_config(path)


if __name__ == '__main__':
main(argv[1])