The GardenDespatches from The Satyrs’ Forest

Posts tagged as “technology”

The pauper’s jQuery

Black and white film still of a man in thought surrounded by grimy computer wiring
Pic loosely-related, from Darren Aronofsky’s πJS makes me want to drill my brain out sometimes, too.

Javascript has come a long way since the days of marquee tags and spacer gifs. You can do a lot with the API they give you to mess around with your web page’s content — but alas, so many of the functions have such verbose names!

To solve this, while not having to deal with the heaving weight of jQuery’s ten billion lines of IE6 compatibility, i made my own little alternative, and carry it everywhere with me:

const $ = sel => document.querySelector(sel);
const $$ = sel => document.querySelectorAll(sel);

Element.prototype.$ = Element.prototype.querySelector;
Element.prototype.$$ = Element.prototype.querySelectorAll;

EventTarget.prototype.on = EventTarget.prototype.addEventListener;

const documentReady = fn => document.on("DOMContentLoaded", fn);

What it does, in a nutshell: Use $ to select something matching a CSS selector, and $$ to select an array of everything it matches. (This is already available in your browser’s dev tools!) You can also use it on an element to restrict your search to its children — say, $(".post").$$("aside"), or some other such fanciful chaining.

.on, meanwhile, lets you listen out for events like so: $("#my-button").on("click", () => { /* Your function here… */ })

Finally, documentReady is just a nicer name for the frankly obtuse “DOMContentLoaded”.

Enjoy. Or don’t, i suppose. Hopefully it makes your hypertext tinkering just a little nicer. :-)

What does AI make of the Gods?

I recently bought 1000 images’ worth of credits on DreamStudio — a machine-learningα-powered art generator — on a whim and, after the requisite “Boris Johnson taking a bath of baked beans” joke entries, i thought it would be an interesting test to get it to generate some images for my shrines (on- and offline).

Four images of god. From left to right: a stone carving resembling Zeus, a tapestry with a four-armed figure draped in green robes, fire reaching into the sky with a nebula in the centre, and a stone carving by the seaside resembling the face of Jesus of Nazareth.
Just typing in “God” brought a fascinating cavalcade of interpretations — some clearly Hellenic, some Christian, some taking more inspiration from the dharmic faiths, and the occasional completely abstract depiction.

My motivations were twofold: first, due to copyright constraints, all of the icons adorning these shrines were either old baroque paintings or freely-licenced photos of even older marble statues, which didn’t necessarily represent my mental image of the Gods’ appearances — a topic which, of course, will vary massively from artist to artist and culture to culture. Second, i thought it would be a fascinating experiment to see how this machine learning algorithm, which has taken in hundreds upon thousands (perhaps millions; i’ve not checked) of images, views the Gods in its latent space. Just as it has a prototypical idea of a “dog” and a “cat”, surely it also has one for “God” and “Dionysos”.

Hestia in a toga leaning on a pillar near a hearth, with a halo-like glow emanating from Her head

As is tradition, we begin this article with Hestia (although Her portrait was actually the final one to be generated). On the broad strokes, my computer collaborator knocked it out of the park — but a closer look reveals some glaring imperfections in the face and hands, a theme which we’ll be seeing a lot of (and which i sometimes managed to harness to my advantage).

Apollon — a lithe, youthful, Caucasian man with waving blonde locks of hair — reaches up towards the heavens in front of a hilly valley

I should note that i’m not just feeding it theonyms with no added context: the programme works best if you help it along to your goal with a heaping of adjectives and descriptors, say, to tell it that this is indeed meant to be an artwork (“4K ultra HD”, “trending on ArtStation”), the details of the pose and background you want (“blonde hair”, “raising His hand to the sky”), or the style and artists you want it to take from (“baroque painting by Thomas Cole”, a prominent painter of beautiful, well-lit landscapes). If you calibrate it just right, it can make some genuinely beautiful stuff, like the above picture of Apollon (which i did, admittedly, have to manually touch up to get rid of a prominent Habsburg chin).

Gæa, framed by Celtic knotwork, as a green-skinned, bare-chested woman with leaves for hair

