From 8340d1d8d4266cba4c5e921739aabeceef9c7685 Mon Sep 17 00:00:00 2001 From: haoyuying <18844182690@163.com> Date: Mon, 22 Nov 2021 20:17:17 +0800 Subject: [PATCH] add readme_en for 100 models --- .../colorization/deoldify/README_en.md | 171 +++++++++++++++++ .../photo_restoration/README_en.md | 151 +++++++++++++++ .../super_resolution/falsr_c/README_en.md | 172 +++++++++++++++++ .../super_resolution/realsr/README_en.md | 174 ++++++++++++++++++ 4 files changed, 668 insertions(+) create mode 100644 modules/image/Image_editing/colorization/deoldify/README_en.md create mode 100644 modules/image/Image_editing/colorization/photo_restoration/README_en.md create mode 100644 modules/image/Image_editing/super_resolution/falsr_c/README_en.md create mode 100644 modules/image/Image_editing/super_resolution/realsr/README_en.md diff --git a/modules/image/Image_editing/colorization/deoldify/README_en.md b/modules/image/Image_editing/colorization/deoldify/README_en.md new file mode 100644 index 00000000..159a7f29 --- /dev/null +++ b/modules/image/Image_editing/colorization/deoldify/README_en.md @@ -0,0 +1,171 @@ +# deoldify + +| Module Name |deoldify| +| :--- | :---: | +|Category|image editing| +|Network |NoGAN| +|Dataset|ILSVRC 2012| +|Fine-tuning supported or not |No| +|Module Size |834MB| +|Data indicators|-| +|Latest update date |2021-04-13| + + +## I. Basic Information + +- ### Application Effect Display + + - Sample results: +

+ +

