GIMP-ML
GIMP-ML copied to clipboard
More intuitive inpainting
Is your feature request related to a problem? Please describe. Currently inpainting is very difficult to use as is so please make it more availible.
Describe the solution you'd like User actions:
- Use any selection tool to select an area of the image to inpaint
- Call the inpainting plugin, which warns the user if there is no selection availible or layer is empty / non rasterized.
The following actions are done by the plugin:
- Fill the selected area with a solid color without antialiasing on a new (mask) layer;
- (if needed) Convert the mask layer to a format the inference module understands;
- Save image layer and mask layer as
cache0.png
/cache1.png
; - Send them to the inference module which saves its output as
result.png
or produces an intelligible error text (The inference module should fill only pixels corresponding to non-transparent mask-layer pixels leaving the rest transparent.); - Replace the mask layer with
result.png
so the it will have only inpainted region; - Delete cache and inference result files.
Additional context Currently if inpainting fails it does so silently without any intelligible error messages whatsoever, please fix it too.
We’ll update the inpainting model in gimp 3 ml branch
Please how line 126 to 160 in
inpainting.py for UI change. Or directly ping on slack https://join.slack.com/t/gimp-mlworkspace/shared_invite/zt-rbaxvztx-GRvj941idw3sQ0trS686YA
Mm.. it's not exactly what I asked. Error checking is also part of it but... Can you at least help me with GIMP3 code for what I asked as the main points? Aka selection, layer generation and filling before sending to the inference module?
In GIMP, see Help->Procedure Browser for list of functions available and it's usage.
It's not that I didn't know about help... I tried it like below and got a lot of type errors and I can't figure out what each type should be by myself:
pdb = Gimp.get_pdb()
interlace, compression = 0, 2
drawable = pdb.run_procedure('gimp-image-get-active-drawable', [image])
arr_drawable = Gimp.ObjectArray.new(Gimp.Drawable, [drawable.index(1)], 1)
cut_result = pdb.run_procedure('gimp-edit-cut', [1, arr_drawable])
mask_image = pdb.run_procedure('gimp-edit-paste-as-new-image', [])
mask_layer_group = pdb.run_procedure('gimp-layer-group-new', [mask_image.index(1)])
pdb.run_procedure('file-png-save', [
GObject.Value(Gimp.RunMode, Gimp.RunMode.NONINTERACTIVE),
GObject.Value(Gimp.Image, mask_layer_group),
GObject.Value(GObject.TYPE_INT, 1),
GObject.Value(Gimp.ObjectArray, arr_drawable),
# ...
pdb.run_procedure('file-png-save', [
GObject.Value(Gimp.RunMode, Gimp.RunMode.NONINTERACTIVE),
GObject.Value(Gimp.Image, image),
GObject.Value(GObject.TYPE_INT, 1),
GObject.Value(Gimp.ObjectArray, arr_drawable),
sorry but there is not much documentation available, the best way is to see other plugin files and see usage.
this is the only documentation available for the time being https://github.com/GNOME/gimp/tree/master/devel-docs/GIMP3-plug-in-porting-guide