網頁

2018年5月3日 星期四

jupyter notebook

jupyter notebook 出錯

(tensorflow) D:\TensorFlow>jupyter notebook
Traceback (most recent call last):
  File "d:\anaconda3\envs\tensorflow\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "d:\anaconda3\envs\tensorflow\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\Anaconda3\envs\tensorflow\Scripts\jupyter-notebook.EXE\__main__.py", line 5, in <module>
  File "d:\anaconda3\envs\tensorflow\lib\site-packages\notebook\notebookapp.py", line 44, in <module>
    from zmq.eventloop import ioloop
  File "d:\anaconda3\envs\tensorflow\lib\site-packages\zmq\__init__.py", line 47, in <module>
    from zmq import backend
  File "d:\anaconda3\envs\tensorflow\lib\site-packages\zmq\backend\__init__.py", line 40, in <module>
    reraise(*exc_info)
  File "d:\anaconda3\envs\tensorflow\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
    raise value
  File "d:\anaconda3\envs\tensorflow\lib\site-packages\zmq\backend\__init__.py", line 27, in <module>
    _ns = select_backend(first)
  File "d:\anaconda3\envs\tensorflow\lib\site-packages\zmq\backend\select.py", line 26, in select_backend
    mod = __import__(name, fromlist=public_api)
  File "d:\anaconda3\envs\tensorflow\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
    from . import (constants, error, message, context,
ImportError: cannot import name 'constants'

重新安裝 pyzmq 可以解決
pip uninstall pyzmq
pip install pyzmq




2018年5月2日 星期三

python labelImg.py 增加另一資料(pose)輸入

執行遇到問題
conda install pyqt=5
pip install --upgrade lxml
pyrcc5 -o resources.py resources.qrc

出現錯誤
Traceback (most recent call last):
  File "labelImg.py", line 1452, in <module>
    sys.exit(main())
  File "labelImg.py", line 1448, in main
    app, _win = get_main_app(sys.argv)
  File "labelImg.py", line 1441, in get_main_app
    argv[3] if len(argv) >= 4 else None)
  File "labelImg.py", line 109, in __init__
    self.settings.load()
  File "D:\TensorFlow\ObjectDetection\labelImg\libs\settings.py", line 33, in load
    self.data = pickle.load(f, encoding="iso-8859-1")
ModuleNotFoundError: No module named 'PyQt4'
請刪除 c:\users\user name\.labelImgSettings.pkl

pascal_voc_io.py
  def addBndBox(self, xmin, ymin, xmax, ymax, name, pose, difficult):
    bndbox['pose'] = pose
self.boxlist.append(bndbox)
  def appendObjects(self, top):
    for each_object in self.boxlist:
      pose.text = unicode(each_object['pose'])
  def save(self, targetFile=None):
    self.appendObjects(root)

labelFile.py
  def savePascalVocFormat(self, filename, shapes, imagePath, imageData, lineColor=None, fillColor=None, databaseSrc=None):
    for shape in shapes:
  pose = shape['pose']
  writer.addBndBox(bndbox[0], bndbox[1], bndbox[2], bndbox[3], label, pose, difficult)

canvas.py

labelImage.py
class MainWindow(QMainWindow, WindowMixin):
  def __init__(self, defaultFilename=None, defaultPrefdefClassFile=None, defaultSaveDir=None):
    self.labelList = QListWidget()
self.canvas = Canvas(parent=self)
  def saveLabels(self, annotationFilePath):
    shapes = [format_shape(shape) for shape in self.canvas.shapes]
self.labelFile.savePascalVocFormat(annotationFilePath, shapes, self.filePath, self.imageData, self.lineColor.getRgb(), self.fillColor.getRgb())
  def addLabel(self, shape):
    item = HashableQListWidgetItem(shape.label)
item.setPose(shape.pose)
self.labelList.addItem(item)
  def currentItem(self):
    items = self.labelList.selectedItems()
return items[0]
  def editLabel(self):
    item = self.currentItem()
text, pose = self.labelDialog.popUp(item.text(), item.getPose())
item.setPose(pose)
item.setLabel(label)
item.setText(label + "_" + pose)
  def labelItemChanged(self, item):
    shape = self.itemsToShapes[item]
shape.label = item.text()
class HashableQListWidgetItem(QListWidgetItem):

labelDialog.py
  def popUp(self, text='', pose='', move=True):