update detect.py
in order to support torch script
#5109
Merged
detect.py
in order to support torch script
#5109