+ +- ### Module Introduction + + - deoldify is a color rendering model for images and videos, which can restore color for black and white photos and videos. + + - For more information, please refer to: [deoldify](https://github.com/jantic/DeOldify) + +## II. Installation + +- ### 1、Environmental Dependence + + - paddlepaddle >= 2.0.0 + + - paddlehub >= 2.0.0 + + - NOTE: This Module relies on ffmpeg, Please install ffmpeg before using this Module. + + ```shell + $ conda install x264=='1!152.20180717' ffmpeg=4.0.2 -c conda-forge + ``` + + +- ### 2、Installation + - ```shell + $ hub install deoldify + ``` + + - In case of any problems during installation, please refer to:[Windows_Quickstart](../../../../docs/docs_ch/get_start/windows_quickstart.md) + | [Linux_Quickstart](../../../../docs/docs_ch/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_ch/get_start/mac_quickstart.md) + + +## III. Module API Prediction + + - ### 1、Prediction Code Example + + ```python + import paddlehub as hub + + model = hub.Module(name='deoldify') + model.predict('/PATH/TO/IMAGE/OR/VIDEO') + ``` + + - ### 2、API + + - ```python + def predict(self, input): + ``` + + - Prediction API. + + - **Parameter** + + - input (str): image path. + + - **Return** + + - If input is image path, the output is: + - pred_img(np.ndarray): image data, ndarray.shape is in the format [H, W, C], BGR; + - out_path(str): save path of images. + + - If input is video path, the output is : + - frame_pattern_combined(str): save path of frames from output video; + - vid_out_path(str): save path of output video. + + - ```python + def run_image(self, img): + ``` + - Prediction API for image. + + - **Parameter** + + - img (str|np.ndarray): image data, str or ndarray. ndarray.shape is in the format [H, W, C], BGR. + + - **Return** + + - pred_img(np.ndarray): ndarray.shape is in the format [H, W, C], BGR. + + - ```python + def run_video(self, video): + ``` + - Prediction API for video. + + - **Parameter** + + - video(str): video path. + + - **Return** + + - frame_pattern_combined(str): save path of frames from output video; + - vid_out_path(str): save path of output video. + + +## IV. Server Deployment + +- PaddleHub Serving can deploy an online service of coloring old photos or videos. + + +- ### Step 1: Start PaddleHub Serving + + - Run the startup command: + + - ```shell + $ hub serving start -m deoldify + ``` + + - The servitization API is now deployed and the default port number is 8866. + + - **NOTE:** If GPU is used for prediction, set CUDA_VISIBLE_DEVICES environment variable before the service, otherwise it need not be set. + +- ### Step 2: Send a predictive request + + - With a configured server, use the following lines of code to send the prediction request and obtain the result. + + - ```python + import requests + import json + import base64 + + import cv2 + import numpy as np + + def cv2_to_base64(image): + data = cv2.imencode('.jpg', image)[1] + return base64.b64encode(data.tostring()).decode('utf8') + def base64_to_cv2(b64str): + data = base64.b64decode(b64str.encode('utf8')) + data = np.fromstring(data, np.uint8) + data = cv2.imdecode(data, cv2.IMREAD_COLOR) + return data + + # Send an HTTP request + org_im = cv2.imread('/PATH/TO/ORIGIN/IMAGE') + data = {'images':cv2_to_base64(org_im)} + headers = {"Content-type": "application/json"} + url = "http://127.0.0.1:8866/predict/deoldify" + r = requests.post(url=url, headers=headers, data=json.dumps(data)) + img = base64_to_cv2(r.json()["results"]) + cv2.imwrite('/PATH/TO/SAVE/IMAGE', img) + ``` + + +## V. Release Note + +- 1.0.0 + + First release + +- 1.0.1 + + Adapt to paddlehub2.0 diff --git a/modules/image/Image_editing/colorization/photo_restoration/README_en.md b/modules/image/Image_editing/colorization/photo_restoration/README_en.md new file mode 100644 index 00000000..0f807f6c --- /dev/null +++ b/modules/image/Image_editing/colorization/photo_restoration/README_en.md @@ -0,0 +1,151 @@ +# photo_restoration + +|Module Name|photo_restoration| +| :--- | :---: | +|Category|image editing| +|Network|deoldify and realsr| +|Fine-tuning supported or not|No| +|Module Size |64MB+834MB| +|Data indicators|-| +|Latest update date|2021-08-19| + + + +## I. Basic Information + +- ### Application Effect Display + + - Sample results: +

+ +

