Pythonic Procrastinations #1: Auto-illustrating a book & upsetting DALL·E

I often come up with concepts for ‘things’ I can do in Python, have a solid crack at them and then either lose interest or lob them across the room into the ‘too hard’ basket. In the interest of keeping some fresh content up on the ‘ol 5th Filter I’ve decided to start sharing some of these happy failures. Pythonic Procrastination #1 is a result of my asking (myself): “How could I ‘automatically’ illustrate a book?” There are some really fun results and this is definitely something I will come back to, tidy up and try out on some other books.

My process (broadly) was:

  • Get a book – I found a txt file of Blood Meridian by Cormac McCarthy (I own a real-life copy!).
  • Use NLTK to tokenise sentences and find the average sentence length, tokenise words and highlight the adjectives, and then finally return the most ‘adjective-heavy’, above-average sentence for each chapter – My reasoning here was the more adjectives, the more ‘illustrative’ the sentence.
    • Defining chapters was its own adventure, as they are in roman numerals…
  • Connect to the DALL·E API, and build some prompts with our illustrative sentences: “Produce a painting in the style of {artist}, considering the following excerpt: {sentence}”
    • (my chosen) artists = [“dali”, “goya”, “cezanne”, “munch”, “kahlo”]
  • The results were fantastic, and for me really captured quite a bit in the way of Blood Meridian’s hellish open desert landscapes and raw horror… I ended up with probably over a hundred images but have provided some favourites below (and the text that inspired them). Enjoy!

“The plains were sere and burnt-looking and the small trees black and misshapen and haunted by ravens and everywhere the ragged packs of jackal wolves and the crazed and sun-chalked bones of the vanished herds.”

Blood Meridian, Chapter 23
In the style of Caravaggio

“The seep lay high up among the ledges, vadose water dripping down the slick black rock and monkeyflower and deathcamas hanging in a small and perilous garden.”

Blood Meridian, Chapter 5,
In the style of Dali

“A wrinkled pug face, small and vicious, bare lips crimped in a horrible smile and teeth pale blue in the star night.”
Blood Meridian, Chapter 5

(This one is actually in the context of a sleeping man being attacked by a bat…)

Blood Meridian, Chapter 5,
In the style of Munch

“The old church was in ruins and the door stood open to the high walled enclosure.”

Blood Meridian, Chapter 17,
In the style of Goya

“In elections of these magnitudes are all lesser ones subsumed, moral, spiritual, natural.”

Blood Meridian, Chapter 17,
In the style of Giger

There’s actually a whoooole heap going on in this last sentence – The chief antagonist, Judge Holden is essentially heckling some poor dullards from 1879 with some heavy-duty philosophic prose. It’s been long understood that Judge Holden is an allegory for Satan, which makes this Giger impression eerily spot on.

Sorry DALL·E!

I received quite a few funky error messages early on, before realising that I was upsetting DALL·E with some of the things I was asking it to illustrate – Some of the sentences the script was turning up were violating the usage policies. It seemed to be particularly disturbed by the following:

“Flies clambered over the peeled and wigless skulls of the dead and flies walked on their shrunken eyeballs.”

Blood Meridian, Chapter 5

In the end I turned to the actual DALL·E client armed with a brief history of American realists of the time and gently persuade it to make the image for me.

Sweet!

A few more awesome outputs:


Posted

in

,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *