Simplified inference (#1153)

This commit is contained in:
Glenn Jocher authored and GitHub committed 2020-10-15 20:10:08 +02:00
1 parent c67e72200e
commit 3b57cb5641
7 files changed
+87 -30

No files matched your search

+1 -4
View File
@@ -10,7 +10,6 @@ import os
import torch
from models.common import NMS
from models.yolo import Model
from utils.google_utils import attempt_download
@@ -36,9 +35,7 @@ def create(name, pretrained, channels, classes):
state_dict = torch.load(ckpt, map_location=torch.device('cpu'))['model'].float().state_dict() # to FP32
state_dict = {k: v for k, v in state_dict.items() if model.state_dict()[k].shape == v.shape} # filter
model.load_state_dict(state_dict, strict=False) # load
model.add_nms() # add NMS module
model.eval()
# model = model.autoshape() # cv2/PIL/np/torch inference: predictions = model(Image.open('image.jpg'))
return model
except Exception as e: