License-Plate-Detector icon indicating copy to clipboard operation
License-Plate-Detector copied to clipboard

根据`Pytorch模型测试`配置流程,运行`python detect_plate.py`报错

Open lex7061 opened this issue 2 years ago • 4 comments

1、源程序build完直接运行报错如下:

image

2、修改了文件路径后运行报错如下:

D:\InstallationDir\anaconda\python.exe E:/lxx/workProjects/uniappHyperLPR/License-Plate-Detector/detect_plate.py
Namespace(weights='runs/train/exp/weights/last.pt', image='data/images/test.jpg', img_size=640)
Traceback (most recent call last):
  File "D:\InstallationDir\anaconda\lib\site-packages\urllib3\connectionpool.py", line 700, in urlopen
    self._prepare_proxy(conn)
  File "D:\InstallationDir\anaconda\lib\site-packages\urllib3\connectionpool.py", line 994, in _prepare_proxy
    conn.connect()
  File "D:\InstallationDir\anaconda\lib\site-packages\urllib3\connection.py", line 364, in connect
    conn = self._connect_tls_proxy(hostname, conn)
  File "D:\InstallationDir\anaconda\lib\site-packages\urllib3\connection.py", line 501, in _connect_tls_proxy
    socket = ssl_wrap_socket(
  File "D:\InstallationDir\anaconda\lib\site-packages\urllib3\util\ssl_.py", line 453, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
  File "D:\InstallationDir\anaconda\lib\site-packages\urllib3\util\ssl_.py", line 495, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock)
  File "D:\InstallationDir\anaconda\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "D:\InstallationDir\anaconda\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "D:\InstallationDir\anaconda\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1129)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\InstallationDir\anaconda\lib\site-packages\requests\adapters.py", line 440, in send
    resp = conn.urlopen(
  File "D:\InstallationDir\anaconda\lib\site-packages\urllib3\connectionpool.py", line 785, in urlopen
    retries = retries.increment(
  File "D:\InstallationDir\anaconda\lib\site-packages\urllib3\util\retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.github.com', port=443): Max retries exceeded with url: /repos/ultralytics/yolov5/releases/latest (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\lxx\workProjects\uniappHyperLPR\License-Plate-Detector\utils\google_utils.py", line 25, in attempt_download
    response = requests.get(f'https://api.github.com/repos/{repo}/releases/latest').json()  # github api
  File "D:\InstallationDir\anaconda\lib\site-packages\requests\api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "D:\InstallationDir\anaconda\lib\site-packages\requests\api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "D:\InstallationDir\anaconda\lib\site-packages\requests\sessions.py", line 529, in request
    resp = self.send(prep, **send_kwargs)
  File "D:\InstallationDir\anaconda\lib\site-packages\requests\sessions.py", line 645, in send
    r = adapter.send(request, **kwargs)
  File "D:\InstallationDir\anaconda\lib\site-packages\requests\adapters.py", line 517, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='api.github.com', port=443): Max retries exceeded with url: /repos/ultralytics/yolov5/releases/latest (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\lxx\workProjects\uniappHyperLPR\License-Plate-Detector\detect_plate.py", line 172, in <module>
    model = load_model(opt.weights, device)
  File "E:\lxx\workProjects\uniappHyperLPR\License-Plate-Detector\detect_plate.py", line 25, in load_model
    model = attempt_load(weights, map_location=device)  # load FP32 model
  File "E:\lxx\workProjects\uniappHyperLPR\License-Plate-Detector\models\experimental.py", line 117, in attempt_load
    attempt_download(w)
  File "E:\lxx\workProjects\uniappHyperLPR\License-Plate-Detector\utils\google_utils.py", line 30, in attempt_download
    tag = subprocess.check_output('git tag', shell=True).decode('utf-8').split('\n')[-2]
IndexError: list index out of range

进程已结束,退出代码1

lex7061 avatar Feb 16 '22 06:02 lex7061

1.文件路径不对,上面的路径改成自己图片的路径。2.你的Python版本是什么,感觉还是路径或者文件编码格式的问题,windows下路径用“\”或者"/"。

Jinkham avatar Feb 16 '22 11:02 Jinkham

1、文件路径采用的绝对路径,图片是CCPD的 image 2、python版本3.9.10,是通过anaconda配置的环境【windows11】 image 3、当前配置下运行报错信息如下:

D:\InstallationDir\anaconda\python.exe E:/lxx/workProjects/uniappHyperLPR/License-Plate-Detector/detect_plate.py
Namespace(weights='runs/train/exp/weights/last.pt', image='data/images/test.jpg', img_size=640)
Traceback (most recent call last):
  File "D:\InstallationDir\anaconda\lib\site-packages\urllib3\connectionpool.py", line 700, in urlopen
    self._prepare_proxy(conn)
  File "D:\InstallationDir\anaconda\lib\site-packages\urllib3\connectionpool.py", line 994, in _prepare_proxy
    conn.connect()
  File "D:\InstallationDir\anaconda\lib\site-packages\urllib3\connection.py", line 364, in connect
    conn = self._connect_tls_proxy(hostname, conn)
  File "D:\InstallationDir\anaconda\lib\site-packages\urllib3\connection.py", line 501, in _connect_tls_proxy
    socket = ssl_wrap_socket(
  File "D:\InstallationDir\anaconda\lib\site-packages\urllib3\util\ssl_.py", line 453, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
  File "D:\InstallationDir\anaconda\lib\site-packages\urllib3\util\ssl_.py", line 495, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock)
  File "D:\InstallationDir\anaconda\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "D:\InstallationDir\anaconda\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "D:\InstallationDir\anaconda\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1129)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\InstallationDir\anaconda\lib\site-packages\requests\adapters.py", line 440, in send
    resp = conn.urlopen(
  File "D:\InstallationDir\anaconda\lib\site-packages\urllib3\connectionpool.py", line 785, in urlopen
    retries = retries.increment(
  File "D:\InstallationDir\anaconda\lib\site-packages\urllib3\util\retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.github.com', port=443): Max retries exceeded with url: /repos/ultralytics/yolov5/releases/latest (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\lxx\workProjects\uniappHyperLPR\License-Plate-Detector\utils\google_utils.py", line 25, in attempt_download
    response = requests.get(f'https://api.github.com/repos/{repo}/releases/latest').json()  # github api
  File "D:\InstallationDir\anaconda\lib\site-packages\requests\api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "D:\InstallationDir\anaconda\lib\site-packages\requests\api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "D:\InstallationDir\anaconda\lib\site-packages\requests\sessions.py", line 529, in request
    resp = self.send(prep, **send_kwargs)
  File "D:\InstallationDir\anaconda\lib\site-packages\requests\sessions.py", line 645, in send
    r = adapter.send(request, **kwargs)
  File "D:\InstallationDir\anaconda\lib\site-packages\requests\adapters.py", line 517, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='api.github.com', port=443): Max retries exceeded with url: /repos/ultralytics/yolov5/releases/latest (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\lxx\workProjects\uniappHyperLPR\License-Plate-Detector\detect_plate.py", line 176, in <module>
    model = load_model(opt.weights, device)
  File "E:\lxx\workProjects\uniappHyperLPR\License-Plate-Detector\detect_plate.py", line 25, in load_model
    model = attempt_load(weights, map_location=device)  # load FP32 model
  File "E:\lxx\workProjects\uniappHyperLPR\License-Plate-Detector\models\experimental.py", line 117, in attempt_load
    attempt_download(w)
  File "E:\lxx\workProjects\uniappHyperLPR\License-Plate-Detector\utils\google_utils.py", line 30, in attempt_download
    tag = subprocess.check_output('git tag', shell=True).decode('utf-8').split('\n')[-2]
IndexError: list index out of range

进程已结束,退出代码1

lex7061 avatar Feb 17 '22 01:02 lex7061

你好,请问预测的时候应该修改哪些呢?

Mr-ind1fferent avatar Feb 28 '22 12:02 Mr-ind1fferent

你好,请问预测的时候应该修改哪些呢?

image 这是我的报错

Mr-ind1fferent avatar Feb 28 '22 12:02 Mr-ind1fferent