Style transfer soon in G'MIC

try with

… output out.png")

It has nothing to do with the output.

The problem is it’s not reaching the image for the style.

GmicException Traceback (most recent call last)
in
----> 1 gmic.run(“athoimage _fx_stylize starrynight +fx_stylize 1,6,0,0,0.5,2,3,0.5,0.1,3,3,0,0.7,1,0,1,0,5,5,7,1,30,1,2,1.85,0 output out.png”)

GmicException: *** Error in ./_fx_stylize/*if/ *** Unreachable network file ‘https://gmic.eu/img/style_starrynight.png’.

But the file exists.

and if I try my own image it still tries to search in the server so I need to know if the command is different for a local style or if it’s not possible with a local style

1 Like

The command string you are showing calls:
_fx_stylize starrynight
this commando looks in ${-path_cache} for the file starrynight.png . If it is not located there gmic tries to download it. Seemingly you have a net problem. try “e ${-path_cache}” to see where it is located.

With your own style image try something like

“sourceimage styleimage +fx_stylize 1,6,0,0,0.5,2,3,0.5,0.1,3,3,0,0.7,1,0,1,0,5,5,7,1,30,1,2,1.85,0”
or
“sourceimage styleimage rv +fx_stylize 1,6,0,0,0.5,2,3,0.5,0.1,3,3,0,0.7,1,0,1,0,5,5,7,1,30,1,2,1.85,0”

sourceimage and styleimage should be filenames of images in gmic. I don’t know how images are addressed in python-gmic. rv exchanges the two images in the list if necessary, I don’t know the sequence for stylize of the images! At least you have to load two images and than call fx_stylize!

1 Like

yay gmic-py in the place!! It seems your computer’s or network’s proxy settings block access to gmic.eu… does running the same command in the gmic cli executable work? gmic-py and gmic cli both use libcurl for accessing internet files… but maybe I should improve the python module’s self-configuration…

Just tested now with Wifi at home:
apples


out_000002

    (gmicpy290numpy) jd@jd-ThinkPad-T400:~/Productions/GMIC/gmic-py/tmp$ python
    Python 3.7.5 (default, Nov 20 2019, 09:21:52) 
    [GCC 9.2.1 20191008] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import gmic; gmic.__version__
    '2.9.2'
    >>> gmic.__build__
    'zlib_enabled:1 libpng_enabled:1 display_enabled:1 fftw3_enabled:1 libcurl_enabled:1 openmp_enabled:1 cimg_OS:1 numpy_enabled:1 OS_type:unix'
    >>> gmic.__spec__
    ModuleSpec(name='gmic', loader=<_frozen_importlib_external.ExtensionFileLoader object at 0x7f01a6733cd0>, origin='/home/jd/.virtualenvs/gmicpy290numpy/lib/python3.7/site-packages/gmic.cpython-37m-x86_64-linux-gnu.so')
    >>> gmic.run("sp apples _fx_stylize starrynight +fx_stylize 1,6,0,0,0.5,2,3,0.5,0.1,3,3,0,0.7,1,0,1,0,5,5,7,1,30,1,2,1.85,0 output out.png")

:tiger: :tiger2: :snake:

2 Likes

I guess you can see

libcurl_enabled:1

in your gmic.__build__ output
if yes, then you may have something blocking outgoing http/https calls on your computer or network

1 Like

Thanks! This worked. I am now on a quest to understand the parameters. It works beautifully! I just want to tweak things here and there.

1 Like

gmic-py has exactly the same syntax as the g’mic language, except that to follow also closely the C++ API, a gmic_list of images is updated along your command string, with the buffers in order. In gmic-py this gmic_list has no special type, it is just a list of GmicImage object.

This images list thing is shown here in the doc’s Quickstart chapter: Quickstart — gmic-py 2.9.4-alpha1 documentation

But writing to you makes me realize there is not even one example on gmic-py’s Github dealing with images list for beginners…

so in short
you may be used to doing this in command line
gmic "my command"
G’MIC commands work in sort of polish notation like:
<buffers aka images from scratch or from previous command> some_command com,mand,scal,ar,para,meters

gmic-py imitates the very little known c++ api where the gmic interpreter takes actuall 2 parameters: a string, optionally: images to use and edit in place:

import gmic
images = []
gmic.run("sp apples sp earth blur 4", images)
#and images are in-memory images to reuse in a gmic.run
gmic.run("sharpen 3", images)

Beside image lists in python, perhaps some examples with command strings between double quotes might be helpful. I think there are similar problems like under bash (or zsh)!

Would you mind mentioning a command valued enough to you, which has quotes?
I do see what you mean, as I had big issues calling all gmic-community filters automatically from their “@gui_parameters” values in bash / pytest…

Been having fun playing with this for the first time. Here is the best I could do with poor old Mona. I don’t think they’ll trade me at the Louvre.

26f7962f9c48a4fee2a79d07a012c256

If I could ask two improvements of this tool it would be this:

  1. The ability to save presets - The parameters required to get an image to look like a line drawing are very different from those to get an image to look like painting. It’d be nice to save different flavours to access in one click.
  2. The ability for the light (and/or less dense) areas of the reference to map to the light areas of the image, and for the dark (and/or more dense) to map to the dark. Looking at the example of Mona above, I’d expect her hair to have a similar cross hatch pattern to her clothing, as they are a similar shade, but in my output one is light and the other is dark - and it didn’t matter which way I swung the parameters - and I tried many - I could never get the light areas to match up with the light directly, and dark with dark.

I of course do not know the complexity of such a request, or whether it might somehow already be possible.

Anyway, it is clear from just a short time playing, that this is a tool of immense power!