首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >模块未找到错误(imutils.paths)

模块未找到错误(imutils.paths)
EN

Stack Overflow用户
提问于 2018-04-15 02:55:01
回答 2查看 3.7K关注 0票数 1

,这是我试图在python3.6中的虚拟环境上运行的代码。我使用ubuntu最新版本17.10,我运行代码作为python3 gather_annotations.py

代码语言:javascript
复制
import numpy as np  
import cv2 
import argparse  
from imutils.paths import list_images
from selectors import BoxSelector  
#parse arguments
ap = argparse.ArgumentParser()  
ap.add_argument("-d","--dataset",required=True,help="path to images dataset...")  
ap.add_argument("-a","--annotations",required=True,help="path to save annotations...")  
ap.add_argument("-i","--images",required=True,help="path to save images")  
args = vars(ap.parse_args())  
#annotations and image paths  
annotations = []  
imPaths = []  
#loop through each image and collect annotations  
for imagePath in list_images(args["dataset"]):  
    #load image and create a BoxSelector instance  
    image = cv2.imread(imagePath)  
    bs = BoxSelector(image,"Image")  
    cv2.imshow("Image",image)  
    cv2.waitKey(0)  
    #order the points suitable for the Object detector  
    pt1,pt2 = bs.roiPts  
    (x,y,xb,yb) = [pt1[0],pt1[1],pt2[0],pt2[1]]  
    annotations.append([int(x),int(y),int(xb),int(yb)])  
    imPaths.append(imagePath)  
#save annotations and image paths to disk  
annotations = np.array(annotations)  
imPaths = np.array(imPaths,dtype="unicode")  
np.save(args["annotations"],annotations)  
np.save(args["images"],imPaths)  

And I get the following errors

我有一个名为'2‘的文件夹,其中有所有的脚本,还有其他名为selectors的文件夹,其中有2个脚本init和box_selector

  • 2(文件夹)
  • -选择器/
  • - _.py
  • -侦探,比
  • -收集注释。
  • -火车

我怎么才能解决这个问题呢?在我得到代码的那篇文章中,我提到了一些关于“相对进口”的内容,但我无法修复,谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2018-04-15 03:51:22

你需要用。用于访问文件夹中的文件的符号。

所以

代码语言:javascript
复制
from folder.python_file import ClassOrMethod

在你的情况下

代码语言:javascript
复制
from selectors.box_selector import BoxSelector

在选择器文件夹中拥有__init__.py是使此工作的关键。

您可以按如下方式访问任意数量的文件夹,但每个文件夹都必须包含一个__init__.py才能工作

代码语言:javascript
复制
from folder.folder1.folder2.python_file import ClassOrMethod
票数 1
EN

Stack Overflow用户

发布于 2019-05-01 23:47:43

一个可能的混淆区域是,有一个不同的python库,称为" selectors“,它不同于本代码示例中的选择器。

https://docs.python.org/3/library/selectors.html

最后,我将此示例的“选择器”(包括目录)重命名为"boxselectors“。

这个例子来自http://www.hackevolve.com/create-your-own-object-detector/

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49838068

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档