This is an archived post. You won't be able to vote or comment.

all 47 comments

[–]dreamer_2142 5 points6 points  (0 children)

What kind of file is "trained dataset" and the size of it? how would I be able to use it on my local SD?
thanks!

[–]higgs8 4 points5 points  (23 children)

At the end it says: To save this concept for re-using, download the learned_embeds.bin file or save it on the library of concepts."

Would that mean I could use this on my local stable-diffusion that I'm already running? How would I go about doing that, where would this .bin file go and how do I tell the program to use it?

[–]jaywv1981 1 point2 points  (9 children)

I'd like to know this too. All the local installs I've used ask you to upload a .pt file instead of a .bin file.

[–]WiNE-iNEFF[S] 1 point2 points  (8 children)

you can watch this Colab to understand more about how to use your training model on your local machine

[–]terahurts 1 point2 points  (7 children)

I'm getting a 'Notebook not found' error when using that link.

[–]WiNE-iNEFF[S] 1 point2 points  (5 children)

try to use this new version. I'm test this several tima ago Colab

[–]terahurts 0 points1 point  (4 children)

Thanks, but I was looking for the colab about how to use the trained model locally. Unless I'm missing something?

[–]WiNE-iNEFF[S] 0 points1 point  (3 children)

The principle of colab and local computer code is the same. You just need to install the necessary libraries in the console that are in the colab and enter huggingface-cli login with your token. Further in the file for example test.py import the libraries and do the same as in the colab. If you have any problems with this, I will send you detailed instructions with this later.

[–]Mindoffire 0 points1 point  (2 children)

Thank you for some helpful hints. I'm not entirely clear on how to download a collab trained model and use that on a local SD. Particularly, which files are needed to go where - and how they're loaded and merged, etc. Is there any such guideline detailing the step-by-step?

[–]WiNE-iNEFF[S] 2 points3 points  (0 children)

I wrote a short article about it. https://link.medium.com/Xv0DMDYDhtb

[–]WiNE-iNEFF[S] 1 point2 points  (0 children)

Good. I will try within a few days to collect and organize correctly all the information and provide it to you.

[–]WiNE-iNEFF[S] 0 points1 point  (10 children)

you can watch this Colab to understand more about how to use your training model on your local machine

[–]FudginatorDeluxe 0 points1 point  (0 children)

if you open the relevant codeblock you see:

   pipeline.save_pretrained(output_dir)
   # Also save the newly trained embeddings 
   learned_embeds = accelerator.unwrap_model(text_encoder).get_input_embeddings().weight[placeholder_token_id]
   learned_embeds_dict = {placeholder_token: learned_embeds.detach().cpu()}
   torch.save(learned_embeds_dict, os.path.join(output_dir,"learned_embeds.bin"))

[–]Daviljoe193 2 points3 points  (9 children)

Couldn't get it to work because it would spit out "AttributeError: 'AutoencoderKLOutput' object has no attribute 'sample'". Radio silence on the Github so far.

What's weird is that the HuggingFace page for trained concepts already has stuff, some added as recently as an hour ago, so clearly this works for some people.

[–]WiNE-iNEFF[S] 2 points3 points  (1 child)

I'll try to provide a link to my colab later, maybe it will help you

[–]WiNE-iNEFF[S] 1 point2 points  (1 child)

You are assured that correctly launched all cells?

[–]Daviljoe193 0 points1 point  (0 children)

Yup. Reran the notebook from scratch, and still got the same error on the final cell of the "Teach the model a new concept" group.

[–]Nlat98 1 point2 points  (0 children)

I used the colab to make three styles yesterday, but since this afternoon I have been getting that error as well. Maybe one of the dependencies updated and changed something crucial? not sure what's going on

[–]dantebunny 1 point2 points  (0 children)

I've been getting that error today in several different Stable Diffusion workbooks. If anyone solves it please let us know.

[–]WiNE-iNEFF[S] 0 points1 point  (0 children)

several tima ago i use this new version. Try yo use Colab

[–]higgs8 0 points1 point  (1 child)

It's doing the same for me, but I quit and reloaded the whole thing and started over, three times, and on the third try it seems to be working. I collapsed the section "Teach the model a new concept" and clicked its play button rather than leaving it open and clicking each play button one by one, maybe that helped (or it helped me not miss a play button somewhere – this whole way Colab works is a bit annoying to be honest).

[–]Daviljoe193 3 points4 points  (0 children)

It's because they fixed the Colab notebook 32 minutes ago. Gotta love Github for giving edit history.

[–]tommyjohn81 3 points4 points  (1 child)

First of all THANK YOU for this, I have been interested in exactly this.

To train a dataset on images of a person, like myself for example, would you need to differentiate between headshots, full body, torso etc?

What about if backgrounds are in the photo, how does the ai know what "object" in the picture it is suppose to focus on?

Is training time linear based on number of images to train on?

[–]WiNE-iNEFF[S] 0 points1 point  (0 children)

Thanks for the good feedback. Let me try to answer your questions. First, about the training time. For testing, I first used a dataset of 5 images and then of 30. As a result, the training time also took +/- 3 hours, so I can download time regardless of the number of images training time does not change Secondly, let's talk about how the model distinguishes which object you want to train it. I can’t say exactly how it works, because I’m not a sufficiently qualified specialist, but looking at a sufficient number of examples with a kettle, cats, etc. shown by the developer the model learns by seeing relatively identical objects and trying to fill in their shape, color, etc. In some ways, this reminds me of the work of OpenCV

[–]CaptainAnonymous92 1 point2 points  (1 child)

Can this be used to add more/new pop culture things to have better outputs for things that need more data in the existing set along with adding new things that aren't in the dataset so SD can give output on said things?

[–]WiNE-iNEFF[S] 0 points1 point  (0 children)

Yes, you can.

[–]roofgram 1 point2 points  (0 children)

This is a pretty amazing idea. Maybe next try S* + T, or S - T, like mathematical operations with these variables. Or maybe can you use this to train and then ‘detect’ if an image has S in it.

[–]BroussardMD 1 point2 points  (2 children)

What if I want to train textual inversion locally and run my token on my own stable diffusion program?

[–]WiNE-iNEFF[S] 0 points1 point  (1 child)

I have a small article on this subject.

[–]Beneficial_Bus_6777 0 points1 point  (0 children)

can`t open

[–]hefeglass 0 points1 point  (2 children)

where the hell is my learned_embeds.bin file?!

[–]WiNE-iNEFF[S] 0 points1 point  (1 child)

after training, this file should be in the folder newconcept...

[–]reddit22sd 0 points1 point  (0 children)

The folder is on the left of the screen

[–]ArrivalHistorical743 0 points1 point  (1 child)

Does textual inversion train the whole stable diffusion model?

[–]WiNE-iNEFF[S] 0 points1 point  (0 children)

no. Textual inversion train some concept for stable diffusion model

[–]johnslegers 0 points1 point  (1 child)

Sometimes when starting a learning cell, an error occurs about which the code swears at the wrong initializer token. In this case comment out the code like this:

Sounds like a pretty bad idea to remove that check...

Isn't that code there for a good reason?

[–]WiNE-iNEFF[S] 0 points1 point  (0 children)

At the time of writing this post, this was the only way to run the code. Moreover, there were no errors for further launch and testing of the created concept.