Send a request

Brand and design · 3 min · Andrey Atmorsky

The image turned out harder than the text

Top view: a woman with printed photos works at a desk with a netbook.

In short

My Python script writes and checks short AI news on its own, but it picks images for those texts much worse. Digests with no cover, a messenger banned in Russia on a stock photo, and different images in the bot and on the site. The takeaway: text can be run through a list of checks, while for images I wrote bans into the script instead of taste.

Five pages of stock photos in a row, and not a single shot that would fit the text.

This is about my automation: a Python script collects short news about artificial intelligence and posts it to a Telegram channel on a schedule. The script writes and checks the text itself. But it picks the image for that text noticeably worse than it writes.

How the script looks for photos

The script takes photos from two stocks: Pexels and Pixabay.

It writes three queries and looks through up to five pages of Pexels results. Then the model decides whether a shot fits the text or not.

Often none of them fit. In the log from October 19, for the query "flood water street" five pages in a row were all rejected.

The text gets checked too, and by a list. Before sending, the script runs it through three checks: junk characters, a humanizer (a score for whether the writing sounds human) and a Russian language checklist of 18 markers.

Digests with no cover

On October 8 and 9 the digests went out to the channel with no cover image.

Since October 10 I have a rule: a post without an image never goes out. If no photo was found, the script does not publish and sends an alert, a short notification about the failure.

An empty slot makes more sense to me than a post that looks unfinished.

A brand that should not be in the frame

On October 18 the model picked a stock photo for the description "smartphone screen with a privacy policy". On the screen there was a messenger that is banned in Russia.

Neither the humanizer nor the checklist catches that: they are about words, not about what you can see in the shot.

Now photo descriptions are filtered against a list of brands. Instead of taste, a hard ban: cross out whatever should not be in the frame.

One image in two places

The same day a simpler bug showed up. For the blog I approve every article by hand: it arrives in a Telegram bot with buttons and goes to the site only after I press a button.

The cover in the bot was picked separately from the image on the site. I was looking at one picture, and a different one went to the site. Two articles had no image at all.

Now the cover in the bot is taken from the image field of the article itself. I look at what will actually go out.

What I took away from this

Text breaks down into markers, and you can run it through a list. With images that does not work yet: whether a shot fits is decided by the human eye.

What I wrote into the script is not taste but bans: do not publish without a photo, do not let brands from the list through, and show the image that will actually go out when I approve it.

Questions on the topic

Where does the script get photos and how does it pick them?

Photos come from two stocks: Pexels and Pixabay. The script writes three queries, looks through up to five pages of Pexels results, and then the model decides whether a shot fits the text or not.

What happens if no suitable photo is found?

Since October 10 a post without an image never goes out: the script skips publishing and sends an alert, a short notification about the failure.

Why did the text checks miss the banned brand on the photo?

Neither the humanizer nor the checklist catches that, because they are about words, not about what you can see in the shot. Now photo descriptions are filtered against a list of brands.

Andrey Atmorsky

Digital concierge, Second Sun

THE FIRST CALL IS FREE

book a call

Second Sun services

Get in touch

The first call is free, 30 minutes.

Message on Telegram
Telegram
@mderth
Instagram*
@atmorskis

Owned by Meta, which is designated an extremist organization and banned in Russia.

157A Pobedy Ave, Kaliningrad
Mon–Fri: 8:00–18:00

Send a request

Discuss your task