diff --git a/README.md b/README.md index 8a698d8..be7853b 100644 --- a/README.md +++ b/README.md @@ -22,37 +22,40 @@ This operator uses [PyTorch.yolov5](https://pytorch.org/hub/ultralytics_yolov5/) ### Code Example +Load an image from path './test.png' and use yolov5 model to detect objects in the image. +*Write a same pipeline with explicit inputs/outputs name specifications:* -- Write the pipeline in the simplified way: - +- **option 1: towhee>=0.9.0** ```Python -import towhee - -towhee.glob('./test.png') \ - .image_decode() \ - .object_detection.yolov5() \ - .show() -``` +from towhee.dc2 import pipe, ops, DataCollection -results1 +p = ( + pipe.input('path') + .map('path', 'img', ops.image_decode()) + .map('img', ('box', 'class', 'score'), ops.object_detection.yolov5()) + .map(('img', 'box'), 'object', ops.image_crop(clamp=True)) + .output('img', 'object', 'class') +) -- Write the same pipeline with explicitly specified inputs and outputs: +DataCollection(p('./test.png')).show() +``` -```Python +- **option 2:** +```python import towhee -towhee.glob['path']('./test.png') \ - .image_decode['path','img']() \ - .object_detection.yolov5['img', ('box', 'class', 'score')]() \ - .image_crop[('img', 'box'), 'object'](clamp = True) \ - .select['img','object']() \ - .show() +( + towhee.glob['path']('./test.png') + .image_decode['path','img']() + .object_detection.yolov5['img', ('box', 'class', 'score')]() + .image_crop[('img', 'box'), 'object'](clamp = True) + .select['img','object', 'class']() + .show() +) ``` -results1 - - +result
diff --git a/result.png b/result.png new file mode 100644 index 0000000..26633f2 Binary files /dev/null and b/result.png differ diff --git a/results1.png b/results1.png deleted file mode 100644 index d21fd20..0000000 Binary files a/results1.png and /dev/null differ diff --git a/results2.png b/results2.png deleted file mode 100644 index cddb8ec..0000000 Binary files a/results2.png and /dev/null differ