Uses 911K of libraries. Click here for Pure Java version (11317L/62K).
!7 cmodule LearnDogsVsCats > DynSingleFunctionWithPrintLog { /*switchable*/ transient File dir = userDir("dev/dogs-vs-cats/train"); LPair<RGBImage, Rect> scaledImages; transient int eyeWidth = /*32*/10; transient double eyeSurround = 0.5; start { if (!dm_osBooting()) thread { doIt(); } } void doIt { // load scaled down test images L<File> allImageFiles = listImageFiles(dir); Map<File, LPair<Rect, S>> markingsMap = new Map; for (File f : allImageFiles) mapPutIfNemptyValue(markingsMap, f, loadImageFileMarkings(f)); pnlStruct(markingsMap); if (empty(markingsMap)) ret with print("No marked images found in " + dir); new Map<File, BWIntegralImage> iImages; for (File f : keys(markingsMap)) iImages.put(f, BWIntegralImage(f)); print("Have " + n2(iImages, "integral image") + ", total size: " + str_toM(deepObjectSize(iImages))); new L<BWImage> allEyeImages; new Map<BWImage, File> eyeImageSources; for (File f : keys(markingsMap)) if (fileNameContains(f, "cat")) for (Pair<Rect, S> mark : markingsMap.get(f)) if (eqic(mark.b, "eye")) { BWImage img = bwResizeSmooth(iBWImageToBWImage(safeClipIBWImage(virtualScaledIntegralImageBW(iImages.get(f)), growRectProportionally(eyeSurround, mark.a) )), eyeWidth); allEyeImages.add(img); eyeImageSources.put(img, f); } showImage(mergeBWImagesVertically(allEyeImages)); //showImage(scaleDownUsingIntegralImageBW(random(values(iImages)), 256)); //showImage(iBWImageToBWImage(virtualScaledIntegralImageBW(random(values(iImages)), 256))); //File f = random(allImageFiles); File f = firstFileWithName(allImageFiles, "cat.2516.jpg"); print(f); BWIntegralImage ii = new(f); int w = /*256*/100; IBWImage scaled = virtualScaledIntegralImageBW(ii, w); float similarity = 0; FoundImg found = null; ImageSurface is = showImage(iBWImageToBWImage(scaled)); Rect r = null; for (BWImage pat : allEyeImages) { FoundImg lastFound = found; found = or(bwImageSearch_best_virtualBig(scaled, pat, found == null ? 0f : found.sim), found); if (neq(found, lastFound)) print(found + " / " + eyeImageSources.get(pat)); if (neq(foundImgRect(found), r)) { r = foundImgRect(found); overlaySelectionsOnImageSurface(is, ll(r)); } } print(found); } }
Began life as a copy of #1022929
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1022975 |
Snippet name: | Learn Dogs vs Cats Prelude v1 |
Eternal ID of this version: | #1022975/36 |
Text MD5: | d639672ed5f5a66eed814bd31166a766 |
Transpilation MD5: | 71f5af299cadc5df4b93b518be197ee2 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-04-17 16:43:54 |
Source code size: | 2555 bytes / 69 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 352 / 916 |
Version history: | 35 change(s) |
Referenced in: | [show references] |