Problems with deep learning training

1. AttributeError: module ‘cv2.cv2’ has no attribute 'saliency

  File "C:\Users\64883\Desktop\contrastive-unpaired-translation-master\models\cut_model.py", line 188, in compute_G_loss
    self.loss_NCE = self.calculate_NCE_loss(self.real_A, self.fake_B)
  File "C:\Users\64883\Desktop\contrastive-unpaired-translation-master\models\cut_model.py", line 209, in calculate_NCE_loss
    feat_k_pool, sample_ids = self.netF(feat_k, self.opt.num_patches, None)
  File "D:\Anaconda3\envs\pytorch_envs\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "C:\Users\64883\Desktop\contrastive-unpaired-translation-master\models\networks.py", line 567, in forward
    detector = cv2.saliency.StaticSaliencyFineGrained_create()  # create a saliency detector
AttributeError: module 'cv2.cv2' has no attribute 'saliency'

Possible solutions
(1) Uninstall opencv and opencv-contrib-python, then reinstall opencv-contrib-python
(2) Make sure your opencv and opencv-contrib-python versions are the same, for example both are 4.5.3
(3) Use cv2 instead of cv2.cv2 to import modules, for example import cv2 as cv2
uses the first method

(pytorch_envs) C:\Users\64883\Desktop\contrastive-unpaired-translation-master>pip uninstall opencv-python
Found existing installation: opencv-python 4.5.2.52
Uninstalling opencv-python-4.5.2.52:
  Would remove:
    d:\anaconda3\envs\pytorch_envs\lib\site-packages\cv2\*
    d:\anaconda3\envs\pytorch_envs\lib\site-packages\opencv_python-4.5.2.52.dist-info\*
Proceed (y/n)? y
  Successfully uninstalled opencv-python-4.5.2.52

2. ValueError: check_hostname requires server_hostname

  File "D:\Anaconda3\envs\pytorch_envs\lib\site-packages\pip\_vendor\urllib3\util\ssl_.py", line 432, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
  File "D:\Anaconda3\envs\pytorch_envs\lib\site-packages\pip\_vendor\urllib3\util\ssl_.py", line 474, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock)
  File "D:\Anaconda3\envs\pytorch_envs\lib\ssl.py", line 423, in wrap_socket
    session=session
  File "D:\Anaconda3\envs\pytorch_envs\lib\ssl.py", line 827, in _create
    raise ValueError("check_hostname requires server_hostname")
ValueError: check_hostname requires server_hostname

Possible solutions
(1) upgrade or downgrade your urllib3 or requests library to make their versions match
(2) turn off your network proxy (VPN), or add the port number of the network proxy in the .condarc file
(3) check Does your requests request have the correct server_hostname parameter?
The second method is used

(pytorch_envs) C:\Users\64883\Desktop\contrastive-unpaired-translation-master>pip install opencv-contrib-python
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting opencv-contrib-python
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f3/8b/9d010c60a2254e810ea2bd4a8645f9e12dff3ee8f2de12e7b8b38cdec561/opencv_contrib_python-4.7.0.72-cp37-abi3-win_amd64.whl (44.9 MB)
     |████████████████████████████████| 44.9 MB 328 kB/s
Requirement already satisfied: numpy>=1.17.0 in d:\anaconda3\envs\pytorch_envs\lib\site-packages (from opencv-contrib-python) (1.21.5)
Installing collected packages: opencv-contrib-python
Successfully installed opencv-contrib-python-4.7.0.72

All solved!

Guess you like

Origin blog.csdn.net/qq_40721108/article/details/129410224