Skip to content

Commit 6db1dd5

Browse files
committed
FIx issue#403
1 parent eaac031 commit 6db1dd5

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Installation
2828
Download prebuilt binaries
2929
~~~~~~~~~~~~~~~~~~~~~~~~~~
3030

31-
- `Windows & Linux <https://tzutalin.github.io/labelImg/>`__
31+
- `Windows <https://github.com/tzutalin/labelImg/releases>`__
3232

3333
- macOS. Binaries for macOS are not yet available. Help would be appreciated. At present, it must be `built from source <#macos>`__.
3434

labelImg.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -795,20 +795,19 @@ def format_shape(s):
795795
# Can add differrent annotation formats here
796796
try:
797797
if self.usingPascalVocFormat is True:
798-
if ustr(annotationFilePath[-4:]) != ".xml":
798+
if annotationFilePath[-4:].lower() != ".xml":
799799
annotationFilePath += XML_EXT
800-
print ('Img: ' + self.filePath + ' -> Its xml: ' + annotationFilePath)
801800
self.labelFile.savePascalVocFormat(annotationFilePath, shapes, self.filePath, self.imageData,
802801
self.lineColor.getRgb(), self.fillColor.getRgb())
803802
elif self.usingYoloFormat is True:
804-
if annotationFilePath[-4:] != ".txt":
803+
if annotationFilePath[-4:].lower() != ".txt":
805804
annotationFilePath += TXT_EXT
806-
print ('Img: ' + self.filePath + ' -> Its txt: ' + annotationFilePath)
807805
self.labelFile.saveYoloFormat(annotationFilePath, shapes, self.filePath, self.imageData, self.labelHist,
808806
self.lineColor.getRgb(), self.fillColor.getRgb())
809807
else:
810808
self.labelFile.save(annotationFilePath, shapes, self.filePath, self.imageData,
811809
self.lineColor.getRgb(), self.fillColor.getRgb())
810+
print('Image:{0} -> Annotation:{1}'.format(self.filePath, annotationFilePath))
812811
return True
813812
except LabelFileError as e:
814813
self.errorMessage(u'Error saving label data', u'<b>%s</b>' % e)
@@ -1293,13 +1292,13 @@ def saveFile(self, _value=False):
12931292
savedFileName = os.path.splitext(imgFileName)[0]
12941293
savedPath = os.path.join(imgFileDir, savedFileName)
12951294
self._saveFile(savedPath if self.labelFile
1296-
else self.saveFileDialog())
1295+
else self.saveFileDialog(removeExt=False))
12971296

12981297
def saveFileAs(self, _value=False):
12991298
assert not self.image.isNull(), "cannot save empty image"
13001299
self._saveFile(self.saveFileDialog())
13011300

1302-
def saveFileDialog(self):
1301+
def saveFileDialog(self, removeExt=True):
13031302
caption = '%s - Choose File' % __appname__
13041303
filters = 'File (*%s)' % LabelFile.suffix
13051304
openDialogPath = self.currentPath()
@@ -1311,7 +1310,10 @@ def saveFileDialog(self):
13111310
dlg.setOption(QFileDialog.DontUseNativeDialog, False)
13121311
if dlg.exec_():
13131312
fullFilePath = ustr(dlg.selectedFiles()[0])
1314-
return os.path.splitext(fullFilePath)[0] # Return file path without the extension.
1313+
if removeExt:
1314+
return os.path.splitext(fullFilePath)[0] # Return file path without the extension.
1315+
else:
1316+
return fullFilePath
13151317
return ''
13161318

13171319
def _saveFile(self, annotationFilePath):
File renamed without changes.

tests/test_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def test_upper(self):
1212
from pascal_voc_io import PascalVocReader
1313

1414
# Test Write/Read
15-
writer = PascalVocWriter('tests', 'test', (512, 512, 1), localImgPath='tests/test.bmp')
15+
writer = PascalVocWriter('tests', 'test', (512, 512, 1), localImgPath='tests/test.512.512.bmp')
1616
difficult = 1
1717
writer.addBndBox(60, 40, 430, 504, 'person', difficult)
1818
writer.addBndBox(113, 40, 450, 403, 'face', difficult)

0 commit comments

Comments
 (0)