Skip to content

Commit

Permalink
add en version readme for model 400
Browse files Browse the repository at this point in the history
  • Loading branch information
haoyuying committed Nov 25, 2021
1 parent 336893a commit 4c07f02
Show file tree
Hide file tree
Showing 31 changed files with 829 additions and 809 deletions.
118 changes: 59 additions & 59 deletions modules/image/Image_editing/colorization/deoldify/README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

| Module Name |deoldify|
| :--- | :---: |
|Category|image editing|
|Category|Image editing|
|Network |NoGAN|
|Dataset|ILSVRC 2012|
|Fine-tuning supported or not |No|
Expand All @@ -22,7 +22,7 @@

- ### Module Introduction

- deoldify is a color rendering model for images and videos, which can restore color for black and white photos and videos.
- 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)

Expand All @@ -36,30 +36,30 @@

- 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
```
```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)
- In case of any problems during installation, please refer to:[Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md)
| [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)


## III. Module API Prediction

- ### 1、Prediction Code Example

```python
import paddlehub as hub
- ```python
import paddlehub as hub
model = hub.Module(name='deoldify')
model.predict('/PATH/TO/IMAGE/OR/VIDEO')
```
model = hub.Module(name='deoldify')
model.predict('/PATH/TO/IMAGE/OR/VIDEO')
```

- ### 2、API

Expand All @@ -69,32 +69,32 @@

- Prediction API.

- **Parameter**
- **Parameter**

- input (str): image path.
- input (str): Image path.

- **Return**
- **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 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.
- 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**
- **Parameter**

- img (str|np.ndarray): image data, str or ndarray. ndarray.shape is in the format [H, W, C], BGR.
- img (str|np.ndarray): Image data, str or ndarray. ndarray.shape is in the format [H, W, C], BGR.

- **Return**
- **Return**

- pred_img(np.ndarray): ndarray.shape is in the format [H, W, C], BGR.
- pred_img(np.ndarray): Ndarray.shape is in the format [H, W, C], BGR.

- ```python
def run_video(self, video):
Expand All @@ -103,12 +103,12 @@

- **Parameter**

- video(str): video path.
- 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.
- frame_pattern_combined(str): Save path of frames from output video.
- vid_out_path(str): Save path of output video.


## IV. Server Deployment
Expand All @@ -120,44 +120,44 @@

- Run the startup command:

- ```shell
$ hub serving start -m deoldify
```
- ```shell
$ hub serving start -m deoldify
```

- The servitization API is now deployed and the default port number is 8866.
- 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.
- **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)
```
- ```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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

|Module Name|photo_restoration|
| :--- | :---: |
|Category|image editing|
|Category|Image editing|
|Network|deoldify and realsr|
|Fine-tuning supported or not|No|
|Module Size |64MB+834MB|
Expand Down Expand Up @@ -47,16 +47,16 @@
$ 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)
- In case of any problems during installation, please refer to:[Windows_Quickstart](../../../../docs/docs_en/get_start/windows_quickstart.md)
| [Linux_Quickstart](../../../../docs/docs_en/get_start/linux_quickstart.md) | [Mac_Quickstart](../../../../docs/docs_en/get_start/mac_quickstart.md)


## III. Module API Prediction

- ### 1、Prediction Code Example


```python
- ```python
import cv2
import paddlehub as hub
Expand All @@ -68,7 +68,7 @@
- ### 2、API


```python
- ```python
def run_image(self,
input,
model_select= ['Colorization', 'SuperResolution'],
Expand All @@ -79,16 +79,16 @@

- **Parameter**

- input (numpy.ndarray|str): image data,numpy.ndarray or str. ndarray.shape is in the format [H, W, C], BGR;
- 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'.
- 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.
- output (numpy.ndarray): Restoration result,ndarray.shape is in the format [H, W, C], BGR.


## IV. Server Deployment
Expand All @@ -103,15 +103,15 @@
$ hub serving start -m photo_restoration
```

- The servitization API is now deployed and the default port number is 8866.
- 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.
- **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
- ```python
import requests
import json
import base64
Expand Down
Loading

0 comments on commit 4c07f02

Please sign in to comment.