Switch to full style
Post all Gimp scripts and script writing questions here
Post a reply

GEGL calls GMIC, REMBG, AIs or any bash string with our bash plugin

Mon Nov 27, 2023 1:05 am

IF YOU WANT TO SEE A WINDOWS VERSION OF THIS PLUGIN WE WILL NEED HELP. IF BIG GIMP YOUTUBE CHANNELS CAN GRAB ATTENTION IT CAN LEAD TO A WINDOWS VERSION OF GEGL AI PLUGINS.

DEC 12 UPDATE - THIS PLUGIN IS MUCH FASTER AND EASIER TO USE
pasted_image021.png
pasted_image021.png (518.67 KiB) Viewed 81032 times


NEW RELEASE HERE!!! (non flatpak Linux only) and it is now located in GEGL operation drop down list under the name Bash Plugin

BINARIES AND SOURCE HERE
gegl_bash_dec_12_2023.zip
(25.56 KiB) Downloaded 217 times


LOCATION TO PUT BINARY
Code:
/home/(USERNAME)/.local/share/gegl-0.4/plug-ins


Then Restart Gimp and go to GEGL operations.
Github of same download
https://github.com/LinuxBeaver/AI_in_Gi ... /tree/main

Plugin's new interface that is much easier to use.
Image

This is a plugin that simply calls Linux Bash in GEGL meaning any app that accepts bash commands such as AI's like background removal, image restoration tools and GMIC can be ran in GEGL. Below are facts about the plugin and a beta download.

1. This plugin is co-developed by BarefootLiam and me. Liam did the technical stuff of getting GEGL to call bash but I did the practial stuff of making it far easier to use and making it where it doesn't take several minutes to load images.

2. You need to have AI's installed on your system for this to work. But in theory they could call designated cloud servers with AI tools one day.

3. This plugin now has a more user friendly mode and due to known bugs like the "GEGL pixel chunks" a sacrifice was made. The bash command must always come first before anything else and users can only one bash string. This can be worked around using Liam's GEGL Graph only plugin though and of course one can input another bash string in the gegl graph.

4. Its Linux only and doesn't work on Windows, Mac or Flatpak Linux (without editing the code). As of Dec 31 2023 we do NOT have a plan to port it to Windows as that uses "Windows SS for Linux" and works in a different way. But we did figure out how to get it working with flatpak by manually editing a flatpak only build source code and replacing my username with your own username.

5. Most excitingly of all, This plugin is in a special build of my GEGL Layer Effects engine which can be downloaded here.
viewtopic.php?f=9&t=19924&start=170#p285859

Image

To find the normal release of GEGL Effects Layer Effects that doesn't include this go here.
https://github.com/LinuxBeaver/GEGL-Eff ... L/releases

The plugin is still in development but is decent and usable as of Dec 10 2023. :gimp

Re: GEGL Bash - by Liam (any bash commands in Gimp) coming soon

Mon Nov 27, 2023 1:13 am

GMIC commands from your systems GMIC will now be in GEGL as static previews via the user inputting something like
Code:
outdated post


and Face restoration AI's via the user inputting a directory to their own copy of GFPGAN via entering a directory UNIQUE TO THEIR OS
Code:
outdated post




Perhaps we can figure out how to make plugins with it but the user will be specified to link their systems GMIC directory manually in a GUI box.

Re: GEGL Bash - by Liam (use bash commands in Gimp) coming soon

Tue Nov 28, 2023 11:47 pm

*update DEC 5 2023

ok I almost confirmed this will be the string used to run AI's and GMIC inside GEGL

This one is unique to my OS in a special directory but if you have REMBG all you'll have to do is make it your own directory.
Code:
boy:spawn path-in="/tmp/in.png" path-out="/tmp/out.png" pipeline=" rembg i /tmp/in.png /tmp/out.png  "



and for GMIC in GEGL (this will be more universal)

Code:
boy:spawn path-in="/tmp/in.png" path-out="/tmp/out.png" pipeline="gmic /tmp/in.png weave 14,65,0,0.5,0,0,0,0,0 -o /tmp/out.png"


Code:

