Developing and Fiddling with the G'MIC Python Binding

Thanks for your feedback!
Well, I wrote something on fx and gui commands lately, according to what David told me… About G'MIC's "fx_" and "_" prefixed filters or commands · GitHub They should not be used for production work if parameters signature stability is a must. So… since my tutorial series will be a duo of official readthedocs.io wiki pages and official gmic-py repository example folders, I must be as strict as possible. But for sure for my side prototyping project I would not mind using the gui commands.

The fact that gui commands are more practical to you than fx ones… speaks even of programmer accessibility of commands… I am myself a G’MIC language newbie, and most people who will turn to G’MIC scripting using gmic-py or gmic CLI will be for sure. I suppose that most new G’MIC users come because of the GUI plug-ins and are illiterate in the G’MIC language.

Here is a second tutorial for very beginners, about the gmic.Gmic() interpreter, gmic.GmicImage() classes and GmicImage lists.
it will be converted to a gmic-py readthedocs wiki article soon, but the above script is already usable and any feedback would be appreciated!
There is a little bug preventing image names from working at the very end. This is not a huge problem for now…

1 Like

Windows compilation and python wheel packaging for gmic-py has been put on hold (MSYS2 half-working but skipped, MSVC started).

The tutorial files have been simplified: the .py sources have almost no comments, the readthedocs .rst file instead has all comments in nice wiki style and contain G’MIC runs’ images.

Tutorial 3 will be about GIF and videos respectively for making a folioscope (flipbook) and a simple scripted non-linear video editing. Pillow or PyAV2 will be used.

Tutorial 4 or 5 will be on image segmenting through clicks for foreground and background annotation using PyGame most probably.

Some other tutorial will cover numpy/PIL/Scikit Image input and output converters, as those are the easiest entry points for Python developers and may bring in the most interest and long-term users.

Tiny docs update

Just switched the readthedocs theme from alabaster to sphinx_rtd_theme:


On the left panel, tutorials can now be navigated on 2 levels.
This is not yet online, I need to release a stable or tag version of gmic-py for readthedocs buildbot to pick it and publish it as the default or visitor-switchable documentation.

Each tutorial will be accompanied by a simplified script file, each in a tutorial*/ directory in the Github’s examples/ directory.

Tutorial 1 and tutorial 2’s example code are ready for testing.

3 Likes

G’MIC site proper could use some updated tutorials. These may be good starting points for that. :wink:

G’MIC’s website is in G’MIC-script-generated static HTML I think, I prefer not to touch it for now…

My gmic-py examples are meant to be:

  • for G’MIC language newbies
  • very simple, with a more artist/hobbyist-oriented approach than the image-processing one of gmic.eu

All-day Python developers start to be used to the github/gitlab + (hook) + readthedocs + (hook) pypi.org modules repository triplet, hence readthedocs, for which I have developed my own gmic sphinx plugin in Python. More modular to me.

Exactly what is missing. As one who is slow in math and coding, the existing content was very hard to digest in the learning phase.

1 Like

Nice!! I hope my Python tutorials will be friendly. Yesterday I was thinking of splitting them in even smaller parts. Maybe video tutorials might help as well some day.

gmic-py 2.9.1alpha6 release: network & documentation updates

Hello,
a “minor” update bumping the latest non-stable gmic-py to 2.9.1alpha6.

To install or upgrade it, run:

pip uninstall gmic -y # optional
pip install gmic==2.9.1a6

gmic-py’s network commands now works on all Linuxes (including Jupyter, Google Colab, Readthedocs)

  • gmic-py now follows the libgmic/CImg default behaviour of relying wget or curl installed executables for network actions. libcurl support is now removed from the setup.py / Python build system, packaging libcurl inside a Linux wheel is way too difficult (see auditwheel issue here).
  • important network commands are:
    • sp/sample for samples retrieval (most of the gmic-py tutorials rely on the them) from gmic.eu over https (example)
    • update for retrieving the latest .gmic internal & community-contributed commands file, which can spare you from upgrading the gmic runtime for a long time and or give you new neat filters published just 1 hour before.
    • network which is new from a few months ago by @David_Tschumperle (just promoting it here, see the gmic.eu commands reference)
  • this brings good news of fixing for 3 public environments which have curl or wget preinstalled:
    • the Google Colab platform, where @lesolorzanov had found gmic-py network errors, thanks for reporting!!
    • the JupyterLab platform, samewise as Google Colab
    • the readthedocs document building environment, which renders our tutorials markup, based on gmic online samples. (related issue here) (Thanks to the readthedocs team!!)

