|
@ -1,6 +1,6 @@ |
|
|
# Image Decode Implementation with NVJpeg and CV2 |
|
|
|
|
|
|
|
|
# Image Decode Implementation with CV2 and nvjpeg |
|
|
|
|
|
|
|
|
*author: Junjie Jiang* |
|
|
|
|
|
|
|
|
*author: junjie.jiang* |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -10,10 +10,10 @@ |
|
|
|
|
|
|
|
|
## Description |
|
|
## Description |
|
|
|
|
|
|
|
|
An image decode operator implementation with OpenCV and NvJpeg. |
|
|
|
|
|
The decoder will use GPU to decode jpeg images. |
|
|
|
|
|
|
|
|
An image decode operator implementation with OpenCV and nvjpeg. |
|
|
|
|
|
In CPU env, use OpenCV, in GPU env, use nvjpeg to decode jpeg files. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Only supports linux. |
|
|
|
|
|
|
|
|
|
|
|
<br /> |
|
|
<br /> |
|
|
|
|
|
|
|
@ -21,32 +21,24 @@ Only supports linux. |
|
|
|
|
|
|
|
|
## Code Example |
|
|
## Code Example |
|
|
|
|
|
|
|
|
Load a image from path './dog.jpg'. |
|
|
|
|
|
|
|
|
Load a image from path './src_dog.jpg'. |
|
|
|
|
|
|
|
|
*Write the pipeline in simplified style:* |
|
|
*Write the pipeline in simplified style:* |
|
|
|
|
|
|
|
|
```python |
|
|
```python |
|
|
import towhee |
|
|
|
|
|
|
|
|
|
|
|
towhee.glob('./dog.jpg') \ |
|
|
|
|
|
.image_decode.nvjpeg() \ |
|
|
|
|
|
.show() |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
from towhee.dc2 import pipe, ops, DataCollection |
|
|
|
|
|
|
|
|
*Write a same pipeline with explicit inputs/outputs name specifications:* |
|
|
|
|
|
|
|
|
|
|
|
```python |
|
|
|
|
|
import towhee |
|
|
|
|
|
|
|
|
p = ( |
|
|
|
|
|
pipe.input('url') |
|
|
|
|
|
.map('url', 'image', ops.image_decode.nvjpeg()) |
|
|
|
|
|
.output('image') |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
towhee.glob['path']('./dog.jpg') \ |
|
|
|
|
|
.image_decode.nvjpeg['path', 'img']() \ |
|
|
|
|
|
.select['img']() \ |
|
|
|
|
|
.show() |
|
|
|
|
|
|
|
|
DataCollection(p('./src_dog.jpg')).show() |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<img src="./show_result.jpg" height="150px"/> |
|
|
|
|
|
|
|
|
<img src="./dog.jpg" height="150px"/> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -58,7 +50,7 @@ towhee.glob['path']('./dog.jpg') \ |
|
|
|
|
|
|
|
|
Create the operator via the following factory method: |
|
|
Create the operator via the following factory method: |
|
|
|
|
|
|
|
|
***image_decode.nvjpeg()*** |
|
|
|
|
|
|
|
|
***ops.image_decode.nvjpeg()*** |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -76,7 +68,7 @@ An image decode operator takes an image path as input. It decodes the image back |
|
|
|
|
|
|
|
|
**img**: *str* |
|
|
**img**: *str* |
|
|
|
|
|
|
|
|
Image file path. |
|
|
|
|
|
|
|
|
Local file path or http url. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|