Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
不会修仙的道士
labelme
提交
fdb18b9b
L
labelme
项目概览
不会修仙的道士
/
labelme
与 Fork 源项目一致
从无法访问的项目Fork
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
labelme
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fdb18b9b
编写于
3月 31, 2018
作者:
K
Kentaro Wada
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Show errorMessage with not existing file to load
上级
52a201f2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
63 addition
and
61 deletion
+63
-61
labelme/app.py
labelme/app.py
+63
-61
未找到文件。
labelme/app.py
浏览文件 @
fdb18b9b
...
...
@@ -738,68 +738,70 @@ class MainWindow(QMainWindow, WindowMixin):
if
filename
is
None
:
filename
=
self
.
settings
.
get
(
'filename'
,
''
)
filename
=
str
(
filename
)
if
QFile
.
exists
(
filename
):
# assumes same name, but json extension
self
.
status
(
"Loading %s..."
%
os
.
path
.
basename
(
str
(
filename
)))
label_file
=
os
.
path
.
splitext
(
filename
)[
0
]
+
'.json'
if
QFile
.
exists
(
label_file
)
and
LabelFile
.
isLabelFile
(
label_file
):
try
:
self
.
labelFile
=
LabelFile
(
label_file
)
# FIXME: PyQt4 installed via Anaconda fails to load JPEG
# and JSON encoded images.
# https://github.com/ContinuumIO/anaconda-issues/issues/131
if
QImage
.
fromData
(
self
.
labelFile
.
imageData
).
isNull
():
raise
LabelFileError
(
'Failed loading image data from label file.
\n
'
'Maybe this is a known issue of PyQt4 built on'
' Anaconda, and may be fixed by installing PyQt5.'
)
except
LabelFileError
as
e
:
self
.
errorMessage
(
'Error opening file'
,
(
"<p><b>%s</b></p>"
"<p>Make sure <i>%s</i> is a valid label file."
)
\
%
(
e
,
label_file
))
self
.
status
(
"Error reading %s"
%
label_file
)
return
False
self
.
imageData
=
self
.
labelFile
.
imageData
self
.
imagePath
=
os
.
path
.
join
(
os
.
path
.
dirname
(
label_file
),
self
.
labelFile
.
imagePath
)
self
.
lineColor
=
QColor
(
*
self
.
labelFile
.
lineColor
)
self
.
fillColor
=
QColor
(
*
self
.
labelFile
.
fillColor
)
else
:
# Load image:
# read data first and store for saving into label file.
self
.
imageData
=
read
(
filename
,
None
)
if
self
.
imageData
is
not
None
:
# the filename is image not JSON
self
.
imagePath
=
filename
self
.
labelFile
=
None
image
=
QImage
.
fromData
(
self
.
imageData
)
if
image
.
isNull
():
formats
=
[
'*.{}'
.
format
(
fmt
.
data
().
decode
())
for
fmt
in
QImageReader
.
supportedImageFormats
()]
self
.
errorMessage
(
'Error opening file'
,
'<p>Make sure <i>{0}</i> is a valid image file.<br/>'
'Supported image formats: {1}</p>'
.
format
(
filename
,
','
.
join
(
formats
)))
self
.
status
(
"Error reading %s"
%
filename
)
if
not
QFile
.
exists
(
filename
):
self
.
errorMessage
(
'Error opening file'
,
'No such file: <b>%s</b>'
%
filename
)
return
False
# assumes same name, but json extension
self
.
status
(
"Loading %s..."
%
os
.
path
.
basename
(
str
(
filename
)))
label_file
=
os
.
path
.
splitext
(
filename
)[
0
]
+
'.json'
if
QFile
.
exists
(
label_file
)
and
LabelFile
.
isLabelFile
(
label_file
):
try
:
self
.
labelFile
=
LabelFile
(
label_file
)
# FIXME: PyQt4 installed via Anaconda fails to load JPEG
# and JSON encoded images.
# https://github.com/ContinuumIO/anaconda-issues/issues/131
if
QImage
.
fromData
(
self
.
labelFile
.
imageData
).
isNull
():
raise
LabelFileError
(
'Failed loading image data from label file.
\n
'
'Maybe this is a known issue of PyQt4 built on'
' Anaconda, and may be fixed by installing PyQt5.'
)
except
LabelFileError
as
e
:
self
.
errorMessage
(
'Error opening file'
,
(
"<p><b>%s</b></p>"
"<p>Make sure <i>%s</i> is a valid label file."
)
\
%
(
e
,
label_file
))
self
.
status
(
"Error reading %s"
%
label_file
)
return
False
self
.
image
=
image
self
.
filename
=
filename
self
.
canvas
.
loadPixmap
(
QPixmap
.
fromImage
(
image
))
if
self
.
labelFile
:
self
.
loadLabels
(
self
.
labelFile
.
shapes
)
self
.
setClean
()
self
.
canvas
.
setEnabled
(
True
)
self
.
adjustScale
(
initial
=
True
)
self
.
paintCanvas
()
self
.
addRecentFile
(
self
.
filename
)
self
.
toggleActions
(
True
)
self
.
status
(
"Loaded %s"
%
os
.
path
.
basename
(
str
(
filename
)))
if
filename
in
self
.
imageList
:
self
.
fileListWidget
.
setCurrentRow
(
self
.
imageList
.
index
(
filename
))
return
True
return
False
self
.
imageData
=
self
.
labelFile
.
imageData
self
.
imagePath
=
os
.
path
.
join
(
os
.
path
.
dirname
(
label_file
),
self
.
labelFile
.
imagePath
)
self
.
lineColor
=
QColor
(
*
self
.
labelFile
.
lineColor
)
self
.
fillColor
=
QColor
(
*
self
.
labelFile
.
fillColor
)
else
:
# Load image:
# read data first and store for saving into label file.
self
.
imageData
=
read
(
filename
,
None
)
if
self
.
imageData
is
not
None
:
# the filename is image not JSON
self
.
imagePath
=
filename
self
.
labelFile
=
None
image
=
QImage
.
fromData
(
self
.
imageData
)
if
image
.
isNull
():
formats
=
[
'*.{}'
.
format
(
fmt
.
data
().
decode
())
for
fmt
in
QImageReader
.
supportedImageFormats
()]
self
.
errorMessage
(
'Error opening file'
,
'<p>Make sure <i>{0}</i> is a valid image file.<br/>'
'Supported image formats: {1}</p>'
.
format
(
filename
,
','
.
join
(
formats
)))
self
.
status
(
"Error reading %s"
%
filename
)
return
False
self
.
image
=
image
self
.
filename
=
filename
self
.
canvas
.
loadPixmap
(
QPixmap
.
fromImage
(
image
))
if
self
.
labelFile
:
self
.
loadLabels
(
self
.
labelFile
.
shapes
)
self
.
setClean
()
self
.
canvas
.
setEnabled
(
True
)
self
.
adjustScale
(
initial
=
True
)
self
.
paintCanvas
()
self
.
addRecentFile
(
self
.
filename
)
self
.
toggleActions
(
True
)
self
.
status
(
"Loaded %s"
%
os
.
path
.
basename
(
str
(
filename
)))
if
filename
in
self
.
imageList
:
self
.
fileListWidget
.
setCurrentRow
(
self
.
imageList
.
index
(
filename
))
return
True
def
resizeEvent
(
self
,
event
):
if
self
.
canvas
and
not
self
.
image
.
isNull
()
\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录