adding ai features like subject select / mergability

hello, already asked on irc but not using IRC usually so will miss answer / web based irc was annoying.

currently thinking about adding some ai features, mostly mask selects like subject / sky. but theoretically also generative heal etc…

would this be anything anyone is interested in? chance that this might go upstream? + the question is: how. i could traina bad model which works with the current denox, extend denox to allow for stuff such as attention etc. OR link full onnx runtime.

what are your thoughts

regards

1 Like

heya,

sorry my irc setup is currently down.

using denox: yes, using microsoft onnx: not so much (uninteresting, bloatware, slower too).

and yes, for some stuff denox might need some extension. what kind of attention were you thinking about? there was this paper that seemed to indicate a simple 1x1 convolution followed by a component-wise multiplication to the original tensor would work well for some applications (that would be simple to put into denox).

oh, also training is a good keyword: i know i didn’t (yet) publish my denoising dataset… but really it’s my own images and only like 100 or 200 of them. i’d very much like us to use ethically sourced data and not use gigawatts in the process. i’m not interested in running models trained by random big tech.

2 Likes

yes okay i understand, also denox is cool so extending it seems worthwhile. i will look into it and update here :slight_smile:

1 Like

okay i already have a proof of work with U2-Net, which of course isn’t ethically sourced, the pretrained models come from DUTS-TR, which comes from ImageNet DET

found 3 bugs in the process in denox which are universal and not u2net specific + u2net specific stuff like adding bilinear upsampling and bound the search in denox because it blew up for the nested unets

now the question arises what you would consider ethically sourced. can’t really find something pretrained honestly, always imagenet data in the loop or something

so ig we have to train ourselves, for just subject select pretty easy, for click to select object bit harder but also doable

datasets:

COCO / LVIS, filtered per image? have license there per image?

Open Images V7. Annotations CC BY 4.0, images CC BY 2.0, declared by the Flickr uploaders (Google doesn’t verify)

CC-BY is permission from the photographer, not consent from the people → so how far do you want to go, blur faces?

theoretically synthetic but mask will be bad on real images then

let me know your thoug

*let me know your thoughts

nice, that was quick :slight_smile:

oh, could you create a github issue or pr?

i have no experience training foreground extraction networks. is that something that can be done on a normal workstation?

it would be my intuition that these networks aren’t much larger than a denoising network (no input prompt, just pixels). as such i believe we wouldn’t need to blur faces because this kind of detail would be impossible to reconstruct from the trained weights.

gotta structure this a bit first hahah and also not sure if i want to include the u2net specific stuff for denox. a custom model i could just design so it works with current denox. + bug fixes that make sense anyway imo

but yeah i will open a batch of PRs for this

it would be my intuition that these networks aren’t much larger than a denoising network (no input prompt, just pixels). as such i believe we wouldn’t need to blur faces because this kind of detail would be impossible to reconstruct from the trained weights

yes this is true, no way to reconstruct. 100k images at 512px → 80 GB of data → into 2MB of fp16 weights seems obvious lol

but i meant it more about the ethical thought that it’s still people that did not consent. i personally have zero problems with this, just didn’t know how “pure” you think about this. IMO no issue.

So you would think open images v7 is fine. and yeah for something reasonable i can probably train on my laptop with rtx 3060

if you think raw open images v7 is good enough from an ethical pov i would try to train something here

citing their website, all the way at the bottom:

Licenses

The annotations are licensed by Google LLC under CC BY 4.0 license. The images are listed as having a CC BY 2.0 license.
Note: while we tried to identify images that are licensed under a Creative Commons Attribution license, we make no representations or warranties regarding the license status of each image and you should verify the license for each image yourself.

i suppose it’s easy to conclude they don’t really care, but extremely hard to keep up higher moral standards if you actually want to move forward. at least we’d know where it comes from. in the paper that comes with an earlier version of the dataset they explain where the annotations come from: computer assisted, a smaller portion then presented to two pools of people. one presumably highly paid google folks, and the other crowdsourced clickworkers. likely that this last part is questionable, but i’m not expecting shocking content on display here.