+ + + +- ### Module Introduction + + - Photo_restoration can restore old photos. It mainly consists of two parts: coloring and super-resolution. The coloring model is deoldify + , and super resolution model is realsr. Therefore, when using this model, please install deoldify and realsr in advance. + +## II. Installation + +- ### 1、Environmental Dependence + + - paddlepaddle >= 2.0.0 + + - paddlehub >= 2.0.0 + + - NOTE: This Module relies on ffmpeg, Please install ffmpeg before using this Module. + + ```shell + $ conda install x264=='1!152.20180717' ffmpeg=4.0.2 -c conda-forge + ``` + +- ### 2、Installation + + - ```shell + $ hub install photo_restoration + ``` + + - In case of any problems during installation, please refer to:[Windows_Quickstart](../../../../docs/docs_ch/get_start/windows_quickstart.md) + | [Linux_Quickstart](../../../../docs/docs_ch/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_ch/get_start/mac_quickstart.md) + + +## III. Module API Prediction + +- ### 1、Prediction Code Example + + + ```python + import cv2 + import paddlehub as hub + + model = hub.Module(name='photo_restoration', visualization=True) + im = cv2.imread('/PATH/TO/IMAGE') + res = model.run_image(im) + + ``` +- ### 2、API + + + ```python + def run_image(self, + input, + model_select= ['Colorization', 'SuperResolution'], + save_path = 'photo_restoration'): + ``` + + - Predicition API, produce repaired photos. + + - **Parameter** + + - input (numpy.ndarray|str): image data,numpy.ndarray or str. ndarray.shape is in the format [H, W, C], BGR; + + - model_select (list\[str\]): Mode selection,\['Colorization'\] only colorize the input image, \['SuperResolution'\] only increase the image resolution; + default is \['Colorization', 'SuperResolution'\]。 + + - save_path (str): save path, default is 'photo_restoration'. + + - **Return** + + - output (numpy.ndarray): restoration result,ndarray.shape is in the format [H, W, C], BGR. + + +## IV. Server Deployment + +- PaddleHub Serving can deploy an online service of photo restoration. + +- ### Step 1: Start PaddleHub Serving + + - Run the startup command: + + - ```shell + $ hub serving start -m photo_restoration + ``` + + - The servitization API is now deployed and the default port number is 8866. + + - **NOTE:** If GPU is used for prediction, set CUDA_VISIBLE_DEVICES environment variable before the service, otherwise it need not be set. + +- ### Step 2: Send a predictive request + + - With a configured server, use the following lines of code to send the prediction request and obtain the result + + ```python + import requests + import json + import base64 + + import cv2 + import numpy as np + + def cv2_to_base64(image): + data = cv2.imencode('.jpg', image)[1] + return base64.b64encode(data.tostring()).decode('utf8') + def base64_to_cv2(b64str): + data = base64.b64decode(b64str.encode('utf8')) + data = np.fromstring(data, np.uint8) + data = cv2.imdecode(data, cv2.IMREAD_COLOR) + return data + + # Send an HTTP request + org_im = cv2.imread('PATH/TO/IMAGE') + data = {'images':cv2_to_base64(org_im), 'model_select': ['Colorization', 'SuperResolution']} + headers = {"Content-type": "application/json"} + url = "http://127.0.0.1:8866/predict/photo_restoration" + r = requests.post(url=url, headers=headers, data=json.dumps(data)) + img = base64_to_cv2(r.json()["results"]) + cv2.imwrite('PATH/TO/SAVE/IMAGE', img) + ``` + + +## V. Release Note + +- 1.0.0 + + First release + +- 1.0.1 + + Adapt to paddlehub2.0 + diff --git a/modules/image/Image_editing/super_resolution/falsr_c/README_en.md b/modules/image/Image_editing/super_resolution/falsr_c/README_en.md new file mode 100644 index 00000000..6225933e --- /dev/null +++ b/modules/image/Image_editing/super_resolution/falsr_c/README_en.md @@ -0,0 +1,172 @@ +# falsr_c + +|Module Name|falsr_c| +| :--- | :---: | +|Category |Image editing| +|Network |falsr_c| +|Dataset|DIV2k| +|Fine-tuning supported or not|No| +|Module Size |4.4MB| +|Data indicators|PSNR37.66| +|Latest update date|2021-02-26| + + +## I. Basic Information + +- ### Application Effect Display + + - Sample results: +

+ +

