From 7da07a8370363743bf57f70a814e3e2afb59e938 Mon Sep 17 00:00:00 2001 From: "xixing.tj" Date: Wed, 24 Aug 2022 15:30:38 +0800 Subject: [PATCH] =?UTF-8?q?[to=20#42322933]ocr=5Fdetection=20pipeline=20ju?= =?UTF-8?q?pyter=E7=8E=AF=E5=A2=83bug=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ocr_detection pipeline jupyter环境优化 Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/9876662 --- modelscope/pipelines/cv/ocr_detection_pipeline.py | 5 +++++ modelscope/pipelines/cv/ocr_utils/ops.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modelscope/pipelines/cv/ocr_detection_pipeline.py b/modelscope/pipelines/cv/ocr_detection_pipeline.py index b54ad96d..62248714 100644 --- a/modelscope/pipelines/cv/ocr_detection_pipeline.py +++ b/modelscope/pipelines/cv/ocr_detection_pipeline.py @@ -17,6 +17,11 @@ from .ocr_utils import (SegLinkDetector, cal_width, combine_segments_python, decode_segments_links_python, nms_python, rboxes_to_polygons) +if tf.__version__ >= '2.0': + import tf_slim as slim +else: + from tensorflow.contrib import slim + if tf.__version__ >= '2.0': tf = tf.compat.v1 tf.compat.v1.disable_eager_execution() diff --git a/modelscope/pipelines/cv/ocr_utils/ops.py b/modelscope/pipelines/cv/ocr_utils/ops.py index 2bc8a8bf..eeab36a0 100644 --- a/modelscope/pipelines/cv/ocr_utils/ops.py +++ b/modelscope/pipelines/cv/ocr_utils/ops.py @@ -88,7 +88,7 @@ def _nn_variable(name, shape, init_method, collection=None, **kwargs): else: raise 'Unsupported weight initialization method: ' + init_method - var = tf.get_variable(name, shape=shape, initializer=initializer, **kwargs) + var = tf.get_variable(name, shape=shape, initializer=initializer) if collection is not None: tf.add_to_collection(collection, var)