id=nothing dst aux=[ ref=nothing
boy:spawn path-in="/tmp/in3.png" path-out="/tmp/out3.png" pipeline=" gmic /tmp/in3.png output /tmp/out3.jpg"
]
crop
median-blur radius=0
id=before_effects over aux=[ ref=before_effects
boy:spawn path-in="/tmp/in2.png" path-out="/tmp/out2.png" pipeline="gmic -i /tmp/out3.jpg  fx_graphic_novelfxl 0,2,39.168,35.8,37.12,0,0.62,14,0,1,1.422,0.78,1.92,0,0,0,1,1,1,0.5,0.8,1.28  -o /tmp/out2.png"



]

Re: GEGL can now call GMIC, AIs or any bash string with Liam's bash pl

Sun Dec 03, 2023 6:25 pm

If anyone knows a way to use a AI based website with a bash string this will be able to work with that.

Meaning if someone figures out how to call a web server running background removal or image restoration in bash this plugin will work with that.

Re: GEGL can now call GMIC, AIs or any bash string with Liam's bash pl

Mon Dec 04, 2023 12:42 pm

Here is GEGL running GMIC's Weave filter.

Image

Download beta here.
https://cdn.discordapp.com/attachments/ ... 09e80be86&


THIS DOES NOT WORK ON WINDOWS OR FLATPAK LINUX.


Command to run GMIC filter, assuming GMIC on the system is installed.
Code:
boy:spawn path-in="/tmp/in.png" path-out="/tmp/out.png" pipeline="gmic /tmp/in.png weave 14,65,0,0.5,0,0,0,0,0 -o /tmp/out.png"

Re: GEGL can now call GMIC, AIs or any bash string with Liam's bash pl

Mon Dec 04, 2023 2:26 pm

This is EXTREMELY SLOW and takes over a minute to load. Its the export to GMIC command not the drop shadow, lol.
2023-12-04_14-25.png
2023-12-04_14-25.png (116.44 KiB) Viewed 81077 times

Re: GEGL can now call GMIC, AIs or any bash string with Liam's bash pl

Mon Dec 04, 2023 4:03 pm

If you are on Linux and have the GEGL Spawn plugin installed along with GMIC installed (ON YOUR SYSTEM OUTSIDE OF GIMP) this syntax will work

pasted_image014.png
pasted_image014.png (337.01 KiB) Viewed 81054 times


2023-12-04_16-02.png
2023-12-04_16-02.png (424.43 KiB) Viewed 81054 times


Syntax to paste in GEGL Graph here. It does not require any plugins of mine but it does require Liam's GEGL Spawn
Code:
boy:spawn path-in="/tmp/in.png" path-out="/tmp/out.png" pipeline="gmic /tmp/in.png  fx_blocks3d 128,0,6.86,1.5,0,10.08,45,50.1818,54.9091,0,-50,-100,0.5,0.7,1,1,0,0,0,128 -o /tmp/out.png"
saturation scale=2.0
translate y=-56.5

median-blur radius=0
id=1 gimp:layer-mode layer-mode=overlay opacity=0.73 aux=[ ref=1 emboss elevation=0 ]
median-blur radius=0
id=2 gimp:layer-mode layer-mode=hardlight opacity=1 composite-mode=auto aux=[ ref=2 noise-solid x-size=2 y-size=8  seed=344 color-to-alpha color=white opacity value=1.06 ]
levels in-high=0.8

bloom strength=220
id=3 gimp:layer-mode layer-mode=addition opacity=0.24 aux=[ ref=3 edge amount=4 ]

id=4 dst-over aux=[ ref=4 color-overlay value=black cubism tile-size=14

translate y=08 gaussian-blur std-dev-x=17 std-dev-y=17  opacity value=0.4 ]

dst-over aux=[ ref=4 color-overlay value=black

translate y=08 gaussian-blur std-dev-x=17 std-dev-y=17  opacity value=0.61 ]
median-blur radius=0
levels in-low=0.02

Re: GEGL can now call GMIC, AIs or any bash string with Liam's bash pl

Tue Dec 05, 2023 12:52 am

contrast_ wrote:1. I did not develop this plugin it was made entirely be a real Gimp dev on my request.

Download beta here.
https://cdn.discordapp.com/attachments/ ... 09e80be86&


