Giter Site home page Giter Site logo

Comments (9)

vasimr avatar vasimr commented on April 28, 2024 1

I had a chance to try the corrected repo, and everything works without issue. I also tested using multiple embeddings, which seems to work quite well (the embedding mapping is poor, but both seem to be contributing to generation).

from stable-diffusion-webui.

AUTOMATIC1111 avatar AUTOMATIC1111 commented on April 28, 2024

Which repository are you using for Stable Diffusion?

from stable-diffusion-webui.

vasimr avatar vasimr commented on April 28, 2024

This one, as per the linked guide in your readme. https://github.com/hlky/stable-diffusion
I then copied your webui.py script into the main directory, and added an embeddings sub-directory.

from stable-diffusion-webui.

AUTOMATIC1111 avatar AUTOMATIC1111 commented on April 28, 2024

I just cloned it and tested my embedding in it, works perfectly. What embedding are you using? Also post the full error message, maybe that will help.

from stable-diffusion-webui.

vasimr avatar vasimr commented on April 28, 2024

I am using a custom embedding trained from textual inversion. I can give the one you posted a try as well in the event that there's something off with the file itself (though they two look very similar).
Is it possible that there's some environmental issue? I am using anaconda (not miniconda), a new environment ("ldo" instead of "ldm"), and I changed the lightning version to 1.5.0 as per another guide with vanilla SD.

Here's the full trace, though I had to redact some of the paths.

To create a public link, set `share=True` in `launch()`.
Loaded a total of 1 text inversion embeddings.
Traceback (most recent call last):
  File "<profile>\anaconda3\envs\ldo\lib\site-packages\gradio\routes.py", line 247, in run_predict
    output = await app.blocks.process_api(
  File "<profile>\anaconda3\envs\ldo\lib\site-packages\gradio\blocks.py", line 641, in process_api
    predictions, duration = await self.call_function(fn_index, processed_input)
  File "<profile>\anaconda3\envs\ldo\lib\site-packages\gradio\blocks.py", line 554, in call_function
    prediction = await block_fn.fn(*processed_input)
  File "<profile>\anaconda3\envs\ldo\lib\site-packages\gradio\interface.py", line 651, in submit_func
    prediction = await self.run_prediction(args)
  File "<profile>\anaconda3\envs\ldo\lib\site-packages\gradio\interface.py", line 680, in run_prediction
    prediction = await anyio.to_thread.run_sync(
  File "<profile>\anaconda3\envs\ldo\lib\site-packages\anyio\to_thread.py", line 31, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(
  File "<profile>\anaconda3\envs\ldo\lib\site-packages\anyio\_backends\_asyncio.py", line 937, in run_sync_in_worker_thread
    return await future
  File "<profile>\anaconda3\envs\ldo\lib\site-packages\anyio\_backends\_asyncio.py", line 867, in run
    result = context.run(func, *args)
  File "webui.py", line 378, in f
    res = list(func(*p1, **p2))
  File "webui.py", line 677, in txt2img
    output_images, seed, info = process_images(
  File "webui.py", line 613, in process_images
    uc = model.get_learned_conditioning(len(prompts) * [""])
  File "F:\webSD\stable-diffusion-main\ldm\models\diffusion\ddpm.py", line 594, in get_learned_conditioning
    c = self.cond_stage_model(c)
  File "<profile>\anaconda3\envs\ldo\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl
    return forward_call(*input, **kwargs)
  File "webui.py", line 516, in forward
    z = outputs.last_hidden_state
AttributeError: 'Tensor' object has no attribute 'last_hidden_state'

from stable-diffusion-webui.

AUTOMATIC1111 avatar AUTOMATIC1111 commented on April 28, 2024

Can you add three lines to you webui.py around line 516 so that it looks like this:

        tokens = torch.asarray(remade_batch_tokens).to(self.wrapped.device)
        print(type(self.wrapped))
        print(type(self.wrapped.transformer))
        outputs = self.wrapped.transformer(input_ids=tokens)
        print(type(outputs))
        z = outputs.last_hidden_state
        return z

And report what's printed in the command line?

from stable-diffusion-webui.

vasimr avatar vasimr commented on April 28, 2024

Sure, but it might have to wait until tomorrow. I am currently doing a very slow embedding training and textual inversion currently has no way to restart from a checkpoint.
Also, if it helps, using an embedding with the other webui.py (from the repo I mentioned above) seems to work without issue, though it only supports a single embedding file, and your method for ensuring that the embedding is used makes far more sense to me.
I will post the printout when I get a chance to run it.

from stable-diffusion-webui.

AUTOMATIC1111 avatar AUTOMATIC1111 commented on April 28, 2024
  File "F:\webSD\stable-diffusion-main\ldm\models\diffusion\ddpm.py", line 594, in get_learned_conditioning
    c = self.cond_stage_model(c)

Here's line 594 of that file in the repo you linked:
https://github.com/hlky/stable-diffusion/blob/main/ldm/models/diffusion/ddpm.py#L594

Line with c = self.cond_stage_model(c) from the stack is:
https://github.com/hlky/stable-diffusion/blob/main/ldm/models/diffusion/ddpm.py#L558

Looks to me like you have a different repo.

from stable-diffusion-webui.

vasimr avatar vasimr commented on April 28, 2024

I think I see what happened now...
Those files differ because they were replaced by https://github.com/hlky/sd-enable-textual-inversion
The original repo that I linked pointed to the sd-enable-textual-inversion repo to enable embeddings. However, your solution likely conflicts with the modification there, which could be causing the issue.

Given that you verified your method working with the first repo link (without the sd-enable update), I will first create a clean repo without it, and try your webui.py implementation. If that still crashes, then I will add the printouts and reply with the result.
I am going to keep the same ldo environment though, which was not modified by adding the sd-enable fix.

from stable-diffusion-webui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.