Cython编译文件出错

报错信息:

(rpc) stu@amax:~/segment/dss_crf$ python setup.py install
Compiling pydensecrf/eigen.pyx because it changed.
Compiling pydensecrf/densecrf.pyx because it changed.
[1/2] Cythonizing pydensecrf/densecrf.pyx
/home/stu/anaconda3/envs/rpc/lib/python3.6/site-packages/Cython/Compiler/Main.py:381: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /home/stu03/kdy/rpc/segment/dss_crf/pydensecrf/densecrf.pxd
  tree = Parsing.p_module(s, pxd, full_module_name)

Error compiling Cython file:
------------------------------------------------------------
...
from eigen cimport *
^
------------------------------------------------------------

pydensecrf/densecrf.pxd:1:0: 'eigen.pxd' not found

Error compiling Cython file:
------------------------------------------------------------
...

    cdef cppclass PottsCompatibility(LabelCompatibility):
        PottsCompatibility(float) except +

    cdef cppclass DiagonalCompatibility(LabelCompatibility):
        DiagonalCompatibility(const c_VectorXf&) except +
                                    ^
------------------------------------------------------------

pydensecrf/densecrf.pxd:12:36: 'c_VectorXf' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...

    cdef cppclass DiagonalCompatibility(LabelCompatibility):
        DiagonalCompatibility(const c_VectorXf&) except +

    cdef cppclass MatrixCompatibility(LabelCompatibility):
        MatrixCompatibility(const c_MatrixXf&) except +
                                  ^
------------------------------------------------------------

pydensecrf/densecrf.pxd:15:34: 'c_MatrixXf' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
cdef extern from "densecrf/include/unary.h":
    cdef cppclass UnaryEnergy:
        pass

    cdef cppclass ConstUnaryEnergy(UnaryEnergy):
        ConstUnaryEnergy(const c_MatrixXf& unary) except +
                               ^
------------------------------------------------------------

pydensecrf/densecrf.pxd:23:31: 'c_MatrixXf' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...

    cdef cppclass ConstUnaryEnergy(UnaryEnergy):
        ConstUnaryEnergy(const c_MatrixXf& unary) except +

    cdef cppclass LogisticUnaryEnergy(UnaryEnergy):
        LogisticUnaryEnergy(const c_MatrixXf& L, const c_MatrixXf& feature) except +
                                  ^
------------------------------------------------------------

pydensecrf/densecrf.pxd:26:34: 'c_MatrixXf' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...

    cdef cppclass ConstUnaryEnergy(UnaryEnergy):
        ConstUnaryEnergy(const c_MatrixXf& unary) except +

    cdef cppclass LogisticUnaryEnergy(UnaryEnergy):
        LogisticUnaryEnergy(const c_MatrixXf& L, const c_MatrixXf& feature) except +
                                                       ^
------------------------------------------------------------

pydensecrf/densecrf.pxd:26:55: 'c_MatrixXf' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        c_DenseCRF(int N, int M) except +

        # Setup methods.
        # TODO
        #void addPairwiseEnergy(PairwisePotential *potential)
        void addPairwiseEnergy(const c_MatrixXf &features, LabelCompatibility*, KernelType, NormalizationType)
                                     ^
------------------------------------------------------------

pydensecrf/densecrf.pxd:54:37: 'c_MatrixXf' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        # Setup methods.
        # TODO
        #void addPairwiseEnergy(PairwisePotential *potential)
        void addPairwiseEnergy(const c_MatrixXf &features, LabelCompatibility*, KernelType, NormalizationType)
        void setUnaryEnergy(UnaryEnergy *unary)
        void setUnaryEnergy(const c_MatrixXf &unary)
                                  ^
------------------------------------------------------------

pydensecrf/densecrf.pxd:56:34: 'c_MatrixXf' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        # TODO
        #void addPairwiseEnergy(PairwisePotential *potential)
        void addPairwiseEnergy(const c_MatrixXf &features, LabelCompatibility*, KernelType, NormalizationType)
        void setUnaryEnergy(UnaryEnergy *unary)
        void setUnaryEnergy(const c_MatrixXf &unary)
        void setUnaryEnergy(const c_MatrixXf &L, const c_MatrixXf &feature)
                                  ^
------------------------------------------------------------

