Lynn Cherny, EuroPython and PyData London, 2019
When I give invited talks, I make new stuff. So there's drafty toys in here!
Hieronymus Bosch's "The Garden of Earthly Delights"
Quantumly random image
detail from the big picture
is really very engaging.
|Task||Thing I Did||Rating Easy||Rating Fun / Interesting|
|1||Used Twint to scrape tweets from Jan 1 - May 5, 2019 with images: "An advanced Twitter scraping & OSINT tool written in Python that doesn't use Twitter's API, allowing you to scrape a user's followers, following, Tweets and more while evading most API limitations."||Very! 😁||Quite cool. 👍|
|2||Pandas to load, review, and finally get the top 10 by most "likes"||Very! 😂||Very! 😂|
|3||Figured out where the image segments were from in the big image (blargh #$%*).||NOT. 🙄||Meh. Good problem I didn't solve.|
|4||Used Leaflet.js for a web app to display them!||Fairly... after tiles and transforms||Kind of? 🤔|
"What details did people like most?" I wondered. And made an app.
Here's a helpful blog post - however, it's a bit out of date because you can use leaflet with image data that's non-map now without extra libs like leaflet-rastercoords.
gdal2tiles.py [-p profile] [-r resampling] [-s srs] [-z zoom] [-e] [-a nodata] [-v] [-q] [-h] [-k] [-n] [-u url] [-w webviewer] [-t title] [-c copyright] [--processes=NB_PROCESSES] [-g googlekey] [-b bingkey] input_file [output_dir]
Click on a "dot" marker... and zoom in:
The top fav was: Naked guy's butt on a fish!
@Boschbot said, "Karen Kilgariff boosted that pinned tweet by 100x. ... With Karen I had to ask, ‘Why did this take off?’ I’d never heard of her!"
Why was it such an outlier?
That tweet image is "pinned" at the top of the twitter page for @Boschbot.
@KarenKilgariff is a comic celeb (I had to look too).
(I'll make a live web app with updating stats soon.)
days posted before july 12
We need new interaction models, filters, display methods... The entire app needs redesigning! (Woops.)
possible local demo of wip
On the path -- a new color scalar helps...
Lower right corner, giant red blob....
A word will be represented by a single vector in a matrix -- we find similar words by finding similar vectors.
A fine source of fair use text!
from gensim.models import Word2Vec # define training data - tokenized sentence format sentences = [['this', 'is', 'the', 'first', 'sentence', 'for', 'word2vec'], ['this', 'is', 'the', 'second', 'sentence'], ['yet', 'another', 'sentence'], ['one', 'more', 'sentence'], ['and', 'the', 'final', 'sentence']] # train model model = Word2Vec(sentences, min_count=1) # summarize the loaded model print(model) # summarize vocabulary words = list(model.wv.vocab) print(words) # access vector for one word print(model['sentence']) # save model model.save('model.bin') # or .txt format is possible too # load model new_model = Word2Vec.load('model.bin')
Source but there are many tutorials online...
Explorable UMAP 2D Display of One Model, thanks to Plotly (local demo)
A common illustration of word2vec models is to find similar terms:
What if we went from the closest word to "polite," which is "courteous," and then found that word's closest word, and then found that word's closest word.... And I made an app (local demo).
ex above from here
Word chain from "wind" in Gutenberg poetry word2vec model (based on Allison Parrish's corpus work here)
Vertical distance ~ distance in this model's vector space. "wind" and "mist" are further than "rain" and "wind"
Size ~ how often this word shows up as a "most similar"; cycles are not allowed (we take the next-closest word instead).
Color: Pretty. (Also to suggest an order for reading left to right, along with the swoop)
"Believe" in the older model, pre-January 2019 common domain releases
"Believe", in the UPDATED poetry model. You can get to magazines!
in nerd2vec, we're fairly "rational" here.
Inspiration in found poems, blackout poems, cut up poems, and creative constraints...
A next level project, a human-in-the-algorithm-loop creativity tool:
Color represents a normalized distance between the original word (random "nouny"*-words) and its next closest relative in the embedding model.
Blue: Closer, Pink: Further Away.
* using Rita.js in the browser, it's not great at POS. I need to switch to a server-based SpaCy
Click on a colored word... pick a replacement from it's nearest neighbors in the model....
and you edited the poem :)
D3.js for color scale: Map from your domain of number values to your range - color start and end point.
App (with Dropdowns) Poem Line of the Poem Clickable Words Buttons Modal component ModalList component SelectList component
Call the API here for all words :( [promise hell]
Called the API originally here - 1 call
React Programming Turns Out To Be...
Basho Haiku are kind of fun :)
|Task||Thing I did||Rate ease||Rate interesting/ fun|
|1||Make word2vec models||Very easy||😃 Always fun|
|2||Stupidly decide to code the poem app in React||Easy to decide, very very hard learning curve for the number of interactions involved up and down the stack. My code is a mess.||😬|
|3||Change the stack to get the distances for all words as promises||Quite hard - updating after right point.||😢|
|4||Do the color scale on the buttons||Easy - D3 is an old friend||😃 Always fun, still fun in react.|
|5||Add the dropdowns to select model and poem||Ok, not bad. Some state issues...||Maybe seeing the point of react a little more-? Obviously hooks would help. 🤔|
Example of me trying to work with the blue tool...
NVidia's GauGAN demo: http://nvidia-research-mingyuliu.com/gaugan
My crap drawing
Its weird photo realism
(and be clever about it.)
Crown & Fathous
Burn Horse Hotel
Doss of Wulling of Stank
Shore’s Castle Crustle Hotel
The All House
Dean & Funtling
Old Hell Kick
Fripy Whee Bore Inn
Hogs Thee Inn
Shur Hiad House Hotel Hotel
Old Ash Ox Horse Inn
Darn Funk Inn
Of Oz the Wizard
For those of you who think this must have taken a lot of time: it didn't! I'm too lazy to have cut all this by hand. I wrote a couple apps that made disassembly go very quickly. The primary work took me and a friend about 20 hours.
My appreciation for the film increased enormously, mostly in a technical sense while disassembling. I saw and heard things I’d never seen before and which you would only see going frame by frame. I saw how much craft there is in the film.
Matt Bucy, interviewed
"Ten thousand, or a myriad, of photos of tulips were taken over the course of tulip season and each has been categorised by hand, revealing the human aspect that sits behind machine learning."
Poetry by Mary Oliver. Art by Helena (@glagolista)
API calls -
Give credit to your sources and inspirations... we all help each other.
And really don't be this guy:
"If I don't do it, someone else will do it in a year."
"Just a couple of days after taking the app down, the creator posted the code of the application to GitHub, saying that because the DeepNude application had already been replicated widely, there was no purpose in keeping the original code private, so they published it online."
"The algorithm only works with women, Alberto said, because images of nude women are easier to find online—but he's hoping to create a male version, too."
wild forks and branches
are way better
When you find yourself playing with what you made and smiling... well, that might be good enough.
in a weirdly popular tweet of mine
More writing about AI Art & Data Vis on Medium: https://medium.com/@lynn_72328
Slides up on ghostweather.slides.com!