1 Star 0 Fork 0

vincentxxxx/orientation_easimation

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
predict.py 1.40 KB
一键复制 编辑 原始数据 按行查看 历史
vincent.xu 提交于 2020-05-14 13:36 . Initial commit
import torch
import os
from utils import dataset
from torch.utils.data import DataLoader
from config import _C as cfg
from utils.model import MobileNetV2,Model
from utils import angle_utils
PI = 3.14159
P2 = [[712., 0, 640.], [0, 712., 360.], [0., 0., 1.]]
def main():
device=cfg.DEVICE
data = dataset.KITTIDataset(cfg.PATH,cfg,mode='predict')
val_dataloader = DataLoader(data, cfg.VAL_BATCH , shuffle=False)
# Initialize the model
mobilenetv2 = MobileNetV2()
model = Model(features=mobilenetv2.features, bins=cfg.BIN).to(device)
model_list = os.listdir(cfg.MODEL_DIR)
# model.load_state_dict(torch.load(cfg.MODEL_DIR + "/%s" % sorted(model_list)[-1]))
model.load_state_dict(torch.load(cfg.MODEL_DIR + '/model_2020-05-13-10-06-12.pth'))
print(sorted(model_list)[-1])
model.eval()
for i, (batch,info) in enumerate(val_dataloader):
# batch, centerAngle, info = data.EvalBatch()
batch = torch.FloatTensor(batch).to(device)
[orient, conf] = model(batch)
orient = orient.cpu().data.numpy()
conf = conf.cpu().data.numpy()
print(orient)
print(conf)
alpha = angle_utils.recover_angle(conf.squeeze(0), orient.squeeze(0), cfg.BIN)
rot_y = angle_utils.compute_orientaion(P2, info['bbox2d'], alpha)
angle_utils.save_result(info, alpha, rot_y, i,mode='predict')
if __name__ == '__main__':
main()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/vincentxxxx/orientation_easimation.git
git@gitee.com:vincentxxxx/orientation_easimation.git
vincentxxxx
orientation_easimation
orientation_easimation
master

搜索帮助