pydensecrf/densecrf.pxd:57:34: 'c_MatrixXf' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        # TODO
        #void addPairwiseEnergy(PairwisePotential *potential)
        void addPairwiseEnergy(const c_MatrixXf &features, LabelCompatibility*, KernelType, NormalizationType)
        void setUnaryEnergy(UnaryEnergy *unary)
        void setUnaryEnergy(const c_MatrixXf &unary)
        void setUnaryEnergy(const c_MatrixXf &L, const c_MatrixXf &feature)
                                                       ^
------------------------------------------------------------

pydensecrf/densecrf.pxd:57:55: 'c_MatrixXf' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        void setUnaryEnergy(UnaryEnergy *unary)
        void setUnaryEnergy(const c_MatrixXf &unary)
        void setUnaryEnergy(const c_MatrixXf &L, const c_MatrixXf &feature)

        # Inference methods.
        c_MatrixXf inference(int n_iterations)
        ^
------------------------------------------------------------

pydensecrf/densecrf.pxd:60:8: 'c_MatrixXf' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        c_MatrixXf inference(int n_iterations)
        # TODO: Not enabled because it would require wrapping VectorXs (note the `s`)
        #c_VectorXs map(int n_iterations)

        # Step-by-step inference methods.
        c_MatrixXf startInference() const
        ^
------------------------------------------------------------

pydensecrf/densecrf.pxd:65:8: 'c_MatrixXf' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        # TODO: Not enabled because it would require wrapping VectorXs (note the `s`)
        #c_VectorXs map(int n_iterations)

        # Step-by-step inference methods.
        c_MatrixXf startInference() const
        void stepInference(c_MatrixXf &Q, c_MatrixXf &tmp1, c_MatrixXf &tmp2) const
                           ^
------------------------------------------------------------

pydensecrf/densecrf.pxd:66:27: 'c_MatrixXf' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        # TODO: Not enabled because it would require wrapping VectorXs (note the `s`)
        #c_VectorXs map(int n_iterations)

        # Step-by-step inference methods.
        c_MatrixXf startInference() const
        void stepInference(c_MatrixXf &Q, c_MatrixXf &tmp1, c_MatrixXf &tmp2) const
                                          ^
------------------------------------------------------------

pydensecrf/densecrf.pxd:66:42: 'c_MatrixXf' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        # TODO: Not enabled because it would require wrapping VectorXs (note the `s`)
        #c_VectorXs map(int n_iterations)

        # Step-by-step inference methods.
        c_MatrixXf startInference() const
        void stepInference(c_MatrixXf &Q, c_MatrixXf &tmp1, c_MatrixXf &tmp2) const
                                                            ^
------------------------------------------------------------

pydensecrf/densecrf.pxd:66:60: 'c_MatrixXf' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        # Step-by-step inference methods.
        c_MatrixXf startInference() const
        void stepInference(c_MatrixXf &Q, c_MatrixXf &tmp1, c_MatrixXf &tmp2) const
        #double gradient( int n_iterations, const ObjectiveFunction & objective, c_VectorXf * unary_grad, c_VectorXf * lbl_cmp_grad, c_VectorXf * kernel_grad=NULL ) const;

        double klDivergence(const c_MatrixXf &Q) const
                                  ^
------------------------------------------------------------

pydensecrf/densecrf.pxd:69:34: 'c_MatrixXf' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        return eigen.MatrixXf().wrap(self._this.inference(niter))

    def startInference(self):
        return eigen.MatrixXf().wrap(self._this.startInference()), eigen.MatrixXf(), eigen.MatrixXf()

    def stepInference(self, MatrixXf Q, MatrixXf tmp1, MatrixXf tmp2):
                            ^
------------------------------------------------------------

pydensecrf/densecrf.pyx:85:28: 'MatrixXf' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        return eigen.MatrixXf().wrap(self._this.inference(niter))

    def startInference(self):
        return eigen.MatrixXf().wrap(self._this.startInference()), eigen.MatrixXf(), eigen.MatrixXf()

    def stepInference(self, MatrixXf Q, MatrixXf tmp1, MatrixXf tmp2):
                                        ^
------------------------------------------------------------

