logo
Browse Source

shape bug fix.

Signed-off-by: wxywb <xy.wang@zilliz.com>
main
wxywb 3 years ago
parent
commit
9f09a83b0a
  1. 71
      README.md
  2. 8
      mobilefacenet.py

71
README.md

@ -5,23 +5,46 @@
## Desription
A class of extremely efficient CNN models to extract 68 landmarks from a facial image[1].
A class of extremely efficient CNN models to extract 68 landmarks from a facial image[MobileFaceNets](https://arxiv.org/pdf/1804.07573.pdf).
## Code Example
extracted facial landmark from './img1.jpg'.
*Write the pipeline in simplified style*:
```python
from towhee import dc
dc.glob('./img1.jpg') \
.face_landmark_detection.mobilefacenet() \
.to_list()
```
*Write a same pipeline with explicit inputs/outputs name specifications:*
```python
from towhee import ops
from towhee import dc
model = ops.face_landmark_detection.mobilefacenet()
landmark = model(img)
dc.glob['path']('./img1.jpg') \
.image_decode.cv2['path', 'img']() \
.face_landmark_detection.mobilefacenet() \
.to_list()
```
## Factory Constructor
Create the operator via the following factory method
***ops.face_landmark_detection.mobilefacenet()***
***ops.face_landmark_detection.mobilefacenet(pretrained = True)***
**Parameters:**
***pretrained***
​ whether load the pretrained weights..
​ supported types: `bool`, default is True, using pretrained weights
## Interface
@ -29,13 +52,6 @@ An image embedding operator takes an image as input. it extracts the embedding b
**Args:**
***framework***
​ the framework of the model
​ supported types: `str`, default is 'pytorch'
***pretrained***
​ whether load the pretrained weights..
@ -45,7 +61,7 @@ An image embedding operator takes an image as input. it extracts the embedding b
**Parameters:**
***image***: *towhee._types.Image*
***image***: *np.ndarray*
​ The input image.
@ -54,32 +70,3 @@ An image embedding operator takes an image as input. it extracts the embedding b
​ The extracted facial landmark.
## Code Example
extracted facial landmark from './img1.jpg'.
*Write the pipeline in simplified style*:
```python
import towhee.DataCollection as dc
dc.glob('./img1.jpg')
.face_landmark_detection.mobilefacenet()
.to_list()
```
*Write a same pipeline with explicit inputs/outputs name specifications:*
```python
import towhee.DataCollection as dc
dc.glob['path']('./img1.jpg')
.image_decode.cv2['path', 'img']()
.face_landmark_detection.mobilefacenet()
.to_list()
```
## Reference
[1].https://arxiv.org/pdf/1804.07573.pdf

8
mobilefacenet.py

@ -22,9 +22,11 @@ import torch
from torchvision import transforms
from towhee import register
from towhee.operator import NNOperator
from towhee.types.image_utils import to_pil
from towhee._types import Image
from towhee.types import arg, to_image_color
#import mobilefacenet
@ -34,8 +36,8 @@ class Mobilefacenet(NNOperator):
Mobilefacenet
"""
def __init__(self, framework: str = 'pytorch', pretrained = True):
super().__init__(framework=framework)
def __init__(self, pretrained = True):
super().__init__()
sys.path.append(str(Path(__file__).parent))
from mobilefacenet_impl import MobileFaceNet
self.model = MobileFaceNet([112, 112], 136)
@ -47,7 +49,7 @@ class Mobilefacenet(NNOperator):
normalize = transforms.Normalize(
mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
self.tfms = transforms.Compose([transforms.Scale(112),
self.tfms = transforms.Compose([transforms.Scale([112,112]),
transforms.ToTensor(),
normalize])

Loading…
Cancel
Save