How does the extract method from ImagePlaygroundConcept work?

I’m building an app that generates images based on text input from a specific text field. However, I’m encountering a problem:

For short prompts like "a cat and a dog", the entire string is sent to the Image Playground, even when I use the extracted method. For longer inputs, the behavior is inconsistent. Sometimes it extracts keywords correctly, but other times it doesn’t extract anything at all.

Since my app relies on generating images based on the extracted keywords, this inconsistency negatively impacts the user experience in my app. How can I make sure that keywords are always extracted from the input string?

                        Button("Generate", systemImage: "apple.intelligence") {
                            isPresented = true
                        }
                        .imagePlaygroundSheet(isPresented: $isPresented, concepts: [ImagePlaygroundConcept.extracted(from: text, title: textTitle)]) { url in
                            imageURL = url
                        }
Answered by DTS Engineer in 823619022

According to extracted(from:title:) the available inputs are:

text
Suitable for long strings, like paragraphs or entire documents.
The system will try to extract important or interesting concepts from the string and add them to the playground, so that each concept becomes an input prompt to the diffusion models.
However, if the string does not meet the minimum length required for concept extraction, it might decide to use the string as-is as input prompt.

title
Helps guiding the extraction of concepts from text by providing a summary of the contents of text.

That said, it seems you'll want to focus on clear(er) concepts in text rather than specific keyword discovery in order to improve results.

The other heuristic under your control is a title intended to summarize the concepts in text. Are your titles fulfilling that need?

According to extracted(from:title:) the available inputs are:

text
Suitable for long strings, like paragraphs or entire documents.
The system will try to extract important or interesting concepts from the string and add them to the playground, so that each concept becomes an input prompt to the diffusion models.
However, if the string does not meet the minimum length required for concept extraction, it might decide to use the string as-is as input prompt.

title
Helps guiding the extraction of concepts from text by providing a summary of the contents of text.

That said, it seems you'll want to focus on clear(er) concepts in text rather than specific keyword discovery in order to improve results.

The other heuristic under your control is a title intended to summarize the concepts in text. Are your titles fulfilling that need?

How does the extract method from ImagePlaygroundConcept work?
 
 
Q