Ubuntu16.04 conda环境运行FaiMOT及相关配置

前几天下载FairMOT项目 也配置好相关环境 今天想准备跑一下代码 看看效果如何
结果运行代码发现 一下问题
再跑kitti数据前,准备先测试一下项目提供的demo视频
按照项目给的demo要求走

(FairMOT) ckq@ckq:~/git/FairMOT/src$ python demo.py mot --load_model ../models/all_dla34.pth --conf_thres 0.4
Traceback (most recent call last):
  File "demo.py", line 11, in <module>
    from tracking_utils.utils import mkdir_if_missing
  File "/home/ckq/git/FairMOT/src/lib/tracking_utils/utils.py", line 6, in <module>
    import cv2
ImportError: /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so: undefined symbol: PyCObject_Type

然后在conda 环境下

(FairMOT) ckq@ckq:~/git/FairMOT/src$ python
Python 3.7.6 | packaged by conda-forge | (default, Jun  1 2020, 18:57:50) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "", line 1, in <module>
ImportError: /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so: undefined symbol: PyCObject_Type
>>> 
 发现 conda 环境没有 cv2模块

但在原本系统下我已经装了 opencv

  ckq@ckq:~$ python
Python 2.7.12 (default, Apr 15 2020, 17:07:12) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2

发现没问题
看来是conda环境下的opencv2有问题

开始网上查找相关解决问题
打开bashrc文件

 sudo gedit ~/.bashrc

在文末加入:

 #运行ROS时需要注释掉这行代码,运行非ROS时需要加上这行代码
export PYTHONPATH="/home/ckq/anaconda3/lib/python3.7/site-packages:$PYTHONPATH"

保存

source ~/.bashrc

但是 保存之后再在conda 环境下:

(FairMOT) ckq@ckq:~$ python
Python 3.7.6 | packaged by conda-forge | (default, Jun  1 2020, 18:57:50) 
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
  File "", line 1, in <module>
ImportError: /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so: undefined symbol: PyCObject_Type

发现这并没有 解决根本问题
只是 在项目代码中 换了另一个报错问题

查看了这里的第一种办法 ,但是有个问题需要注意一下 就是运行ros的需要注释掉改行代码,运行非ros是需要加上这行代码
第二种方法没尝试过 不知道这样子是否会把系统的ros搞崩掉 所以没有尝试 so还是用蠢办法吧

https://blog.csdn.net/qq_34544129/article/details/81946494

下面这个链接也是同样解决方法 他也在conda环境下:
https://www.cnblogs.com/gdut-gordon/p/9480652.html

最后 我还是选择了第二个方法

进入conda的环境:
输入python

 >>> import cv2
Traceback (most recent call last):
  File "", line 1, in <module>
ImportError: /opt/ros/kinetic/lib/python2.7/dist-packages/cv2.so: undefined symbol: PyCObject_Type
 >>> import sys
>>> sys.path.remove('/opt/ros/kinetic/lib/python2.7/dist-packages')
>>> import cv2
 Traceback (most recent call last):
  File "", line 1, in <module>
ModuleNotFoundError: No module named 'cv2'
输入:
 pip install opencv-python
 
 下载超时!!!!
 ERROR: Exception:
 pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.

换用国内原

 pip install https://pypi.tuna.tsinghua.edu.cn/simple

继续报错

 pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn opencv-python

 Successfully installed opencv-python-4.2.0.34
 
 (FairMOT) ckq@ckq:~$ pip install https://pypi.tuna.tsinghua.edu.cn/simple
 
Collecting https://pypi.tuna.tsinghua.edu.cn/simple
  Downloading https://pypi.tuna.tsinghua.edu.cn/simple (12.9 MB)
     |████████████████████████████████| 12.9 MB 75 kB/s 
  ERROR: Cannot unpack file /tmp/pip-unpack-hq3edg_y/simple (downloaded from /tmp/pip-req-build-q3xennvm, content-type: text/html; charset=utf-8); cannot detect archive format
ERROR: Cannot determine archive format of /tmp/pip-req-build-q3xennvm
(FairMOT) ckq@ckq:~$ 
(FairMOT) ckq@ckq:~$ 
(FairMOT) ckq@ckq:~$ pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn opencv-python

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting opencv-python
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d0/f0/cfe88d262c67825b20d396c778beca21829da061717c7aaa8b421ae5132e/opencv_python-4.2.0.34-cp37-cp37m-manylinux1_x86_64.whl (28.2 MB)
     |████████████████████████████████| 28.2 MB 92 kB/s 
Requirement already satisfied: numpy>=1.14.5 in ./anaconda3/envs/FairMOT/lib/python3.7/site-packages (from opencv-python) (1.18.5)
Installing collected packages: opencv-python
Successfully installed opencv-python-4.2.0.34

之前方法 我是把remove运行在conda python 环境下,每次运行完,进入项目,还是报同样的错位,有问题!!!
后来得知 要把这话放在报错文件夹下面

import sys
sys.path.remove('/opt/ros/kinetic/lib/python2.7/dist-packages')

添加在报错的文件夹下面!!!!

OK!!!
解决这个问题 成功了一半 下面报的错都是我没有下载一下库而已!!!

之后这个问题解决

出现新的报错:

