Greetings, I’m working on my first t2i generator, and I’m in need of a little assistance.

I want to output 4 images with 4 different attributes for one of the prompt terms. Let’s say shirt color. I understand that I could easily create 4 different outputs, but that would mean duplicating the whole prompt 4 times. I’d rather have it be more concise using one output and dynamically change on reload (with no duplicates).

A consumable list seems like what I would need, but it seems like this still requires 2 outputs?

This works, and outputs my 4 colors correctly with no dupes:

output1
  [c = shirtcolor.consumableList]
output2
  [c]

HTML:

[output1]
[output2]
[output2]
[output2]

I’d prefer it if I could get this to work with just one output. Thanks for any help or tips!

2 points

I’m not 100% sure if this answers your question, but:

Lists:

output
  [c = shirtcolor.consumableList, ""][prompt.selectMany(4).joinItems(", ")]

prompt
  a person wearing a [c] shirt

HTML:

[output]

And you can write [prompt], [prompt], [prompt], [prompt] instead of [prompt.selectMany(4).joinItems(", ")] if you want.

If you desperately want to squash it all into a single output list, you can do this:

output
  [c = shirtcolor.consumableList, ""]["a person wearing a [c] shirt".selectMany(4).joinItems(", ")]

But that’s probably not a great idea. Hopefully that helps! Let me know if not.

permalink
report
reply
1 point

@perchance@lemmy.world Thanks for the reply! Much appreciated. 👍

Hmm… maybe I didn’t explain properly. I tried your code and got weird results. Your output/prompt is concatenating the color list… which I don’t want.

I’m basically trying to output 4 images with DIFFERENT prompts using ONE output. Here is my (almost) working generator: https://perchance.org/zh7u0fwp8q

As you can see, when randomizing, EACH of the outputs correctly outputs a distinct ethnicity and a distinct shirt color - with no duplicates.

It’s almost perfect, but it’s still using 2 prompts/outputs (because the consumable list seems to require it) which I think will be a problem if/when I set up a user input for the prompt.

I’m basically just trying to insert a single list item into the prompt… but don’t want duplicates in the output which is why I thought consumable list was the way to do it. Is there some way to get/store the list items BEFORE inserting them into the prompt?

permalink
report
parent
reply
3 points

Try this snippet:

output
  [e = ethnicity.consumableList, c = shirtColor.consumableList, ''] [new Array(4).fill(0).map(a => `<div>${t2i(prompt)}<br>${lastTextToImagePrompt}</div>`).joinItems("")]

prompt
  prompt = [bodyType] [e] Woman wearing a [c] shirt
  resolution = 512x768
  guidanceScale = 5

First we instantiate the consumable lists. Then, we create an Array with the size of the length of the consumable list (to prevent no more items), we then fill it with default items first, then map the items by changing them to host the t2i outputs then join them.

permalink
report
parent
reply
1 point

Wow! That looks perfect… This will also allow me to easily add use user inputs, and add the prompt parameters all in one place.

Thanks so much for the help!

I’ll be sure to post again if I run into any trouble. 🙂

permalink
report
parent
reply
2 points

I may still be misunderstanding, but maybe this is what you want?

init
  [e = ethnicity.consumableList, c = shirtColor.consumableList, ""]

And then at the top of your HTML:

[init]

A fork of your example with those changes: https://perchance.org/ynkght2sbg#edit

permalink
report
parent
reply
1 point

This is even better. And much cleaner. Absolutely perfect.

Initiating the list is definitely the way to go over outputting an array.

Thanks ever SO much!!

😲 🤓

permalink
report
parent
reply

Perchance - Create a Random Text Generator

!perchance@lemmy.world

Create post

⚄︎ Perchance

This is a Lemmy Community for perchance.org, a platform for sharing and creating random text generators.

Feel free to ask for help, share your generators, and start friendly discussions at your leisure :)

This community is mainly for discussions between those who are building generators. For discussions about using generators, especially the popular AI ones, the community-led Casual Perchance forum is likely a more appropriate venue.

See this post for the Complete Guide to Posting Here on the Community!

Rules

1. Please follow the Lemmy.World instance rules.
2. Be kind and friendly.
  • Please be kind to others on this community (and also in general), and remember that for many people Perchance is their first experience with coding. We have members for whom English is not their first language, so please be take that into account too :)
3. Be thankful to those who try to help you.
  • If you ask a question and someone has made a effort to help you out, please remember to be thankful! Even if they don’t manage to help you solve your problem - remember that they’re spending time out of their day to try to help a stranger :)
4. Only post about stuff related to perchance.
  • Please only post about perchance related stuff like generators on it, bugs, and the site.
5. Refrain from requesting Prompts for the AI Tools.
  • We would like to ask to refrain from posting here needing help specifically with prompting/achieving certain results with the AI plugins (text-to-image-plugin and ai-text-plugin) e.g. “What is the good prompt for X?”, “How to achieve X with Y generator?”
  • See Perchance AI FAQ for FAQ about the AI tools.
  • You can ask for help with prompting at the ‘sister’ community Casual Perchance, which is for more casual discussions.
  • We will still be helping/answering questions about the plugins as long as it is related to building generators with them.
6. Search through the Community Before Posting.
  • Please Search through the Community Posts here (and on Reddit) before posting to see if what you will post has similar post/already been posted.

Community stats

  • 103

    Monthly active users

  • 671

    Posts

  • 2.6K

    Comments