aaronfisher-code / ComfyUI-SDXL-DiscordBot

Simple Discord Bot for interfacing with ComfyUI and/or the Stability AI API for text2image generation using the SDXL model
GNU General Public License v3.0
55 stars 25 forks source link

Bot error, images not returned. #4

Closed OliPassey closed 1 year ago

OliPassey commented 1 year ago

Got the bot into my server and sent it a command, comfy kicked off generating but after 10s this error appears in the discord bot console, and nothing further happens in discord after the initial "this shouldn't take too long" msg.

Could this be a bot permissions issue do you think? Or something else

Any advice would be appreciated.

[2023-09-09 23:17:34] [ERROR   ] discord.app_commands.tree: Ignoring exception in command 'imagine'
Traceback (most recent call last):
  File "discord\app_commands\commands.py", line 828, in _do_call
  File "bot.py", line 148, in slash_command
  File "imageGen.py", line 116, in generate_images
  File "imageGen.py", line 68, in get_images
  File "json\__init__.py", line 341, in loads
  File "encodings\utf_32_be.py", line 11, in decode
UnicodeDecodeError: 'utf-32-be' codec can't decode bytes in position 8-11: code point not in range(0x110000)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "discord\app_commands\tree.py", line 1248, in _call
  File "discord\app_commands\commands.py", line 853, in _invoke_with_namespace
  File "discord\app_commands\commands.py", line 846, in _do_call
discord.app_commands.errors.CommandInvokeError: Command 'imagine' raised an exception: UnicodeDecodeError: 'utf-32-be' codec can't decode bytes in position 8-11: code point not in range(0x110000)
erroneousau commented 1 year ago

I had the exact same issue, I am running the python code instead of using the exe so I could edit the files. I'm assuming comfy is returning a preview of the image as it is generating which isn't JSON. I edited the imageGen.py file at line 67 and replaced the block with the following.

async for out in self.ws:
            try:
                message = json.loads(out)
                if message['type'] == 'execution_start':
                    currently_Executing_Prompt = message['data']['prompt_id']
                if message['type'] == 'executing' and prompt_id == currently_Executing_Prompt:
                    data = message['data']
                    if data['node'] is None and data['prompt_id'] == prompt_id:
                        break
            except ValueError as e:
                print("not json");

it now prints the not json message in command prompt but will generate the image and send it back to discord. Hope that helps.

OliPassey commented 1 year ago

Amazing, thanks!

I made the change but am having issues installing the various requirements. Which version of python are you using, and did you use a venv?

Looks like im missing websockets library, as when i run bot.py it doesn't give the usual output and just quits. pip install -r requirements.txt gave a couple of errors; image

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. google-auth 2.22.0 requires urllib3<2.0, but you have urllib3 2.0.4 which is incompatible.

I tried pip uninstall urllib3 then re-running the pip -r requirements.txt but this brings back the same version issue.

aaronfisher-code commented 1 year ago

Hey guys, thanks for pointing this one out!

I've made a new release now here with the changes suggested by @erroneousau let me know if it all works as intended and Ill close up this issue

OliPassey commented 1 year ago

Thanks for this! The bot now works and returns 4x complete images to the discord server, however during generation no previews were sent and the bot console repeatedly printed; image

Trying to upscale one of the images caused this in the comfyui console; image And no upscaled image was created.

Just providing this as feedback, really appreciate your work on this!

aaronfisher-code commented 1 year ago

So currently the bot doesn't support running image previews, (might be something I implement later on) as for the upscaling issue however, have you double checked you have the RealESRGAN_x2plus.pth model in your upscale_models folder in ComfyUI it seems as though its reading that it cant locate the model

The model can be downloaded here if you haven't got it yet: https://github.com/xinntao/Real-ESRGAN/releases/download/v0.2.1/RealESRGAN_x2plus.pth

OliPassey commented 1 year ago

ah, i didn't have the plus version - thanks, thats working fine now. Really appreciate your assistance 👍