FIx issue#403
This commit is contained in:
parent
eaac031404
commit
6db1dd500d
@ -28,7 +28,7 @@ Installation
|
||||
Download prebuilt binaries
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
- `Windows & Linux <https://tzutalin.github.io/labelImg/>`__
|
||||
- `Windows <https://github.com/tzutalin/labelImg/releases>`__
|
||||
|
||||
- macOS. Binaries for macOS are not yet available. Help would be appreciated. At present, it must be `built from source <#macos>`__.
|
||||
|
||||
|
||||
16
labelImg.py
16
labelImg.py
@ -795,20 +795,19 @@ class MainWindow(QMainWindow, WindowMixin):
|
||||
# Can add differrent annotation formats here
|
||||
try:
|
||||
if self.usingPascalVocFormat is True:
|
||||
if ustr(annotationFilePath[-4:]) != ".xml":
|
||||
if annotationFilePath[-4:].lower() != ".xml":
|
||||
annotationFilePath += XML_EXT
|
||||
print ('Img: ' + self.filePath + ' -> Its xml: ' + annotationFilePath)
|
||||
self.labelFile.savePascalVocFormat(annotationFilePath, shapes, self.filePath, self.imageData,
|
||||
self.lineColor.getRgb(), self.fillColor.getRgb())
|
||||
elif self.usingYoloFormat is True:
|
||||
if annotationFilePath[-4:] != ".txt":
|
||||
if annotationFilePath[-4:].lower() != ".txt":
|
||||
annotationFilePath += TXT_EXT
|
||||
print ('Img: ' + self.filePath + ' -> Its txt: ' + annotationFilePath)
|
||||
self.labelFile.saveYoloFormat(annotationFilePath, shapes, self.filePath, self.imageData, self.labelHist,
|
||||
self.lineColor.getRgb(), self.fillColor.getRgb())
|
||||
else:
|
||||
self.labelFile.save(annotationFilePath, shapes, self.filePath, self.imageData,
|
||||
self.lineColor.getRgb(), self.fillColor.getRgb())
|
||||
print('Image:{0} -> Annotation:{1}'.format(self.filePath, annotationFilePath))
|
||||
return True
|
||||
except LabelFileError as e:
|
||||
self.errorMessage(u'Error saving label data', u'<b>%s</b>' % e)
|
||||
@ -1293,13 +1292,13 @@ class MainWindow(QMainWindow, WindowMixin):
|
||||
savedFileName = os.path.splitext(imgFileName)[0]
|
||||
savedPath = os.path.join(imgFileDir, savedFileName)
|
||||
self._saveFile(savedPath if self.labelFile
|
||||
else self.saveFileDialog())
|
||||
else self.saveFileDialog(removeExt=False))
|
||||
|
||||
def saveFileAs(self, _value=False):
|
||||
assert not self.image.isNull(), "cannot save empty image"
|
||||
self._saveFile(self.saveFileDialog())
|
||||
|
||||
def saveFileDialog(self):
|
||||
def saveFileDialog(self, removeExt=True):
|
||||
caption = '%s - Choose File' % __appname__
|
||||
filters = 'File (*%s)' % LabelFile.suffix
|
||||
openDialogPath = self.currentPath()
|
||||
@ -1311,7 +1310,10 @@ class MainWindow(QMainWindow, WindowMixin):
|
||||
dlg.setOption(QFileDialog.DontUseNativeDialog, False)
|
||||
if dlg.exec_():
|
||||
fullFilePath = ustr(dlg.selectedFiles()[0])
|
||||
return os.path.splitext(fullFilePath)[0] # Return file path without the extension.
|
||||
if removeExt:
|
||||
return os.path.splitext(fullFilePath)[0] # Return file path without the extension.
|
||||
else:
|
||||
return fullFilePath
|
||||
return ''
|
||||
|
||||
def _saveFile(self, annotationFilePath):
|
||||
|
||||
|
Before Width: | Height: | Size: 257 KiB After Width: | Height: | Size: 257 KiB |
@ -12,7 +12,7 @@ class TestPascalVocRW(unittest.TestCase):
|
||||
from pascal_voc_io import PascalVocReader
|
||||
|
||||
# Test Write/Read
|
||||
writer = PascalVocWriter('tests', 'test', (512, 512, 1), localImgPath='tests/test.bmp')
|
||||
writer = PascalVocWriter('tests', 'test', (512, 512, 1), localImgPath='tests/test.512.512.bmp')
|
||||
difficult = 1
|
||||
writer.addBndBox(60, 40, 430, 504, 'person', difficult)
|
||||
writer.addBndBox(113, 40, 450, 403, 'face', difficult)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user