(FairMOT) ckq@ckq:~/git/FairMOT/src$ python3 demo.py mot --load_model ../models/all_dla34.pth --conf_thres 0.4
Traceback (most recent call last):
  File "demo.py", line 12, in <module>
    from tracking_utils.utils import mkdir_if_missing
  File "/home/ckq/git/FairMOT/src/lib/tracking_utils/utils.py", line 11, in <module>
    from torchvision.ops import nms
  File "/home/ckq/anaconda3/envs/FairMOT/lib/python3.7/site-packages/torchvision/__init__.py", line 2, in <module>
    from torchvision import datasets
  File "/home/ckq/anaconda3/envs/FairMOT/lib/python3.7/site-packages/torchvision/datasets/__init__.py", line 9, in <module>
    from .fakedata import FakeData
  File "/home/ckq/anaconda3/envs/FairMOT/lib/python3.7/site-packages/torchvision/datasets/fakedata.py", line 3, in <module>
    from .. import transforms
  File "/home/ckq/anaconda3/envs/FairMOT/lib/python3.7/site-packages/torchvision/transforms/__init__.py", line 1, in <module>
    from .transforms import *
  File "/home/ckq/anaconda3/envs/FairMOT/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 17, in <module>
    from . import functional as F
  File "/home/ckq/anaconda3/envs/FairMOT/lib/python3.7/site-packages/torchvision/transforms/functional.py", line 5, in <module>
    from PIL import Image, ImageOps, ImageEnhance, PILLOW_VERSION
ImportError: cannot import name 'PILLOW_VERSION' from 'PIL' (/home/ckq/anaconda3/lib/python3.7/site-packages/PIL/__init__.py)

找的链接

https://www.jianshu.com/p/36c35666f077
https://blog.csdn.net/Lee_lg/article/details/103901632

解决:

 pip install pillow==6.1 -i https://pypi.tuna.tsinghua.edu.cn/simple

再次运行 报新的错误

(FairMOT) ckq@ckq:~/git/FairMOT/src$ python demo.py mot --load_model ../models/all_dla34.pth --conf_thres 0.4
Traceback (most recent call last):
  File "demo.py", line 14, in <module>
    import datasets.dataset.jde as datasets
  File "/home/ckq/git/FairMOT/src/lib/datasets/dataset/jde.py", line 16, in <module>
    from cython_bbox import bbox_overlaps as bbox_ious
ModuleNotFoundError: No module named 'cython_bbox'

解决:

pip install cython_bbox -i https://pypi.tuna.tsinghua.edu.cn/simple
(FairMOT) ckq@ckq:~/git/FairMOT/src$ python demo.py mot --load_model ../models/all_dla34.pth --conf_thres 0.4
Traceback (most recent call last):
  File "demo.py", line 15, in <module>
    from track import eval_seq
  File "/home/ckq/git/FairMOT/src/track.py", line 11, in <module>
    import motmetrics as mm
ModuleNotFoundError: No module named 'motmetrics'

解决:

pip install motmetrics -i https://pypi.tuna.tsinghua.edu.cn/simple
(FairMOT) ckq@ckq:~/git/FairMOT/src$ python demo.py mot --load_model ../models/all_dla34.pth --conf_thres 0.4
Traceback (most recent call last):
  File "demo.py", line 15, in <module>
    from track import eval_seq
  File "/home/ckq/git/FairMOT/src/track.py", line 15, in <module>
    from tracker.multitracker import JDETracker
  File "/home/ckq/git/FairMOT/src/lib/tracker/multitracker.py", line 8, in <module>
    from models.model import create_model, load_model
  File "/home/ckq/git/FairMOT/src/lib/models/model.py", line 9, in <module>
    from .networks.pose_hrnet import get_pose_net as get_pose_net_hrnet
  File "/home/ckq/git/FairMOT/src/lib/models/networks/pose_hrnet.py", line 13, in <module>
    from .config import cfg, update_config
  File "/home/ckq/git/FairMOT/src/lib/models/networks/config/__init__.py", line 1, in <module>
    from .default import _C as cfg
  File "/home/ckq/git/FairMOT/src/lib/models/networks/config/default.py", line 5, in <module>
    from yacs.config import CfgNode as CN
ModuleNotFoundError: No module named 'yacs'

解决:

pip install yacs -i https://pypi.tuna.tsinghua.edu.cn/simple
(FairMOT) ckq@ckq:~/git/FairMOT/src$ python demo.py mot --load_model ../models/all_dla34.pth --conf_thres 0.4
Traceback (most recent call last):
  File "demo.py", line 15, in <module>
    from track import eval_seq
  File "/home/ckq/git/FairMOT/src/track.py", line 15, in <module>
    from tracker.multitracker import JDETracker
  File "/home/ckq/git/FairMOT/src/lib/tracker/multitracker.py", line 10, in <module>
    from tracker import matching
  File "/home/ckq/git/FairMOT/src/lib/tracker/matching.py", line 1, in <module>
    import lap
ModuleNotFoundError: No module named 'lap'

解决:

pip install lap -i https://pypi.tuna.tsinghua.edu.cn/simple

总之一路报错,路改!!!!
ok!!!
到这里成功运行demo!!!

贴图贴图!!!
Ubuntu16.04 conda环境运行FaiMOT及相关配置_第1张图片
自己也录制了小视频!!!效果不是很好 可能因为我是室内环境吧!!!
Ubuntu16.04 conda环境运行FaiMOT及相关配置_第2张图片

下面附:
pip换国内的镜像源 一些国内的镜像源:

清华:https://pypi.tuna.tsinghua.edu.cn/simple

阿里云:http://mirrors.aliyun.com/pypi/simple/

中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/

华中理工大学:http://pypi.hustunique.com/

山东理工大学:http://pypi.sdutlinux.org/

豆瓣:http://pypi.douban.com/simple/

之后再添加 跑kitti数据集的效果图!!!!

你可能感兴趣的:(FairMOT,anaconda)