Problem/Motivation

Humans usually have images named something meaningful, and I was trying to adjust the default prompt by adding
"11. If the filename of the image is available you can use it for hints for context as to what is shown in that image."
but it doesn't seem to have any affect.

Steps to reproduce

Get an image of a house, name the file "Foreclosed-Home.jpg" or something, then if filename were working I hopefully would get something like "Single-story beige foreclosed house with a garage, blue driveway, and lush greenery."

Proposed resolution

Add filename token to be used in prompt template for more context when creating alt text.

Remaining tasks

User interface changes

I did not propose adding the token to the default prompt, but if the maintainers think it could help everyone, then I don't think it would harm the default prompts performance.

API changes

Data model changes

A new filename token.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

nicholass created an issue. See original summary.

nicholass’s picture

I wonder if the file name could also help situations like #3493133

nicholass’s picture

nicholass’s picture

StatusFileSize
new20.05 KB
nicholass’s picture

I added an image to help test this feature request. All I get back is variations like "Single-story beige house with garage, front lawn, and trees in the background."

Also tried some prompt engineering but I just don't think it has access to the filename?
11. If the filename of the image is available you can use it for hints for context as to what is shown in that image and work those words into the description.

nicholass’s picture

StatusFileSize
new2.69 MB

I experimented a lot trying to get AI to use the filename, but only luck I had was by adding a token so that I can specifically include it in our prompt template. And for the images I tested this seemed to have a very beneficial effect, so this change just adds a filename token.

Along with IMPORTANT: This image has the filename "{{ filename }}" - use keywords from this filename as strong hints about the image content and incorporate relevant context into your description. it has greatly improved our images alt text. So I feel like this shouldn't be too much of a request to add this token.

nicholass’s picture

Issue summary: View changes
nicholass’s picture

Status: Active » Needs review
marcus_johansson’s picture

Hi @nicholass - in 1.2.0 we will actually have a new module called Field Widget Actions that will make it possible to trigger any processor using a button.

The AI Automators module has an AI Image Alt Text processor, that can take any token available to generate the alt text, including the filename.

This module is meant to just be simple - install and get an 80% okish alt text - for perfect generated alt text I'm wondering if the Field Widget Action + AI Automators doesn't make more sense?

Its not 100% documented yet and I'll create some videos on it and update as soon as its done.

nicholass’s picture

I could try it if you have a guide for "Field Widget Action + AI Automators" but honestly after testing the filename token seems to be all the context I need, its good enough to get us good results and our content editors can adjust from there. Plus teaches them to name their images better which helps long term content maintenance.

marcus_johansson’s picture

We need to improve this as well - tested, code looks good so its getting merged. Thanks @nicholass.

marcus_johansson’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.