1 现象描述
c++调用python程序。调用的main函数,该main函数中有如下代码:
from matching import Matching
其中matching是和main文件在同一个目录下的文件,这里面定义了一个类,结构如下:
import torch
class Matching(torch.nn.Module):
""" Image Matching Frontend (SuperPoint + SuperGlue) """
def __init__(self, config={}):
怪现象出现了。
在Ajax上运行c++调用python正确。
在Nx上运行上述c++调用python则出现了错误。报的错误是:
这个错误:
from matching import Matching
另外,在Nx上直接使用python运行也没有问题,但是使用c++调用则有问题。
2 解决方案
最后使用下面方法解决了:
matching文件更改为imatching文件名称,同时,其中的类名成更改为IMatching。如下:
import torch
class IMatching(torch.nn.Module):
""" Image Matching Frontend (SuperPoint + SuperGlue) """
def __init__(self, config={}):
main中的引用更改为:
from imatching import IMatching
问题解决了。
但是不太清楚什么原因造成的!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)