diff --git a/modules/image/Image_gan/style_transfer/U2Net_Portrait/README.md b/modules/image/Image_gan/style_transfer/U2Net_Portrait/README.md index e2724618d42095ebf05e410ece2ced9b06c831d6..4175ec598c6e02a65a744a9b26dd7c00aa2efd43 100644 --- a/modules/image/Image_gan/style_transfer/U2Net_Portrait/README.md +++ b/modules/image/Image_gan/style_transfer/U2Net_Portrait/README.md @@ -50,16 +50,16 @@ ## 三、模型API预测 -- ### 1、代码示例 +- ### 1、预测代码示例 - ```python import paddlehub as hub import cv2 model = hub.Module(name="U2Net_Portrait") - result = model.Cartoon_GEN(images=[cv2.imread('/PATH/TO/IMAGE')]) + result = model.Portrait_GEN(images=[cv2.imread('/PATH/TO/IMAGE')]) # or - # result = model.Cartoon_GEN(paths=['/PATH/TO/IMAGE']) + # result = model.Portrait_GEN(paths=['/PATH/TO/IMAGE']) ``` - ### 2、API diff --git a/paddlehub/utils/pypi.py b/paddlehub/utils/pypi.py index 8f0f3c68c4a254138b0d647b81d484803735ede6..6a6d76535f25b13e46448e72eef7852c9d9f9654 100644 --- a/paddlehub/utils/pypi.py +++ b/paddlehub/utils/pypi.py @@ -15,10 +15,11 @@ import os import subprocess +import sys from typing import IO from paddlehub.utils.utils import Version -from paddlehub.utils.io import discard_oe, typein +from paddlehub.utils.io import discard_oe def get_installed_packages() -> dict: @@ -40,13 +41,14 @@ def check(package: str, version: str = '') -> bool: return pdict[package].match(version) -def install(package: str, version: str = '', upgrade: bool = False, ostream: IO = None, estream: IO = None) -> bool: +def install(package: str, version: str = '', upgrade: bool = False, ostream: IO = sys.stdout, + estream: IO = sys.stderr) -> bool: '''Install the python package.''' package = package.replace(' ', '') if version: package = '{}=={}'.format(package, version) - cmd = 'pip install "{}"'.format(package) + cmd = '{} -m pip install "{}"'.format(sys.executable, package) if upgrade: cmd += ' --upgrade' @@ -59,9 +61,9 @@ def install(package: str, version: str = '', upgrade: bool = False, ostream: IO return result == 0 -def install_from_file(file: str, ostream: IO = None, estream: IO = None) -> bool: +def install_from_file(file: str, ostream: IO = sys.stdout, estream: IO = sys.stderr) -> bool: '''Install the python package.''' - cmd = 'pip install -r {}'.format(file) + cmd = '{} -m pip install -r {}'.format(sys.executable, file) result, content = subprocess.getstatusoutput(cmd) if result: @@ -71,14 +73,13 @@ def install_from_file(file: str, ostream: IO = None, estream: IO = None) -> bool return result == 0 -def uninstall(package: str, ostream: IO = None, estream: IO = None) -> bool: +def uninstall(package: str, ostream: IO = sys.stdout, estream: IO = sys.stderr) -> bool: '''Uninstall the python package.''' - with typein('y'): - # type in 'y' to confirm the uninstall operation - cmd = 'pip uninstall {}'.format(package) - result, content = subprocess.getstatusoutput(cmd) - if result: - estream.write(content) - else: - ostream.write(content) + # type in 'y' to confirm the uninstall operation + cmd = '{} -m pip uninstall {} -y'.format(sys.executable, package) + result, content = subprocess.getstatusoutput(cmd) + if result: + estream.write(content) + else: + ostream.write(content) return result == 0 diff --git a/requirements.txt b/requirements.txt index 3990fb4bd0547cd4001784e0d74bbe98995421ac..f95cfe689940dbd35f750b4267f2804d8a6fe53b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,7 @@ matplotlib opencv-python packaging paddle2onnx >= 0.5.1 -paddlenlp >= 2.0.0rc5 +paddlenlp >= 2.0.0 Pillow pyyaml pyzmq