THIS PLUGIN WILL BE LINUX ONLY AS WE HAVE NO IDEA HOW TO GET IT TO WORK WITH WINDOWS POWERSHELL.

A associate Gimp dev (BarefootLiam) is making a new GEGL plugin on my request to call bash commands using GEGL meaning it will be able to run any bash command on the users system. It will only work on Linux not Windows. This will allow me to call AI's like GFPGAN, REMBG and GMIC strings in GEGL

The plugin is still in development. :gimp


Is there a slim chance it might work on the mac OS version?

Re: GEGL can now call GMIC, AIs or any bash string with Liam's bash pl

Tue Dec 05, 2023 1:33 am

akky wrote:
contrast_ wrote:1. I did not develop this plugin it was made entirely be a real Gimp dev on my request.

Download beta here.
https://cdn.discordapp.com/attachments/ ... 09e80be86&


THIS PLUGIN WILL BE LINUX ONLY AS WE HAVE NO IDEA HOW TO GET IT TO WORK WITH WINDOWS POWERSHELL.

A associate Gimp dev (BarefootLiam) is making a new GEGL plugin on my request to call bash commands using GEGL meaning it will be able to run any bash command on the users system. It will only work on Linux not Windows. This will allow me to call AI's like GFPGAN, REMBG and GMIC strings in GEGL

The plugin is still in development. :gimp


Is there a slim chance it might work on the mac OS version?


I've never got any GEGL plugins working on Mac, they compile for Mac but in Mac's GEGL directory they do nothing.

Re: GEGL can now call GMIC, AIs or any bash string with Liam's bash pl

Tue Dec 05, 2023 1:39 am

UPDATE THIS IS MUCH FASTER NOW.

REMBG INSIDE GEGL

This is REMBG running inside the new GEGL Plugin with MANY OTHER THINGS INCLUDING GMIC STUFF

pasted_image017.png
pasted_image017.png (759.3 KiB) Viewed 79888 times


Here is an unmodified image of a Mottled Duck.
in.png
in.png (948.24 KiB) Viewed 79888 times


Now lets run the same syntax from the penguin on the duck

pasted_image016.png
pasted_image016.png (699.13 KiB) Viewed 79888 times


100% automated in GEGL

Re: GEGL can now call GMIC, AIs or any bash string with Liam's bash pl

Tue Dec 05, 2023 1:44 am

Here is the syntax btw, it requires plugins of mine and Liam's to work and this image file.

Code:
boy:spawn path-in="/tmp/in.png" path-out="/tmp/out.png" pipeline=" rembg i /tmp/in.png /tmp/out.png  "
lb:threshold-alpha alphadegree=1
id=1 gimp:layer-mode layer-mode=normal opacity=0.5 aux=[ ref=1]

lb:edgesmooth alpha-percentile2=80
id=2
crop
id=recall
id=alphalocked
src-atop aux=[ ref=alphalocked
id=nothing dst aux=[ ref=nothing
boy:spawn path-in="/tmp/in3.png" path-out="/tmp/out3.png" pipeline=" gmic /tmp/in3.png output /tmp/out3.jpg"
]
crop
median-blur radius=0
id=before_effects over aux=[ ref=before_effects
boy:spawn path-in="/tmp/in2.png" path-out="/tmp/out2.png" pipeline="gmic -i /tmp/out3.jpg  fx_graphic_novelfxl 1,2,13.056,40,3.96,0,0,9.2,0,1,0.776,0.474,2.17,0,0,4,1,1,1,0.5,0.8,1.28  -o /tmp/out2.png"
]
]
crop
over aux=[ ref=2  ssg stroke=1 opacityssg=3 colorssg=white    ]
id=3
dst-over aux=[ ref=3  ssg stroke=3 opacityssg=1 colorssg=#f7a8ff over aux=[ ref=2  ssg stroke=3 opacityssg=1.7 colorssg=#f7a8ff  gegl:custom-bevel size=1 gaus=1 depth=10 alphapercentile=55 blendmode=Overlay median-blur radius=0    ]
id=3.5 over aux=[ ref=3.5
color-overlay value=#240075 gaussian-blur std-dev-x=8 std-dev-y=9 opacity value=1.5
]

id=bg
dst-over aux=[ ref=bg  layer src=/home/contrast/Pictures/Magic/Trianglify_Workstation/polygons_fun.png unsharp-mask scale=1.5 ]
median-blur radius=0




crop
id=containrecall aux=[ ref=containrecall
gimp:layer-mode layer-mode=normal opacity=0.2 aux=[ ref=recall ]
]



]



]


