gyptazy

DevOps

Developer

IT Consultant

gyptazy

DevOps

Developer

IT Consultant

Blog Post

AI: Image – Generating Random but Consistent Persons

2023-07-31 AI, Stable Diffusion
AI: Image – Generating Random but Consistent Persons

Random but consistent? Sounds crazy? Maybe! As many advantages and great features AI offers, it also has certain disadvantages or even problems. While generating non recurring things, animals or persons is a perfect scenario for AI, it might get difficult when there should be some kind of special consistency. Imagine you want to take advantage of AI’s power to create a comic or an advertisement which everyone should recognise. Of course, different characters or persons in a comic regarding a specific character would be non sense. This is where AI may lack without further adjustments.

Generating Persons

Not in all cases we want to generate a fully random person with a fully different face. To generate recurring persons with AI, we might have multiple approaches when using Stable Diffusion and Co.

Approach #1 – Text to Image by Adjusting the Prompt

Generating a Female Farmer

Generating a batch of 8 portraits of a female farmer results in eight different persons. Not a single one looks familiar to another one. But the given output is still valid. Let’s see if we might get better results regarding consistent persons.

Generating a Female Celeb Farmer

To generate a recurring and consistent person we might adjust our outputs and tell the AI to use a common face of a celeb. For example we could just use the face of Emma Watson. This makes the face memorable over all output images. However, this might not be the perfect solution and might probably result in legal issues when using generated pictures for business purposes.

Generating a Merged Female Celeb Farmer

While the last outputs were leading into a too familiar and well known face we might adjust our prompts. What about merging faces? What could be the outcome of a merged face of Emma Watson and Angelina Jolie? Let’s have a look!

While the outcome is pretty fine, most pictures still lead into a too familiar face. It still looks very similar. We could now switch to a less merged model but we will always get a face which looks very familiar and well known. Therefore, we could merge further faces with less overall percentages to get a more unique face.

Generating a Female Farmer by More Prompt Details

Another approach to get a fully random but consistent person leads into defining more and more prompt details. Within this approach, we define straight brown hairs, freckles, green eyes, thin nose, full lips, smiling etc. The batch output generated very similar persons.

In general, the prompt seems to be a perfect base to work with.

Generating a Female Farmer by More & More Prompt Details

Defining more and more details could be a solution. Let’s give a last try and define more details. We might also directly define our prompts for our final results. I think a foto realistic one could be great! Therefore, we provide all other details as well as more sample rounds to get more details. Lets look at the results:

Wow, this looks real, now! And our female farmer looks on all generated photos like the same person. We could just generate more and more pictures where we would gain a higher percentage of results of the same person. We might also change the scenery, add persons or things, etc.

And suddenly, our female farmer is at the beach:

Approach #2 – Image to Image

Another approach could lead into generating several random photos like we already did within the first step.

Now, we could just take a desired picture which fits our needs mostly and use this one as our base image. With image to image work batches we can now tell the AI generate pictures with different poses, scenery and so on. Let’s pick a single one, change the background from a field to a city in the same style (keeping the bokeh effect) and remove the hat.

Pretty cool!

Approach #3 – Models

Within the last two approaches we just used generic models to create random bust consistent persons but there’s still another approach. Models! Instead of using generic models we might switch to a dedicated model regarding trained data on specific persons. While this is not really a random way we use a trained model for a specific person where this specific person could be based on something we have created on our own (mocks, sketches, or real photos). This could be for example your wife/husband – just a few pictures are already enough to create an own model and to create a new images by text to image prompts. But there’re also several public ones out in the wild.

Conclusion

Providing a detailed prompt can significantly improve the results you get from an AI language model like Stable Diffusion, ChatGPT etc.. A well-crafted prompt helps the AI understand your requirements and context better, leading to more accurate and relevant responses. Here are some tips on how to create a detailed prompt:

  1. Clear and specific question: Start with a clear and specific question that outlines what you want to know or achieve. Avoid ambiguous or open-ended queries, as they might lead to vague responses.
  2. Context: Provide relevant context or background information to help the AI understand the topic and frame its response accordingly. Context can be crucial in getting accurate and personalized answers.
  3. Examples: Including examples related to your question can aid the AI in grasping the specifics of what you are looking for. These examples can be in the form of scenarios, data, or hypothetical situations.
  4. Desired format: Indicate the format you prefer for the response. For instance, if you want a step-by-step guide, a pros and cons list, or a comparison between two options, mention it explicitly.
  5. Limitations: If applicable, inform the AI about any limitations or constraints it should consider while generating the response. This can help prevent unrealistic or impractical answers.
  6. Language style: Specify the desired tone, level of formality, or any other language style preferences that you want the AI to adhere to.
  7. Questions hierarchy: If your prompt contains multiple questions or sub-parts, consider numbering or bullet-pointing them to ensure a comprehensive response.
  8. Revision request: If the initial response isn’t quite what you’re looking for, feel free to ask for a revision or clarifications. AI models can learn from feedback, and this iterative process can lead to more accurate and refined results.
  9. Working with negativ prompts if supported (tell what you NOT want to have)

By following these guidelines, you can optimize the AI’s understanding of your requirements, leading to more detailed, relevant, and satisfactory responses. Remember that while AI can generate impressive content, it still relies on the information provided in the prompt to deliver the best output.

Taggs: