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

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

Wed Dec 06, 2023 1:37 pm

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

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


Downloaded, zip unpacked, contains a "RCS" folder ( and other files) in there is a "spawn.c,v" file ?
Never seen such a file-ending before. I doubt that it's ready to use.

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

Wed Dec 06, 2023 1:40 pm

A new discovery has been made with GEGL Bash Spawn that leads to it running orders of magnitude faster, as it prevents GEGL from reloading the same operation 9 times in a row. That's what is slowing it down.

Before I show case the discovery remember that /tmp/final.png is unique to the users given path.

The GEGL syntax
Code:
gegl-buffer-load

layer src=/tmp/final.png


gegl-buffer-load When ran after boy:spawn or anything in GEGL (like a blur or emboss) causes it to cancel everything and have nothing in the graph. GEGL Layer loads an image file; such as a final output in /tmp/. The plan to make GEGL Bash Spawn faster is to run the syntax I listed above after a few seconds of the user pressing a checkbox. The checkbox will activate the nodes at a several second delay.

This means GMIC filters in GEGL will load in 1 or 2 seconds instead of 10-20 seconds. Once again this is happening because gegl:buffer-load cancels everything and layer src= calls the image file that GEGL dumped in /tmp/

Example of me running GMIC's Bokeh in GEGL fast
This only took one second to load because I pasted commands strategicly.

first I pasted the command to call GMIC

Code:
id=callgmic
over aux=[ ref=callgmic

boy:spawn path-in="/tmp/first.png"  "path-out"="/tmp/final.png"   pipeline="  gmic  /tmp/first.png  output /tmp/in3.webp && gmic /tmp/in3.webp fx_bokeh 3,8,0,1,33.5,4,0.07,0.2,255,176,252,160,0.302,27,4.3,20,0.19,2,255,170,255,110,0.15,0,50,50 -o /tmp/final.png   "  ]

]


Then a second later I pasted this while Gimp was Frozen

Code:
gegl-buffer-load

layer src=/tmp/final.png


gmic_GEGL.png
gmic_GEGL.png (1.4 MiB) Viewed 69661 times

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

Wed Dec 06, 2023 1:54 pm

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

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


Downloaded, zip unpacked, contains a "RCS" folder ( and other files) in there is a "spawn.c,v" file ?
Never seen such a file-ending before. I doubt that it's ready to use.


Sorry it was source code only. I provided a download with a binary on the first page post.
download/file.php?id=70342

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

Wed Dec 06, 2023 2:06 pm

Soon this plugin will update with a delay property. When activated the nodes gegl-buffer-load and gegl:layer will kick in and unfreeze the graph and load the file in /tmp/

This is a hypothetical example where the unfreeze and call layer nodes are delayed by 4 seconds
delay_nodes.png
delay_nodes.png (17.39 KiB) Viewed 69656 times

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

Wed Dec 06, 2023 3:51 pm

Here is the same thing I did with GMIC now with REMBG. It now loads very fast with a delayed buffer.

pasted_image023.png
pasted_image023.png (372.57 KiB) Viewed 69655 times

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

Thu Dec 07, 2023 3:46 am