Here are examples of working network retrievals on the first two platforms:

The readthedocs documentation is now refreshed and online with a new theme

You can discover the graphically refreshed readthedocs documentation for gmic-py here (the latest default version which your web browser will show, corresponds to 2.9.1alpha6, which is what we want).

It includes quite solid Tutorials (number 1 and 2 especially) for beginners. The tutorials 3 and later are in the work; links at least show a roadmap before December 23rd 2020. gmic-py is very little known, but learning it should be very fast for simple applications, so feel to try and share this documentation around!

The API Reference is now also up to date.

Next steps are :slight_smile: :

  • write a tiny scikitimage pytest case
  • make the whole pytest suite green again
  • continue writing envisioned tutorials
  • synchronize with libgmic and publish gmic-py 2.9.4

:tiger: :tiger2:

1 Like

Result of the upcoming flipbook tutorial:
flipbook3

Added more example excerpts to the gmic-py Github home README:

Just realizing that the readthedocs website also allows for PDF and ePub output and the result is not bad!
image

Yeah, it comes with quite a few features. Some people love their reading devices. May be good for screen readers, for those with disabilities.

1 Like

Just released gmic-py 2.9.2 embedded libgmic 2.9.2 and using the related 2.9.2 G’MIC commands.
Just run the following to grab it:

pip install -U gmic

2.9.4 is slated for this week, after pytest suites fixes

1 Like

Congratulations on your accomplishment. Will there be someone who will work on the Win64 implementation of the Blender G’MIC addon? Is there anything I can do? Hope you land in Montreal as you have posted.

2 Likes

@paulhart2 you are sweetheart, thank you
I will now go on holiday and develop gmic-py itself or scripts using it in my free time only from january 2021. I will stay in France till June 2021 for passing a chocolate exam (much more clever to do it in France) and possibly a driving license. Montreal is for after then I think, when I find a position, multidisciplinary PhD or something else there.

Remember, we were close to a successful msvc compiling of gmic-py for Windows, after succeeding in compiling it for msys2 (except msys2 python dlls would not import in Python). I have no one in mind willing to try that out and succeed in it.

gmic-blender is very tiny for a Blender add-on for now and provides an addon manifest with an auto-importer for Blender’s Python interpreter of the OS-related bundled gmic-py release (typically a .so file), from its respective subdirectory. So once a gmic-py release for Windows is ready, it is very easy to put its .dll files in a windows-specific subdirectory of the gmic-blender addon and it will importable in Blender. From there, people can build all kinds of UIs and new add-ons and work with G’MIC without need for any Blender fork.

gmic-py's tutorials 1, 2, 3 are ready

These tutorials, hosted on gmic-py’s readthedocs.org website are:

  1. on the G’MIC language for beginners, using just gmic.run()
  2. about GmicImage, and Gmic intepreters, stylize - for people caring about gmic-py performance and internals and curious of G’MIC’s style transferring
  3. how to make a flipbook from a moonphases GIF using gmic-py, Pillow/ImageMagick - which uses a bit of 1. and 2., but can be dived right away too. This tutorial’s animate previewing commands will not work on web-based Jupyter/IPython/GoogleColab environments; they are not a must though.

All three tutorials will work best with gmic-py 2.9.1+ versions (pip install --upgrade gmic) for Linux.

Here is an overview of tutorial 3’s steps (just running the example 3 script in a virtual environment where gmic was installed):
gmicpy_tutorial3_steps

Tutorials 4 and later are discarded for now, because of their work in progress state.

Any feedback on any of those tutorial or on gmic-py will appreciated! Here or on gmic-py's Github.

@myselfhimself, thank you for your work on this.

I am really looking forward to the Windows version as I need support for both Windows and Linux in my project(s). :smiley:

1 Like

I like the new docs format better. :slight_smile:

1 Like