crop
id=nothing dst aux=[ ref=nothing
boy:spawn path-in="/tmp/in3x.png" path-out="/tmp/out3.png" pipeline=" gmic /tmp/in3x.png output /tmp/out3x.jpg"
crop
median-blur radius=0
id=before_effects over aux=[ ref=before_effects
boy:spawn path-in="/tmp/in2x.png" path-out="/tmp/out2x.png" pipeline="gmic -i /tmp/out3x.jpg fx_mighty_details 25,0.21,25,1,11,0,50,50  -o /tmp/out2x.png"



Plugins syntax requires

viewtopic.php?f=9&t=20377
https://github.com/LinuxBeaver/Threshol ... /releases/
https://github.com/LinuxBeaver/GEGL-Cus ... /releases/
https://github.com/LinuxBeaver/GEGL-SSG ... /releases/

IMAGE FILE SYNTAX REQUIRES- REPLACE THE CONTRAST PATH WITH YOUR OWN
polygons_fun.png
polygons_fun.png (151.43 KiB) Viewed 90936 times

Re: GEGL calls GMIC, REMBG, AIs or any bash string with Liam's bash pl

Tue Dec 05, 2023 2:25 am

I am going to see if it is possible to call a web based REMBG, GFPGAN or some other AI image editing server. Based on everything I know the answer should be yes but it would need to be intentionally dedicated, meaning the web host INTENDED a designated bash string for REMBG, REAL ESRGAN, GFPGAN ect...

Re: GEGL calls GMIC, REMBG, AIs or any bash string with Liam's bash pl

Tue Dec 05, 2023 3:27 am

THIS IS MUCH FASTER NOW WITH THE NEW DEC 10 UPDATE

FACE RESTORATION AI RUNNING INSIDE GEGL

I got GFPGAN running in GEGL unique to a special directory on my system. It takes 4 minutes to load on large images.

pasted_image019.png
pasted_image019.png (437.1 KiB) Viewed 90928 times


For me it is this.

Code:
id=nothing dst aux=[ ref=nothing
boy:spawn path-in="/tmp/in3.png" path-out="/tmp/out3.png" pipeline=" source /home/contrast/Applications/mc/etc/profile.d/conda.sh && conda activate base && cd /home/contrast/Applications/GFPGAN/ && python inference_gfpgan.py -i /tmp/in3.png -o /tmp/out3.png  -v 1.3 -s 1"
]
crop
layer src=/tmp/out3.png/restored_imgs/in3.png


For everyone normal in a default install GFPGAN may be here

Code:
id=nothing dst aux=[ ref=nothing
boy:spawn path-in="/tmp/in3.png" path-out="/tmp/out3.png" pipeline="  /home/contrast/.local/GFPGAN/ && python inference_gfpgan.py -i /tmp/in3.png -o /tmp/out3.png  -v 1.3 -s 1"
]
crop
layer src=/tmp/out3.png/restored_imgs/in3.png

Re: GEGL calls GMIC, REMBG, AIs or any bash string with Liam's bash pl

Tue Dec 05, 2023 3:32 am

I just confirmed that the only way this tool will work in the cloud online (for normies who don't have any AI's installed) is if someone makes a public server that allows users to run specific bash strings to call said AI tools. Then it will definitely be possible.

Currently I don't think anyone does it like that and if they did they could charge a fee or only 3 users per day ect...

Re: GEGL calls GMIC, REMBG, AIs or any bash string with Liam's bash pl

Tue Dec 05, 2023 3:55 am

It looks to me like I am making deep progress with GEGL while others haven't even made a single GEGL plugin. It concerns me that everyone else is way behind and its has been over 1.5 years since my first plugin and 2.5 years since the first day I studied GEGL.

GEGL AUTOMATES WITH GMIC COMMANDS
2023-12-05_03-52.png
2023-12-05_03-52.png (480.82 KiB) Viewed 90928 times



2023-12-05_03-49.png
2023-12-05_03-49.png (26.3 KiB) Viewed 90928 times


gmic_gegl.png
gmic_gegl.png (365.56 KiB) Viewed 65845 times

Re: GEGL calls GMIC, REMBG, AIs or any bash string with Liam's bash pl

Tue Dec 05, 2023 4:44 am

@contrast_,
maybe it's only me ...
but I'm unable to see what I have to install, to for example run rembg in GEGL.
You post so many things in so many places .... I can't follow you.

Re: GEGL calls GMIC, REMBG, AIs or any bash string with Liam's bash pl

Tue Dec 05, 2023 5:56 pm

nelo wrote:@contrast_,
maybe it's only me ...
but I'm unable to see what I have to install, to for example run rembg in GEGL.
You post so many things in so many places .... I can't follow you.


Sorry for not clarifying.


How to get REMBG working with this (Linux Only)


You have to have REMBG installed on Linux.
https://pypi.org/project/rembg/

Then if you haven't already install this GEGL plugin on non flatpak Linux in


https://cdn.discordapp.com/attachments/ ... 09e80be86&


You can also add this string to remove the erosion damage around the outline from REMBG.

Code:
lb:threshold-alpha alphadegree=1
id=1 gimp:layer-mode layer-mode=normal opacity=0.5 aux=[ ref=1]

lb:edgesmooth alpha-percentile2=80


These two plugins are needed for that
viewtopic.php?f=9&t=20377
https://github.com/LinuxBeaver/Threshol ... /releases/

All three GEGL plugins go in
Code:
/home/(USERNAME)/.local/share/gegl-0.4/plug-ins


Install the plugins and restart Gimp and open GEGL Graph

THE PART OF DISABLING FOR SPEED IS OUTDATED
slow.png
slow.png (41.48 KiB) Viewed 90903 times


Run
Code:
boy:spawn path-in="/tmp/in.png" path-out="/tmp/out.png" pipeline=" rembg /tmp/in.png -o /tmp/out.png  "


If REMBG is in a special directory change the default rembg text to its directory. It should work


At the end GEGL Graph should look like this and have this.

2023-12-05_17-54.png
2023-12-05_17-54.png (424.56 KiB) Viewed 90903 times


Code:
boy:spawn path-in="/tmp/in.png" path-out="/tmp/out.png" pipeline=" rembg /tmp/in.png -o /tmp/out.png "


lb:threshold-alpha alphadegree=1
id=1 gimp:layer-mode layer-mode=normal opacity=0.5 aux=[ ref=1]

lb:edgesmooth alpha-percentile2=80boy:spawn path-in="/tmp/in.png" path-out="/tmp/out.png" pipeline=" rembg i /tmp/in.png /tmp/out.png "


lb:threshold-alpha alphadegree=1
id=1 gimp:layer-mode layer-mode=normal opacity=0.5 aux=[ ref=1]

lb:edgesmooth alpha-percentile2=80


If the path doesn't work go to pipeline=" and add your REMBG directory. This will be extremely slow.

Re: GEGL calls GMIC, REMBG, AIs or any bash string with Liam's bash pl

Tue Dec 05, 2023 6:03 pm

GEGL runs each command six times in a row even when preview is DISABLED. But the final image is already in the /tmp/ directory the first time getting overwritten five more times.

This could be six times faster if someone figured out how to cancel GEGL Graph and import the final png file in Gimp. Or if the user manually presses Esc key many times to cancel GEGL graph loading and goes to their /tmp/ and manually imports the final result by dragging the image file into Gimp.

I tried using xdotool to hit escape many times by running bash like
Code:
xdotool key escape && sleep 0.100 && repeated... && gimp /tmp/final.png
and it didn't work but new images suprisingly opened Gimp while GEGL graph was running.

Re: GEGL calls GMIC, REMBG, AIs or any bash string with Liam's bash pl

Tue Dec 05, 2023 7:07 pm

This plugin has a known bug caused by GEGL's pixel chunks.

WHAT ARE PIXEL CHUNKS?
GEGL's image processing under the hood tiles images based on a given amount of pixels. They are called "chunks" I don't know what the default is but I do know that it can be changed. by running
Code:
gimp --gegl-chunk-size number
though this does not solve my problem as no matter what I think some chunks have to exist and the number may have a cap around several thousand.

WHAT IS THE BUG?
The exported png to be ran with bash is sometimes a pixel chunk instead of the full image. Here is the problem caught live in my tmp folder.
pixel_chunks.png
pixel_chunks.png (80.69 KiB) Viewed 90900 times


END RESULT OF THE BUG
(Gmic filter is only applied on a pixel chunk and not the entire image. Seen in red)
pixel_chunks2.png
pixel_chunks2.png (58.46 KiB) Viewed 90900 times



The only work around to pixel chunks is to avoid using Gegl Spawn's path out.
Code:
boy:spawn path-out=/tmp/final.png""


and instead just import the final file with

Code:
layer src=/tmp/final.png



This is code that will only work on my machine to do the task of running REMBG, GMIC and GFPGAN together, it ignores "path-out"
and imports the /tmp/whatever.png using gegl:layer.

Code:
#STRING 1
id=string1
src aux=[ ref=string1

id=invisibleblendmode dst aux=[ ref=invisibleblendmode

boy:spawn path-in="/tmp/in3.png"  pipeline="   gmic /tmp/in3.png output /tmp/out3.jpg   && gmic -i /tmp/out3.jpg  gcd_jpeg_smooth 1,1,0,0  -o /tmp/out2.png && source /home/contrast/Applications/mc/etc/profile.d/conda.sh && conda activate base && cd /home/contrast/Applications/GFPGAN/ && python inference_gfpgan.py -i /tmp/out2.png -o /tmp/face -v 1.3 -s 1 && rembg /tmp/face/restored_imgs/out2.png -o /tmp/final.png   "  ]
src-in aux=[
layer src=/tmp/final.png

]

lb:threshold-alpha alphadegree=1
id=1 gimp:layer-mode layer-mode=normal opacity=0.7 aux=[ ref=1]
lb:edgesmooth alpha-percentile2=80

Re: GEGL calls GMIC, REMBG, AIs or any bash string with Liam's bash pl

Wed Dec 06, 2023 12:00 am

After spending all day with the plugin I figured out how to trigger a variation the chunk bug.


chunk_bug.png
chunk_bug.png (289.17 KiB) Viewed 65845 times



0. Start with GEGL Graph - duh

1. Run moderately/severely intensive normal GEGL commands like a gaussian-blur.

2. Call GMIC through GEGL after those commands ( the importing of the image file is when the chunks are created) then the chunks create a NOT INTENDED glass tile effect.

This does NOT happen if the GMIC command is before the other GEGL operations. Only if it happens after it. It also does not happen if the commands are super light weight like lighting filters that take virtually no resources.


Here is an example of a graph that creates a unwanted glass tile chunk bug.
It happens because boy:spawn has a bunch of GEGL operations before it and those operations are constantly updating when the image file export is happening in /tmp/. The saved .png chunks are then modified and they create the ugly glass tile effect.


Code to duplicate the bug
Code:

id=containall

src aux=[ ref=containall

id=1
posterize levels=10
cubism tile-size=10
gimp:threshold-alpha

gimp:layer-mode layer-mode=normal opacity=0.3 aux=[ ref=1  ]
id=3
gimp:layer-mode layer-mode=overlay opacity=0.30 aux=[ ref=3 emboss ]



]

crop

id=invisibleblendmode src aux=[ ref=invisibleblendmode

boy:spawn path-in="/tmp/in3.png" path-out="/tmp/out2.png"  pipeline="   sleep 0.5 && gmic /tmp/in3.png output /tmp/out3.jpg   && gmic -i /tmp/out3.jpg  fx_smooth_anisotropic 10,0.512,1,2.15,8.61,1.6504,80.48,5,0,1,10,0,0,50,50  -o /tmp/out2.png    "  ]


]

crop


I have no clue how to solve this bug. I tried exporting a png and sleep 10 (to delay things and it failed)
Post a reply