pydensecrf/densecrf.pyx:85:40: 'MatrixXf' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        return eigen.MatrixXf().wrap(self._this.inference(niter))

    def startInference(self):
        return eigen.MatrixXf().wrap(self._this.startInference()), eigen.MatrixXf(), eigen.MatrixXf()

    def stepInference(self, MatrixXf Q, MatrixXf tmp1, MatrixXf tmp2):
                                                       ^
------------------------------------------------------------

pydensecrf/densecrf.pyx:85:55: 'MatrixXf' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...
        return eigen.MatrixXf().wrap(self._this.startInference()), eigen.MatrixXf(), eigen.MatrixXf()

    def stepInference(self, MatrixXf Q, MatrixXf tmp1, MatrixXf tmp2):
        self._this.stepInference(Q.m, tmp1.m, tmp2.m)

    def klDivergence(self, MatrixXf Q):
                           ^
------------------------------------------------------------

pydensecrf/densecrf.pyx:88:27: 'MatrixXf' is not a type identifier

Error compiling Cython file:
------------------------------------------------------------
...

    def addPairwiseEnergy(self, float[:,::1] features not None, compat, KernelType kernel=DIAG_KERNEL, NormalizationType normalization=NORMALIZE_SYMMETRIC):
        self._this.addPairwiseEnergy(eigen.c_matrixXf(features), _labelcomp(compat), kernel, normalization)

    def setUnary(self, Unary u):
        self._this.setUnaryEnergy(u.move())
                                 ^
------------------------------------------------------------

pydensecrf/densecrf.pyx:71:33: ambiguous overloaded method
Traceback (most recent call last):
  File "setup.py", line 16, in <module>
    ext_modules=cythonize(['pydensecrf/eigen.pyx', 'pydensecrf/densecrf.pyx']),
  File "/home/stu/anaconda3/envs/rpc/lib/python3.6/site-packages/Cython/Build/Dependencies.py", line 1154, in cythonize
    cythonize_one(*args)
  File "/home/stu/anaconda3/envs/rpc/lib/python3.6/site-packages/Cython/Build/Dependencies.py", line 1321, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: pydensecrf/densecrf.pyx
(rpc) stu@amax:~/segment/dss_crf$

解决方法

(1)尝试从该目录中删除__init__.py。由于某些原因,它在尝试编译时混淆了cython。

(2)考虑使用pyximport扩展名: import pyximport; pyximport.install(),然后import your_module(好像是一个normal.py),如果您只想从普通python文件导入.pyx文件。

注意:在第二种情况下,__init__.py不必删除。

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
Transformer发轫于NLP(自然语言处理),并跨界应用到CV(计算机视觉)领域。 Swin Transformer是基于Transformer的计算机视觉骨干网,在图像分类、目标检测、实例分割、语义分割等多项下游CV应用中取得了SOTA的性能。该项工作也获得了ICCV 2021顶会最佳论文奖。本课程将手把手地教大家使用labelme标注和使用Swin Transformer训练自己的数据集进行图片和视频的实例分割。  本课程将介绍Transformer及在CV领域的应用、Swin Transformer的原理。 本课程以汽车驾驶场景图片和视频开展项目实践:对汽车行驶场景中的路坑、车、车道线进行物体标注和实例分割。  课程在Windows和Ubuntu系统上分别做项目演示。包括:安装软件环境、安装Pytorch、安装Swin-Transformer-Object-Detection、标注自己的数据集、准备自己的数据集、数据集格式转换(Python脚本完成)、修改配置文件、训练自己的数据集、测试训练出的网络模型、性能统计、日志分析。  本课程提供项目的数据集和相关Python程序文件。相关课程: 《Transformer原理与代码精讲(PyTorch)》https://edu.csdn.net/course/detail/36697《Transformer原理与代码精讲(TensorFlow)》https://edu.csdn.net/course/detail/36699《ViT(Vision Transformer)原理与代码精讲》https://edu.csdn.net/course/detail/36719《DETR原理与代码精讲》https://edu.csdn.net/course/detail/36768《Swin Transformer实战目标检测:训练自己的数据集》https://edu.csdn.net/course/detail/36585《Swin Transformer实战实例分割:训练自己的数据集》https://edu.csdn.net/course/detail/36586《Swin Transformer原理与代码精讲》 https://download.csdn.net/course/detail/37045

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值