The last three Neural Filters, and a network for one of them - #71
Merged
Conversation
Smart Portrait, Makeup Transfer and Sketch to Portrait were the three left out, because Adobe's are generative and a generative model does not fit in a filter. None of them needed to be, and the README now says exactly where each one stops. Smart Portrait warps and relights rather than redrawing: a smile is the corners of the mouth lifted, surprise the brows raised, age skin texture added or taken away, and the light comes off the surface MiDaS measures -- with a guard at the silhouette, where a depth cliff would otherwise halo. Makeup Transfer moves colour and not texture from the face on the layer below, matching the statistics of the lips, the eyes and the skin separately. Both find the face with UltraFace and then assume the features are where a face looking at the camera keeps them. Sketch to Portrait runs a new 448k-parameter network, trained here to invert *this build's own Photo to Sketch* -- a far smaller question than inventing a photograph, and one that fits. Sixteen thousand face crops, cut by tools/train/faces.py out of the CC BY 2.0 Open Images photographs tools/train/photos.py fetches, framed exactly the way the filter frames them at run time. It comes back at 29% of the sketch's error against the original, and the test that says so runs the same sketch operator the training script does, so the filter and the model cannot drift apart unnoticed. Its Colour slider scales the chroma the network chose: fitted to absolute error, it hedges, because a sketch genuinely does not say what colour anything was. Also adds run_framed for models that want the whole picture at once, rather than tiles at full resolution: filling in a drawing of a face means knowing it is a face. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Smart Portrait, Makeup Transfer and Sketch to Portrait were the three Neural Filters left out, because Adobe's are generative and a generative model does not fit in a filter. None of them needed to be. All fifteen are now in the menu, twelve of them run a network, and none of those networks are Adobe's.
Smart Portrait
Warps and relights rather than redrawing. A smile is the corners of the mouth lifted, surprise is the brows raised, age is skin texture added or taken away, and the light comes off the surface MiDaS measures — with a guard at the silhouette, where a depth cliff would otherwise leave a halo. It opens with every expression neutral and the light where it already is, because the picture it was given is the picture the photographer took.
Makeup Transfer
Moves colour, not texture, from the face on the layer below: it matches the statistics of the lips, the eyes and the skin separately, so you get someone else's lipstick and eyeshadow and not their eyeliner. With no face in either picture it leaves the layer alone, which is what the new
makeup_transfer_leaves_a_picture_with_no_face_in_it_alonepins.Both find the face with UltraFace and then assume the features are where a face looking at the camera keeps them — so both work on a portrait and fall apart on a profile, which the README says out loud.
Sketch to Portrait
Runs a new 448k-parameter network, trained here rather than downloaded. It was fitted to invert this build's own Photo to Sketch, which is a far smaller question than inventing a photograph and is why it fits in the binary at all. Training data is sixteen thousand face crops, cut by the new
tools/train/faces.pyout of the CC BY 2.0 Open Images photographstools/train/photos.pyfetches, framed exactly the way the filter frames them at run time.It comes back at 29% of the sketch's error against the original photograph, and the test that says so runs the same sketch operator the training script does — so the filter and the model cannot drift apart unnoticed. The Colour slider scales the chroma the network chose: fitted to absolute error it hedges, because a sketch genuinely does not say what colour anything was.
Give it a pencil drawing from a sketchbook and it does something in the same spirit and rather worse. The README says that too.
Also
schist_neural::run_framed, for models that want the whole picture at once rather than tiles at full resolution — filling in a drawing of a face means knowing it is a face.tools/train/photos.pygrew--labeland--split, so the corpus fetcher can pull face-labelled photographs specifically.Checks
cargo fmt,cargo clippy --workspace --all-targetsandcargo test --workspaceare all clean. The three filters were verified on real photographs and in the running application headlessly; the Filter ▸ Neural Filters menu lists all fifteen.🤖 Generated with Claude Code