+ + +- ### Module Introduction + + - falsr_c is a lightweight super-resolution model based on `Accurate and Lightweight Super-Resolution with Neural Architecture Search`. The model uses a multi-objective approach to deal with the over-segmentation problem, and uses an elastic search strategy based on a hybrid controller to improve the performance of the model. This model provides super resolution result with scale factor x2. + + - For more information, please refer to:[falsr_c](https://github.com/xiaomi-automl/FALSR) + +## II. Installation + +- ### 1、Environmental Dependence + + - paddlepaddle >= 2.0.0 + + - paddlehub >= 2.0.0 + + +- ### 2、Installation + + - ```shell + $ hub install falsr_c + ``` + + - In case of any problems during installation, please refer to:[Windows_Quickstart](../../../../docs/docs_ch/get_start/windows_quickstart.md) + | [Linux_Quickstart](../../../../docs/docs_ch/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_ch/get_start/mac_quickstart.md) + + +## III. Module API Prediction + +- ### 1、Command line Prediction + + - ``` + $ hub run falsr_c --input_path "/PATH/TO/IMAGE" + ``` + +- ### 2、Prediction Code Example + + ```python + import cv2 + import paddlehub as hub + + sr_model = hub.Module(name='falsr_c') + im = cv2.imread('/PATH/TO/IMAGE').astype('float32') + res = sr_model.reconstruct(images=[im], visualization=True) + print(res[0]['data']) + sr_model.save_inference_model() + ``` + +- ### 3、API + + - ```python + def reconstruct(self, + images=None, + paths=None, + use_gpu=False, + visualization=False, + output_dir="falsr_c_output") + ``` + + - Prediction API. + + - **Parameter** + + * images (list\[numpy.ndarray\]): image data,ndarray.shape is in the format \[H, W, C\],BGR; + * paths (list\[str\]): image path; + * use\_gpu (bool): use GPU or not; **set the CUDA_VISIBLE_DEVICES environment variable first if you are using GPU**; + * visualization (bool): Whether to save the recognition results as picture files; + * output\_dir (str): save path of images, "dcscn_output" by default. + + - **Return** + * res (list\[dict\]): The list of model results, where each element is dict and each field is: + * save\_path (str, optional): Save path of the result, save_path is '' if no image is saved. + * data (numpy.ndarray): result of super resolution. + + - ```python + def save_inference_model(self, + dirname='falsr_c_save_model', + model_filename=None, + params_filename=None, + combined=False) + ``` + + - Save the model to the specified path. + + - **Parameters** + + * dirname: Save path. + * model\_filename: model file name,defalt is \_\_model\_\_ + * params\_filename: parameter file name,defalt is \_\_params\_\_(Only takes effect when `combined` is True) + * combined: Whether to save the parameters to a unified file. + + + + +## IV. Server Deployment + +- PaddleHub Serving can deploy an online service of super resolution. + + +- ### Step 1: Start PaddleHub Serving + + - Run the startup command: + + - ```shell + $ hub serving start -m falsr_c + ``` + + - The servitization API is now deployed and the default port number is 8866. + + - **NOTE:** If GPU is used for prediction, set CUDA_VISIBLE_DEVICES environment variable before the service, otherwise it need not be set. + +- ### Step 2: Send a predictive request + + - With a configured server, use the following lines of code to send the prediction request and obtain the result + + ```python + import requests + import json + import base64 + + import cv2 + import numpy as np + + def cv2_to_base64(image): + data = cv2.imencode('.jpg', image)[1] + return base64.b64encode(data.tostring()).decode('utf8') + def base64_to_cv2(b64str): + data = base64.b64decode(b64str.encode('utf8')) + data = np.fromstring(data, np.uint8) + data = cv2.imdecode(data, cv2.IMREAD_COLOR) + return data + + org_im = cv2.imread('/PATH/TO/IMAGE') + data = {'images':[cv2_to_base64(org_im)]} + headers = {"Content-type": "application/json"} + url = "http://127.0.0.1:8866/predict/falsr_c" + r = requests.post(url=url, headers=headers, data=json.dumps(data)) + sr = base64_to_cv2(r.json()["results"][0]['data']) + cv2.imwrite('falsr_c_X2.png', sr) + print("save image as falsr_c_X2.png") + ``` + + +## V. Release Note + +- 1.0.0 + + First release + + + diff --git a/modules/image/Image_editing/super_resolution/realsr/README_en.md b/modules/image/Image_editing/super_resolution/realsr/README_en.md new file mode 100644 index 00000000..f0558835 --- /dev/null +++ b/modules/image/Image_editing/super_resolution/realsr/README_en.md @@ -0,0 +1,174 @@ +# realsr + +|Module Name |reasr| +| :--- | :---: | +|Category |image editing| +|Network|LP-KPN| +|Dataset |RealSR dataset| +|Fine-tuning supported or not|No| +|Module Size |64MB| +|Latest update date|2021-02-26| +|Data indicators |PSNR29.05| + + + +## I. Basic Information + +- ### Application Effect Display + + - Sample results: +

