Flask部署Keras模型遇到的问题
AttributeError: ‘_thread._local’ object has no attribute ‘value’
定位到
tensorflow_backend.py
这个文件在这个位置
1
2
3
4
5
6
7
8
def symbolic_fn_wrapper(*args, **kwargs):
if _SYMBOLIC_SCOPE.value:
with get_graph().as_default():
return func(*args, **kwargs)
else:
return func(*args, **kwargs)
return symbolic_fn_wrapper增加
1
_SYMBOLIC_SCOPE.value = True
变成这样
1
2
3
4
5
6
7
8
9
def symbolic_fn_wrapper(*args, **kwargs):
_SYMBOLIC_SCOPE.value = True
if _SYMBOLIC_SCOPE.value:
with get_graph().as_default():
return func(*args, **kwargs)
else:
return func(*args, **kwargs)
return symbolic_fn_wrapper问题解决