Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
lih627 committed Jul 30, 2020
1 parent faefb3f commit 5ec8b47
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
6 changes: 5 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
include *py *md LICENSE *txt
include demo.py
include README.md
include LICENSE
include MANIFEST.in
include visualization.py
include autocrop/*py
include autocrop/model/*py
include autocrop/model/rod_align/functions/*
Expand Down
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ crop_ret = autocropper.crop(img_,
topK=1,
crop_height=1,
crop_width=1,
filter_face=True)
filter_face=True, # True: Crop result will not contain half face
single_face_center=True) # True: face in the crop result's width center
```

You can visualize the cropping results
Expand All @@ -91,14 +92,26 @@ This project is mostly based on GAIC, and the modules are listed as follows:

It is slightly different from GAIC in practice, as shown below:

1. **We can specify any crop ratio**

GAIC supports RoIs with uncertain aspect ratios and several RoIs with fixed aspect ratios(`1:1, 4:3, 16:9`). In practical applications, image cropping needs to select the cropping area according to the fixed aspect ratio. I modified the code of the bboxes generation part. For RoIs evaluation, I used the GAIC pre-trained model.

2. **If there is only half a face in the bounding box, filter out the bounding box**

At the same time, in practical applications, when the distribution of people in the picture is not fixed, for example, when two people stand on the left and right sides of the picture, the RoI selected by GAIC may tear the human body. We adopt the face detection method to filter out some non-conformities. The required RoI will be evaluated after.

There is a comparison:

<img src="https://github.com/lih627/autocrop/blob/master/misc/face_filter.jpg?raw=true" alt="comparison with face detection - w150" style="zoom:50%;" />

3. **When the bounding box has only one face, the face should be in the middle of the box as much as possible**

We have added additional options when generating anchor boxes. If there is only one face in a RoI, use the RoI with the face in the middle of the RoI's width direction. see `autocrop/cropper.py` for details.

There is a comparison:

<img src="https://github.com/lih627/autocrop/blob/master/misc/face_filter2.jpg?raw=true" alt="comparison with face detection - w150" style="zoom:50%;" />

## Reference

1. [GAIC: Grid-Anchor-based-Image-Cropping-Pytorch](https://github.com/lld533/Grid-Anchor-based-Image-Cropping-Pytorch) MIT License
Expand Down
2 changes: 1 addition & 1 deletion visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,4 @@ def bbox_visualization(crop_height=1,


if __name__ == '__main__':
bbox_visualization(crop_height=322, crop_width=436)
bbox_visualization(crop_height=7, crop_width=5)

0 comments on commit 5ec8b47

Please sign in to comment.