resolve if don't select default save dir, can't load xml file(saved dir same with image) issue.
resolve cannot open annotation xml file issue.
This commit is contained in:
parent
ef13a1ede5
commit
c3d1baac5f
18
labelImg.py
18
labelImg.py
@ -826,12 +826,16 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
self.toggleActions(True)
|
self.toggleActions(True)
|
||||||
|
|
||||||
# Label xml file and show bound box according to its filename
|
# Label xml file and show bound box according to its filename
|
||||||
if self.usingPascalVocFormat is True and \
|
if self.usingPascalVocFormat is True:
|
||||||
self.defaultSaveDir is not None:
|
if self.defaultSaveDir is not None:
|
||||||
basename = os.path.basename(
|
basename = os.path.basename(
|
||||||
os.path.splitext(self.filePath)[0]) + XML_EXT
|
os.path.splitext(self.filePath)[0]) + XML_EXT
|
||||||
xmlPath = os.path.join(self.defaultSaveDir, basename)
|
xmlPath = os.path.join(self.defaultSaveDir, basename)
|
||||||
self.loadPascalXMLByFilename(xmlPath)
|
self.loadPascalXMLByFilename(xmlPath)
|
||||||
|
else:
|
||||||
|
xmlPath = filePath.split(".")[0] + XML_EXT
|
||||||
|
if os.path.isfile(xmlPath):
|
||||||
|
self.loadPascalXMLByFilename(xmlPath)
|
||||||
|
|
||||||
self.setWindowTitle(__appname__ + ' ' + filePath)
|
self.setWindowTitle(__appname__ + ' ' + filePath)
|
||||||
|
|
||||||
@ -942,12 +946,12 @@ class MainWindow(QMainWindow, WindowMixin):
|
|||||||
path = os.path.dirname(u(self.filePath))\
|
path = os.path.dirname(u(self.filePath))\
|
||||||
if self.filePath else '.'
|
if self.filePath else '.'
|
||||||
if self.usingPascalVocFormat:
|
if self.usingPascalVocFormat:
|
||||||
formats = ['*.%s' % str(fmt).lower()
|
|
||||||
for fmt in QImageReader.supportedImageFormats()]
|
|
||||||
filters = "Open Annotation XML file (%s)" % \
|
filters = "Open Annotation XML file (%s)" % \
|
||||||
' '.join(formats + ['*.xml'])
|
' '.join(['*.xml'])
|
||||||
filename = str(QFileDialog.getOpenFileName(self,
|
filename = QFileDialog.getOpenFileName(self,'%s - Choose a xml file' % __appname__, path, filters)
|
||||||
'%s - Choose a xml file' % __appname__, path, filters))
|
if filename:
|
||||||
|
if isinstance(filename, (tuple, list)):
|
||||||
|
filename = filename[0]
|
||||||
self.loadPascalXMLByFilename(filename)
|
self.loadPascalXMLByFilename(filename)
|
||||||
|
|
||||||
def openDir(self, _value=False):
|
def openDir(self, _value=False):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user