Download Jar. Libraryless. Click here for Pure Java version (10845L/78K).
1 | !7 |
2 | |
3 | replace Finder with F1<RGBImage, Rect>. |
4 | |
5 | sbool withNoFace = true; |
6 | |
7 | p-exp { |
8 | int w = 32; |
9 | int limit = 95; // search for smallest finder with at least 95% accuracy |
10 | |
11 | File dir = ai_faceFinderDir(); |
12 | if (withNoFace) dir = newFile(dir, "with-no-face"); |
13 | |
14 | L<RGBImageAndRect> marked = markedFaces_scaledToWidth(w, +withNoFace); |
15 | FaceFinderByPictures1 finder = new(w, nonNulls(rgbImageAndRects_getClip(marked))); |
16 | new Best<FaceFinderByPictures1> best; |
17 | //double tolerance = first(images).image.getWidth()/2.0; |
18 | |
19 | best.put(racerOptimize( |
20 | new RandomAndVary_Record<FaceFinderByPictures1>( |
21 | finder, |
22 | similarity := new RandomAndVary_Float), |
23 | func(FaceFinderByPictures1 finder) -> double { |
24 | video_scoreRect_step(new Best, marked, finder).score() |
25 | }, plateauLength := 100)); |
26 | finder = best!; |
27 | saveTextFileWithBackupVerbose(newFile(dir, "full-finder.struct"), struct(finder)); |
28 | |
29 | //showImage(mergeRGBImagesAndRects(callFaceFinder(finder, rgbImageAndRects_images(marked)))); |
30 | |
31 | new Best<Finder> best3; |
32 | |
33 | while (nempty(finder.pictures) && best.score() >= limit) { |
34 | // Make finder smaller by removing pictures |
35 | new Best<Finder> best2; |
36 | for (int i = 0; i < l(finder.pictures); i++) { |
37 | FaceFinderByPictures1 newFinder = shallowClone(finder); |
38 | newFinder.pictures = listWithoutIndex(newFinder.pictures, i); |
39 | //print("Took out image " + (i+1) + "/" + l(finder.pictures)); |
40 | video_scoreRect_step(best2, marked, newFinder, print := false); |
41 | copyBestIfAtLeast(best2, best3, limit); |
42 | } |
43 | finder = (FaceFinderByPictures1) best2!; |
44 | print("Got new finder with score " + best2.score() + ": " + finder); |
45 | } |
46 | |
47 | saveTextFileWithBackupVerbose(newFile(dir, "smallest-finder-over-" + limit + ".struct"), struct(best3!)); |
48 | } |
Began life as a copy of #1019536
download show line numbers debug dex old transpilations
Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vdyxwxlmubrt, vouqrxazstgt
No comments. add comment
Snippet ID: | #1023110 |
Snippet name: | Make Face Detector [including face/no face, OK, but result not very good yet] |
Eternal ID of this version: | #1023110/8 |
Text MD5: | fe621acabdaaaadd2f2a0e4bbd674c7a |
Transpilation MD5: | 6019e66e0bf58d5ef99fe8ce026c8840 |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-05-05 20:29:52 |
Source code size: | 1825 bytes / 48 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 292 / 895 |
Version history: | 7 change(s) |
Referenced in: | [show references] |