very difficult to follow you for non-programmers :-(

What do I really have to write into the GEGL command?

in my normal working(!) bash script I activate the environment like so:
Code:
source ~/anaconda3/etc/profile.d/conda.sh
conda activate base


And if I put this in the GEGL command
Code:
boy:bash input="GEGL_IN" output="GEGL_OUT" pipeline="source ~/anaconda3/etc/profile.d/conda.sh && conda activate base && rembg -p GEGL_IN -o GEGL_OUT


nothing happens really, nothing in /tmp either

It would be really nice to have a working step by step example.
Only to get rembg to work ... nothing else. No fancy you can do this and that and so.
That only confuses me ( perhaps others, too)

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

Thu Dec 07, 2023 4:29 am

nelo wrote:very difficult to follow you for non-programmers :-(

What do I really have to write into the GEGL command?

in my normal working(!) bash script I activate the environment like so:
Code:
source ~/anaconda3/etc/profile.d/conda.sh
conda activate base


POST WAS EDITED TO WORK WITH MODERN REMBG

And if I put this in the GEGL command
Code:
boy:bash input="GEGL_IN" output="GEGL_OUT" pipeline="source ~/anaconda3/etc/profile.d/conda.sh && conda activate base && rembg -p GEGL_IN -o GEGL_OUT


nothing happens really, nothing in /tmp either

It would be really nice to have a working step by step example.
Only to get rembg to work ... nothing else. No fancy you can do this and that and so.
That only confuses me ( perhaps others, too)


Disable preview and try this.

Code:
boy:spawn path-in="/tmp/in.png" path-out="/tmp/out.png" pipeline="source ~/anaconda3/etc/profile.d/conda.sh && conda activate base && rembg i /tmp/in.png /tmp/out.png"




To make it go 9 times faster paste

Code:
buffer-sink layer src=/tmp/out.png


AFTER GIMP IS FROZE AND THE ORIGINAL COMMAND IS RUNNING


its tricky but you'll get the hang of it.

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

Thu Dec 07, 2023 5:39 pm

contrast_ wrote:
nelo wrote:very difficult to follow you for non-programmers :-(

What do I really have to write into the GEGL command?

in my normal working(!) bash script I activate the environment like so:
Code:
source ~/anaconda3/etc/profile.d/conda.sh
conda activate base


And if I put this in the GEGL command
Code:
boy:bash input="GEGL_IN" output="GEGL_OUT" pipeline="source ~/anaconda3/etc/profile.d/conda.sh && conda activate base && rembg -p GEGL_IN -o GEGL_OUT


nothing happens really, nothing in /tmp either

It would be really nice to have a working step by step example.
Only to get rembg to work ... nothing else. No fancy you can do this and that and so.
That only confuses me ( perhaps others, too)


Disable preview and try this.

Code:
boy:spawn path-in="/tmp/in.png" path-out="/tmp/out.png" pipeline="source ~/anaconda3/etc/profile.d/conda.sh && conda activate base && rembg /tmp/in.png -o /tmp/out.png"




To make it go 9 times faster paste

Code:
buffer-sink layer src=/tmp/out.png


AFTER GIMP IS FROZE AND THE ORIGINAL COMMAND IS RUNNING


its tricky but you'll get the hang of it.


That doesn't work for me here. It just leaves an empty layer, except for text in the upper left corner that reports "load failed".

The plugin by JamesH works perfectly however.
viewtopic.php?f=9&t=20041&start=30#p278034

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

Thu Dec 07, 2023 6:51 pm

POST EDIT --- THE POST DID NOT RUN REMBG BECAUSE I WAS USING AN OUTDATED VERSION OF REMBG FROM EARLY 2022 AND THESE PEOPLE WERE USING A 2023 MODERN VERSION

Learn more about this here.
viewtopic.php?f=9&t=20652&start=60#p286226

--original post---

racer-x wrote:
contrast_ wrote:
nelo wrote:very difficult to follow you for non-programmers :-(

What do I really have to write into the GEGL command?

in my normal working(!) bash script I activate the environment like so:
Code:
source ~/anaconda3/etc/profile.d/conda.sh
conda activate base


And if I put this in the GEGL command
Code:
boy:bash input="GEGL_IN" output="GEGL_OUT" pipeline="source ~/anaconda3/etc/profile.d/conda.sh && conda activate base && rembg -p GEGL_IN -o GEGL_OUT


nothing happens really, nothing in /tmp either

It would be really nice to have a working step by step example.
Only to get rembg to work ... nothing else. No fancy you can do this and that and so.
That only confuses me ( perhaps others, too)


Disable preview and try this.

Code:
boy:spawn path-in="/tmp/in.png" path-out="/tmp/out.png" pipeline="source ~/anaconda3/etc/profile.d/conda.sh && conda activate base && rembg i /tmp/in.png /tmp/out.png"




To make it go 9 times faster paste

Code:
buffer-sink layer src=/tmp/out.png


AFTER GIMP IS FROZE AND THE ORIGINAL COMMAND IS RUNNING


its tricky but you'll get the hang of it.


That doesn't work for me here. It just leaves an empty layer, except for text in the upper left corner that reports "load failed".

The plugin by JamesH works perfectly however.
viewtopic.php?f=9&t=20041&start=30#p278034


Make sure you are using non flatpak Linux and Please give me your unique rembg directory. This is the default for most people. So try this

1-5-2024 EDIT TO MODERNIZE ORIGINAL POST
Code:
boy:spawn path-in="/tmp/in.png" path-out="/tmp/out.png" pipeline=" rembg i /tmp/in.png /tmp/out.png  "


Guys you need to understand that this plugin is literally just calling bash in Linux. So whatever works in bash on Linux will work in this plugin. If you can call REMBG in bash on non-flatpak Gimp it will work here.

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

Thu Dec 07, 2023 8:28 pm

I'm using Gimp PPA, not flatpak. rembg directory is "/home/user/.local/bin/rembg". it works fine via command line as well as python plugin. It doesn't seem to work in gegl graph using your script, at least not here.

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

Thu Dec 07, 2023 10:14 pm

If this worked on Windows, I wouldn't want to use rembg in Gegl anyway.
The expected result depends on the image type - but the JamesH plugin allows additional adjustments via mask (max. 20% adjustments - which is why a relatively slow plugin is better than manual selection).

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

Fri Dec 08, 2023 2:29 am

Doesn't work for me either. Looks like described by MareroQ GIMP from PPA.
Starting GIMP from terminal gives some messages:
Code:
(gimp:6349): GLib-GObject-WARNING **: 19:34:37.509: value "NULL" of type 'gchararray' is invalid or out of range for property 'path-in' of type 'gchararray'

(gimp:6349): GLib-GObject-WARNING **: 19:34:37.509: value "NULL" of type 'gchararray' is invalid or out of range for property 'path-out' of type 'gchararray'
using gegl copy
sh: 1: source: not found
sh: 1: source: not found
sh: 1: source: not found
sh: 1: source: not found
sh: 1: source: not found
sh: 1: source: not found


rembg works fine here from my bash script, but not from that GEGL thingy.
I won't try any longer.

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

Fri Dec 08, 2023 3:00 am

OUTDATED POST

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

Fri Dec 08, 2023 3:04 am

racer-x wrote:I'm using Gimp PPA, not flatpak. rembg directory is "/home/user/.local/bin/rembg". it works fine via command line as well as python plugin. It doesn't seem to work in gegl graph using your script, at least not here.


Try this once more and make sure it is ran inside GEGL Graph and replace "user" with your username.

This code was incorrect and was updated to be correct

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

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

Fri Dec 08, 2023 6:02 am

contrast_ wrote:
racer-x wrote:I'm using Gimp PPA, not flatpak. rembg directory is "/home/user/.local/bin/rembg". it works fine via command line as well as python plugin. It doesn't seem to work in gegl graph using your script, at least not here.


Try this once more and make sure it is ran inside GEGL Graph and replace "user" with your username.

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


Tried that and same results. It just won't work here. It's also very slow to process compared to the JamesH plugin.

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

Fri Dec 08, 2023 7:26 am

POST EDIT --- THE POST ABOVE DID NOT RUN REMBG BECAUSE I WAS USING AN OUTDATED VERSION OF REMBG FROM EARLY 2022 AND THESE PEOPLE WERE USING A 2023 MODERN VERSION

Learn more about this here.
viewtopic.php?f=9&t=20652&start=60#p286226

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

Fri Dec 08, 2023 6:07 pm

contrast_ wrote:The commands I posted earlier did not work because I posted REMBG -o /tmp/output.png, now I added the original in.png in front.

These should work, high confidence. I feel stupid for wasting people's time.

if REMBG is in Local Bin
Code:
boy:spawn path-in="/tmp/in.png" path-out="/tmp/out.png" pipeline=" /home/user/.local/bin/rembg /tmp/in.png -o /tmp/out.png  "



If REMBG can be accessed just by typing REMBG in bash.
Code:
boy:spawn path-in="/tmp/in.png" path-out="/tmp/out.png" pipeline=" rembg /tmp/in.png -o /tmp/out.png  "



I feel silly that I was going wrong advice.


I tried both those scripts and got the same results. I'm beginning to think you're the only one that can make it work. Yes I only need to use REMBG in bash...

Code:
~$ rembg --version
rembg, version 2.0.50


Using rembg in commandline or JamesH plugin work just fine. I'm done playing with this, sorry.

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

Fri Dec 08, 2023 7:13 pm

POST EDIT --- THE POST DID NOT RUN REMBG BECAUSE I WAS USING AN OUTDATED VERSION OF REMBG FROM EARLY 2022 AND THESE PEOPLE WERE USING A 2023 MODERN VERSION

Learn more about this here.
viewtopic.php?f=9&t=20652&start=60#p286226

--original post---


racer-x wrote:
contrast_ wrote:The commands I posted earlier did not work because I posted REMBG -o /tmp/output.png, now I added the original in.png in front.

These should work, high confidence. I feel stupid for wasting people's time.

if REMBG is in Local Bin
Code:
boy:spawn path-in="/tmp/in.png" path-out="/tmp/out.png" pipeline=" /home/user/.local/bin/rembg /tmp/in.png -o /tmp/out.png  "



If REMBG can be accessed just by typing REMBG in bash.
Code:
boy:spawn path-in="/tmp/in.png" path-out="/tmp/out.png" pipeline=" rembg /tmp/in.png -o /tmp/out.png  "



I feel silly that I was going wrong advice.


I tried both those scripts and got the same results. I'm beginning to think you're the only one that can make it work. Yes I only need to use REMBG in bash...

Code:
~$ rembg --version
rembg, version 2.0.50


Using rembg in commandline or JamesH plugin work just fine. I'm done playing with this, sorry.



I just realized I am using a version of REMBG from 2021 that I got off of a python website. I intentionally used an older versio.

It could be that the `rembg -i` command is replaced with something else in the newer version.


I am deeply sorry for wasting your time racer-x. I'll investigate and ask someone else to test it.

*update I don't know why it isn't working for some people and feel bad.

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

Fri Dec 08, 2023 7:15 pm

OUTDATED POST

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

Sat Dec 09, 2023 1:44 am

REMBG COULD WORK IN THE CLOUD FROM ANY MACHINE LIKE THIS

I have not tested this on my machine as I don't know how to open ports but in theory REMBG can run in the cloud like this. Both on a local cloud or a designated website that someone has yet to make specifically for GEGL to Gimp.

Code:
boy:spawn path-in="input.png" path-out="output.png" pipeline=" curl -s "http://localhost:5000/api/remove?url=http://input.png" -o output.png
"


It would likely work by uploading an image to a website using a bash command then sleep for a few seconds or so for it to process then call back the output file in GEGL. This is totally possible if someone made a designated website not only for u2net/REMBG in the cloud but to access it via bash.
Post a reply