+ +

+ +- ### Module Introduction + + - realsr is a super resolution model for image and video based on "Toward Real-World Single Image Super-Resolution: A New Benchmark and A New Mode". This model provides super resolution result with scale factor x4. + + - For more information, please refer to: [realsr](https://github.com/csjcai/RealSR) + + +## II. Installation + +- ### 1、Environmental Dependence + + - paddlepaddle >= 2.0.0 + + - paddlehub >= 2.0.0 + + - **NOTE**: This Module relies on ffmpeg, Please install ffmpeg before using this Module. + ```shell + $ conda install x264=='1!152.20180717' ffmpeg=4.0.2 -c conda-forge + ``` + +- ### 2、Installation + + - ```shell + $ hub install realsr + ``` + + - In case of any problems during installation, please refer to:[Windows_Quickstart](../../../../docs/docs_ch/get_start/windows_quickstart.md) + | [Linux_Quickstart](../../../../docs/docs_ch/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_ch/get_start/mac_quickstart.md) + + + +## III. Module API Prediction + + - ### 1、Prediction Code Example + + ```python + import paddlehub as hub + + model = hub.Module(name='realsr') + model.predict('/PATH/TO/IMAGE/OR/VIDEO') + ``` + - ### 2、API + + - ```python + def predict(self, input): + ``` + + - Prediction API. + + - **Parameter** + + - input (str): image path. + + - **Return** + + - If input is image path, the output is: + - pred_img(np.ndarray): image data, ndarray.shape is in the format [H, W, C], BGR; + - out_path(str): save path of images. + + - If input is video path, the output is : + - frame_pattern_combined(str): save path of frames from output video; + - vid_out_path(str): save path of output video. + + - ```python + def run_image(self, img): + ``` + - Prediction API for images. + + - **Parameter** + + - img (str|np.ndarray): image data, str or ndarray. ndarray.shape is in the format [H, W, C], BGR. + + - **Return** + + - pred_img(np.ndarray): ndarray.shape is in the format [H, W, C], BGR. + + - ```python + def run_video(self, video): + ``` + - Prediction API for video. + + - **Parameter** + + - video(str): video path. + + - **Return** + + - frame_pattern_combined(str): save path of frames from output video; + - vid_out_path(str): save path of output video. + + +## IV. Server Deployment + +- PaddleHub Serving can deploy an online service of image super resolution. + +- ### Step 1: Start PaddleHub Serving + + - Run the startup command: + + - ```shell + $ hub serving start -m realsr + ``` + + - The servitization API is now deployed and the default port number is 8866. + + - **NOTE:** If GPU is used for prediction, set CUDA_VISIBLE_DEVICES environment variable before the service, otherwise it need not be set. + +- ### Step 2: Send a predictive request + + - With a configured server, use the following lines of code to send the prediction request and obtain the result + + - ```python + import requests + import json + import base64 + + import cv2 + import numpy as np + + def cv2_to_base64(image): + data = cv2.imencode('.jpg', image)[1] + return base64.b64encode(data.tostring()).decode('utf8') + def base64_to_cv2(b64str): + data = base64.b64decode(b64str.encode('utf8')) + data = np.fromstring(data, np.uint8) + data = cv2.imdecode(data, cv2.IMREAD_COLOR) + return data + + # 发送HTTP请求 + org_im = cv2.imread('/PATH/TO/IMAGE') + data = {'images':cv2_to_base64(org_im)} + headers = {"Content-type": "application/json"} + url = "http://127.0.0.1:8866/predict/realsr" + r = requests.post(url=url, headers=headers, data=json.dumps(data)) + img = base64_to_cv2(r.json()["results"]) + cv2.imwrite('/PATH/TO/SAVE/IMAGE', img) + + ``` + + +## V. Release Note + + +- 1.0.0 + + First release + +* 1.0.1 + + Support paddlehub2.0 + -- GitLab