i think i’m fine with using the dataset.

i have for now opened the fix PRs in denox and asked what the best way to contribute is (Best way to contribute / adding features to vkdt / mergability · Issue #150 · kistenklaus/denox · GitHub)

already have all the new features in the pipeline: support bilinear resize (upsampling), support stride in the direct conv, support elementwise add, support average pooling

but yeah dunno how he likes to get 10+ PRs randomly

do you know kistenklaus? maybe using a fork makes sense

some thoughts:

tldr: the schedule search blows up on branchy graphs (resnet blocks, pyramid pooling, u2net), i added a search budget as a workaround. the ops my nets need (add, avg-pool, stride) don’t really fit “fast unets through fusion”, so question is if denox should be more general “image nets in renderers” or stay unet focused. for now i only opened the bug fixes + bilinear, which make sense either way. models for click/box/brush select + automatic masks are ready and usable if the ops go in, plain unets could be an alternative (not tested). theoretically the new ops could be fused like pool/upsample/concat too, via some prologue / epilogue system for the conv (+ a search that doesn’t blow up on branchy graphs)

so the search quickly blows up in all_minimum_cost_subgraphs (the structural pruning in prune_topological). my nets have resnet style residual blocks + a pyramid pooling block, so lots of split → join, and every branch multiplies the states. oidn and the test models stay at most at ~6.7M states, mine didn’t finish within 15 GB, u2netp needed >26 GB.

i just added a search budget for this which of course works, probably not optimal for graphs over the budget (only the pruning goes greedy, the final selection still picks the best of what’s left), but I didn’t measure how much

and now i trained my own network but it uses resnet style encoders which also blow up (same reason)

i added all this while getting u2net to work without thinking too much, so i quickly wanna stop here and think about if this is even right direction for denox, i added some ops now, (elementwise-add, avg-pool, strided-conv) which my architecture needs (resnet encoder + pyramid pooling, probably closer to SOTA theoretically, not possible with the data anyway) but this does not really fit the idea of the super performant unet execution. if you think about denox as just getting models into vulkan and into renderers, then adding the ops and everything i did makes sense. but if it’s about unets can be done fast with smart fuse then ig not. not sure how karl sees it.

theoretically to just get this working, i can probably use plain unets with the existing features and call it a day. but didn’t test how much worse it is. not really educated guess → not too much worse. resnet style encoders that exist probably win mostly because of image net pretraining (even though residuals prob help)

i opened PRs now for everything that makes sense either way IMO (the bug fixes).

also now opened the bilinear resize PR, that is also applicable to bare unets / standard alternative. which he probably would want to merge, but the rest would need this thought first

of course, we can also fuse the new stuff the same way. currently it’s hard written so the shaders would grow quite a lot for the fused ops, but we could do a epilogue + prologue system. this is what CUTLASS (epilogue visitor trees) and TVM do for CUDA afaik

but yeah i have very cool segmentation models ready if we would add these 3 ops (+ bilinear and the search budget), click, box and brush select (left click adds, right click removes, more clicks refine) and automatic masks for people, sky, vegetation, water, mountain, ground, building, clothing and subject. all trained from scratch on open images v7 (+ the cc licensed part of coco-stuff for the automatic masks), circa 5-7 ms for a click (up to ~13 ms with many clicks) and ~7 ms for the automatic masks on a laptop 3060 which is only at a 60w charger and i think quite a lot slower because of it. for the automatic masks the net is ~1.4 ms, ~7 ms is with guided filter btw, this is on input 384×384 and output 192×192 (click select is 512 in, 256 out), so we could increase this of course, have compute budget i think. the results are usable, but strong edits have halo of course

very cool! how long does that take for a say 20MP full res image? these timings are running denox, or the python version after training, or a vkdt-denox vulkan version already?

yes will have to find out where denox would best be going. i could see this stuff to be in scope.

well i downscale the image for the input into the net. so doesnt matter really what image size, but i tested on 24mp. i will maybe take a look to also train bigger networks, but for segmentation full size most likely never makes sense, maybe a bit more pixels wouldnt hurt though, but this was also because of training constraints. but i found some left over credits on lightning.ai now so those might wait for some training

but the timings are already in vkdt with vkdt denox already, at least the click to select timings.

i will continue this in the issue on github with Karl as most of the stuff is denox specific honestly. But he’s quite motivated and has time the next days so i think we will get some good stuff merged

I will come back here regarding vkdt implementation e.g. for widgets for stuff like box a subject to select etc… or just PR

1 Like

awesome, sounds great!

…any intermediate progress that i could try? i’m thinking it would be good to do a release at some point and trying to find out what to include here :slight_smile:

ui wise: probably wire a draw module for the scribbles on screen. doing that with presets that add all required modules + wires at the same time should be reasonably quick wrt required user interaction. the pick module has some support for drawing quads, too (could re-use the widget i suppose).

btw you tried this on your 30xx card? GitHub - Zagitta/gpu-unlock: Unlock FP/BF16 instruction issue rate on Nvidia 3000's cards to their professional equivalents · GitHub have to say this sounds tempting but dangerous to me. also i’m not sure we’ll get the 2x speedups with our networks, or whether we’ll be memory bound anyways. might need to re-bench with denox.

hey, i have everything working basically, for weeks already, i just didn’t have time to open proper PRs

if i can just dump my state somewhere i would glady do that hahah

but yes i will try to get this pushed very soon (this week). i think all prerequisites are already in denox

just wondering also where to put models and generally i might want to train better models etc, how that would work later in vkdt, i assume you will not just swap those out as it would change graph output?

nice! looking forward.

denox has a reweight command, to keep network topology and just dump better weights. we’d ship these through a side channel. so far i uploaded them with the github release, and newer weights are shipped in a separate repository, as a release tarball:

yes i have seen that, just wondering regarding changed weights as those would of course change e.g. the selection, which would be different compared to lightroom where at select time it’s computed and then the mask is saved, rather than the click and recomputed on next open. but it seems then you have no issues changing the weights?

and i pushed my code

branch: GitHub - lennardwalter/vkdt at ai-masks · GitHub
weights: https://github.com/lennardwalter/vkdt/releases/download/weights-v0.1/weights.tar.xz (extract into ~/.config/vkdt/data/)

  • select: click to select. left click add, right click remove, drag a box, or “draw start” and roughly paint over it. ~6-9 ms
  • segment: auto masks for people, sky, vegetation, water, mountain, ground, building, subject, roads/floors, clothing (+ invert). ~3 ms
  • click widget: new widget type for the points + box

masks go into blend via guided, see presets select-exposure and segment-sky. trained from scratch on open images v7 + cc-licensed coco-stuff, no pretrained weights. built with plain upstream denox + vkdt-denox (after my changes there) nvidia only for now.

full disclosure btw some stuff is done with llm help, e.g. restructured my messy stuff into clean commits, co-wrote readme and also some code. you seem to have a no slop policy, so the judgement is on you. i am using this for personal use and are happy to share the code of course but that as a disclaimer

1 Like

awesome, will have a look! fwiw vkdt supports an “export copy with all required dependency files” mode for archival purposes. the same problem goes with updated colour luts etc. so the resource tracking system can now be used to collect all the actually opened files and export them along with the file, as an archived project. i think that’s enough to maintain pixel-accurate history, in case that is a user requirement.

i don’t like llms for their side effects on open source community and planet. i’m not necessarily against using them for coding. i know good coders get more productive this way. but i want to know where code comes from, so i can have a closer look… not all llm are equally good at producing code.

didn’t run yet, but code is looking pretty good, i think i can work with this! i’ll probably change a few minor details and merge.

there’s a special bypass call for the zero.comp use case, which simply binds the input to the output, not running any compute shader at all. (like what denoise does here)

if you could publish the .dnx files along with the weights i’ll include these in the nn repo, so people with intel/amd cards can pick it up and bench/autotune/compile for their archs. oh, also we’ll need a generic variant to run on non-tensor-core machines.