设计的系统,里面包含yolov5模块,其中args.parser,parse_args()负责解析终端里面输入的参数。后端主函数能完美运行的程序,放到django前端就不能执行。
Traceback (most recent call last):
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/site-packages/django/contrib/staticfiles/handlers.py", line 80, in __call__
return self.application(environ, start_response)
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/site-packages/django/core/handlers/wsgi.py", line 132, in __call__
response = self.get_response(request)
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/site-packages/django/core/handlers/base.py", line 140, in get_response
response = self._middleware_chain(request)
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/site-packages/django/utils/deprecation.py", line 134, in __call__
response = response or self.get_response(request)
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/site-packages/django/utils/deprecation.py", line 134, in __call__
response = response or self.get_response(request)
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/site-packages/django/utils/deprecation.py", line 134, in __call__
response = response or self.get_response(request)
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/site-packages/django/utils/deprecation.py", line 134, in __call__
response = response or self.get_response(request)
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/site-packages/django/utils/deprecation.py", line 134, in __call__
response = response or self.get_response(request)
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/site-packages/django/utils/deprecation.py", line 134, in __call__
response = response or self.get_response(request)
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/site-packages/django/utils/deprecation.py", line 134, in __call__
response = response or self.get_response(request)
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/barry/PycharmProjects/EEPC/login/views.py", line 148, in result
s = Deal_Score(file_list,ma,mi)
File "/home/barry/PycharmProjects/EEPC/main.py", line 229, in Deal_Score
deal(image_one)
File "/home/barry/PycharmProjects/EEPC/main.py", line 143, in deal
choice_score = choice_question(choice_src)
File "/home/barry/PycharmProjects/EEPC/detect.py", line 315, in choice_question
result = Detect(p)
File "/home/barry/PycharmProjects/EEPC/detect.py", line 297, in Detect
opt = parse_opt()
File "/home/barry/PycharmProjects/EEPC/detect.py", line 283, in parse_opt
opt = parser.parse_args()
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/argparse.py", line 1823, in parse_args
self.error(msg % ' '.join(argv))
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/argparse.py", line 2577, in error
self.exit(2, _('%(prog)s: error: %(message)s\n') % args)
File "/home/barry/anaconda3/envs/EEPC/lib/python3.9/argparse.py", line 2564, in exit
_sys.exit(status)
SystemExit: 2
核心就是最后一行SystemExit: 2
解决方案:
args = parser.parse_args()
改成
args = parser.parse_args(args=[])
|