It may be an immensely powerful tool, but DreamStudio can also be rather prudish.β It blurs out any images it thinks might contain the utterly offensive sight of the genitalia with which we are all born, which can be a real problem if the relevant pictures it’s learnt from are all Greek and Roman statues — not exactly works known for their nether modesty. The detection software isn’t perfect, though, and sometimes, like in this portrait of Gæa, it lets a few slip past (perhaps because of the greenish tone with which i instructed itγ to portray Her skin).

Hermes as a swarthy young man wearing a three-feathered crown, fleshy wings emanating from His sides

The algorithm sometimes has issues with more complex prompts, for it is just a machine, and doesn’t actually understand that “ball on top of a red box” means that the ball indeed should be on top of the box, as opposed to by its side, beneath it, or fused together in a horrific amalgam. These troubles somewhat manifested themselves in the above portrait of Hermes; the winged cap He is traditionally depicted with has transformed itself into both a crown and a hulking pair of soaring, fleshy wings emanating from His shoulders, and the recognisable caduceus has been reduced to a bamboo stick by His side.

Perhaps it’s just the style i instructed it to paint in — sixteenth-century European paintings aren’t renowned for their diversity — but DreamStudio also has some real trouble with darker skin tones. You can cry “dark skin, dark bronze skin, dark skin, dark skin, dark skin, black” all you want, but the only thing that can consistently get it to generate anything a shade below the average Spaniard is “African American”, which tends to bring along a heap of other associated physical changes besides just skin tone. (I have to say, i don’t particularly envision Hermes as the eponymous Futurama character in my head.)

Hermaphroditus as an androgynous, twinkish fellow with three arms, laying down by a pond in a bed of leaves

It also has quite some trouble with arms and legs. Originally, i thought of its odd morphings and multiplications as a bug to be stamped out, but i came to see them as a feature, representing the manifold, varied aspects of the Gods, their omnipresence, transcending the limits of human form. (This is also why the Hindus do it, if i recall correctly.)

I would have rather the above portrait of Hermaphroditos been slightly more, ah, gynomorphic around the chest, so to speak, but i’d been trying to get a decent pose for what felt like an hour and i didn’t feel like fighting the blur anymore.

Dionysos as a three-legged and -armed bearded man, overweight but muscled, covered in flowers

So then — it’s a bit off in places, and lacks the leopard-skin toga i would have liked, and lord knows what the objects He’s holding are meant to be, and it turned out the computer really, really, struggled with the basic concept of a faun or satyr’s legs, but we end this post with DreamStudio’s interpretation of an icon of Dionysos, framed by some beautiful landscape.

Navigating through the neural net’s knowledge and limitations has been a fascinating, illuminating exercise, which has left no doubt in my mind that “AI art” is, indeed, just that: art. It seems to me much more comparable to something like photography than painting: rather than doing the hard work by hirself with brush strokes and pencil lines, the artist guides hir computer collaborator through latent space, pressing “click” when sie finds something appealing. One can only hope the Muses would approve.

I am not good at computer

Non-techies, you can safely ignore this post and go on with your day. But, tech people, if you’re still reading… a little help for an ignorant soul, please? 😅

I’m planning to add a comment section to the main part of my website. The problem is, of course, that i’ve barely ever touched PHP and Sql before, let alone tried to make something like a comment system, and as such, i have no fucking idea what i’m doing.

I’ve got a design figured out — see above — and a rough idea of what the database will look like:

  • postId: Integer, generated by adding some random digits to the end of a Unix timestamp
  • timestamp: Integer, just a Unix timestamp of when the comment was submitted
  • commentLocation: Unicode string, max. 32 chars?, indicating on which comments section the comment was posted
  • displayName: Unicode, max. 128 chars?, is what it says on the can
  • emailAddress: Unicode, max. 128 chars?, used to generate the avatar via Gravatar and maybe filter spam if it comes to that
  • website: Unicode, max. 128 chars?, used to… link to the commenter’s website
  • commentText: Unicode, max. 4096 chars?, the actual text of the comment; will be processed as a subset of Markdown
  • planet: Unicode, max. 16 chars?, any comment for which the response isn't earth will get thrown out

So, erm… any suggestions? Improvements? Ways of not getting my site hacked? Polite ways of telling me that this was a terrible idea? are welcome in the comments below.