gingivere0 / dalebot

discord bot using AI to generate images based on discord messages
11 stars 1 forks source link

Feature or help request #1

Closed Darkflo264 closed 1 year ago

Darkflo264 commented 1 year ago

Hello!

Your bot is exactely the fantastic addition i was looking for to use AUTOMATIC1111 ´s amazing SD solution.

Your bot is working quite well so far, but i would like to have the possibility to generate images with another sampler.

Is there a way to implement this parameter in a easy way as well? I would love to see a additional parameter for the bot to use like "sampler=DDIM", sampler="DPM adaptive" or something like this.

If this is not possible a easy way, i would love to get a response about how to edit the default sampler Euler a to something else in your bots .py or .json files.

I already found it in several files, but these seem like some files modified after the creation initiation and getting the "Euler a" value from something else...

I am sure you are laughing about my question, but sadly i´m neither a programmer nor do i really have experience with python.

I would be very happy if you could implement such a addition to your bot - or can at least tell me how to change it myself.

Thank you in advance and best wishes!

Darkflo264

gingivere0 commented 1 year ago

Hey Darkflo264!

My first feature request! I just pushed an update that should add what you've asked for. Pull it and give it a shot, and let me know if it works for you.

Let me know if you have any other requests as well!

Thanks!

Darkflo264 commented 1 year ago

Hey gingivere0!

update: Thank you for your response.

If not already possible, it would be great to use more then one word as prompt.

I cloned the repository again (added my token) and do still have the following problem:

[2022-10-15 16:45:31] [ERROR ] discord.client: Ignoring exception in on_message Traceback (most recent call last): File "D:\AI-Painting\Python310\lib\site-packages\discord\client.py", line 409, in _run_event await coro(*args, **kwargs) File "D:\AI-Painting\dalebot\bot.py", line 113, in on_message await postresponse(message) File "D:\AI-Painting\dalebot\bot.py", line 135, in postresponse imgdata = base64.b64decode(response.json()['data'][0][0][22:]) TypeError: unhashable type: 'slice'

Darkflo264 commented 1 year ago

UPDATE: I tried the same on my wsl2 Ubuntu. Tried both, with localhost as 127.0.0.1:7860 as well as using the --listen parameter for webui and my network-ip (after adjusting the ip-adresses in your files)

Same Problem:

2022-10-15 17:08:05 ERROR discord.client Ignoring exception in on_message Traceback (most recent call last): File "/home/flo/anaconda3/lib/python3.9/site-packages/discord/client.py", line 409, in _run_event await coro(*args, **kwargs) File "/home/flo/dalebot/bot.py", line 115, in on_message await postresponse(message) File "/home/flo/dalebot/bot.py", line 137, in postresponse imgdata = base64.b64decode(response.json()['data'][0][0][22:]) TypeError: unhashable type: 'slice'

So, your addition for the seems very nice, but there might be another problem right now. Sadly i am more or less just starting with python but doesn´t that seem like something regarding to discord and not my fucked up environment? (at least my ubuntu should be fine)

Thank you in advance!

gingivere0 commented 1 year ago

Can you post a file here called "img2imgjson.json"? And does the Stable Diffusion UI have errors whenever you send a request through the bot?

Darkflo264 commented 1 year ago

UPDATE at end:

I can not attach the file directely, so i will paste it´s content as code. I dont get errors at the Stable Diffusion UI. When i request something at the bot, as example matching to the file: !dale firetruck I can see the SD-UI creating the image in it´s console. When the bot is trying to send attach/send it to the chat the error occurs (as it seems)

Additional the command !dale help does not work as well. I did notice this before (as it was working): When do the help command, the SD UI is also creating a picture with prompt "help". So now, not even the !dale help command does work because the bot there still tries to send a picture back.

Content of my img2imgjson.json { "fn_index": 14, "data": [ "firetruck", "", "None", "None", 20, "Euler a", false, false, 1, 1, 7.0, -1.0, -1.0, 0.0, 0, 0, false, 512, 512, false, 0.7, 0, 0, "None", false, false, null, "", "Seed", "", "Nothing", "", true, true, false, [], "", "" ], "session_hash": "cucp21gbbx8" }

img2imgjson json

Error in my console (bot)

response_error

Discord:

discord

I tried it with the following command in discord for a extended generation: !dale firetruck conform=12 num=1 samples=30 res=512x512 seed=910501638 sampler=Euler

Which results in the same problem. The matching img2imgjson.json is:

{ "fn_index": 14, "data": [ "firetruck ", "", "None", "None", 30, "Euler", false, false, 1, 1, 12, 910501638, -1.0, 0.0, 0, 0, false, 512, 512, false, 0.7, 0, 0, "None", false, false, null, "", "Seed", "", "Nothing", "", true, true, false, [], "", "" ], "session_hash": "cucp21gbbx8" }

Darkflo264 commented 1 year ago

Call me a idiot about python and programming, but why do the previously shown prompts get displayed in img2imgjson.json? Isn´t this one for image-to-image? Shouldn´t my command + parameters transferred to txt2imgjson.json?

gingivere0 commented 1 year ago

I just need to change the name of the file lol, there's not a good reason. I'll fix that in a future update.

The current problem is that fn_index is 14 when it should be 13. Maybe this is a difference of linux vs window, so I've pushed an update that should work. Can you try it out and let me know what you get?

Thanks again

Darkflo264 commented 1 year ago

UPDATE: Because this might help you help me. The previous failed prompt with additional parameters created this picture:

firetruck

My set parameters were sent without problems to the SD-UI. The generation worked well without errors. It seems the Problem is to send back the generated image

I need to thank you for your time and effort! I absolutely do not have a idea about this problem. I did a git pull on both systems. img2imgjson.json in Windows after sending the command "!dale help". Only response in discord is the "recycle" emoticon and console showed same error again:

{ "fn_index": 14, "data": [ "help", "", "None", "None", 20, "Euler a", false, false, 1, 1, 7.0, -1.0, -1.0, 0.0, 0, 0, false, 512, 512, false, 0.7, 0, 0, "None", false, false, null, "", "Seed", "", "Nothing", "", true, true, false, [], "", "" ], "session_hash": "cucp21gbbx8" }

img2imgjson.json in Ubuntu after sending the command "!dale help". Only response in discord is the "recycle" emoticon and console showed same error again:

{ "fn_index": 13, "data": [ "help", "", "None", "None", 20, "Euler a", false, false, 1, 1, 7.0, -1.0, -1.0, 0.0, 0, 0, false, 512, 512, false, 0.7, 0, 0, "None", false, false, null, "", "Seed", "", "Nothing", "", true, true, false, [], "", "" ], "session_hash": "cucp21gbbx8" }

Even i do notice, the index is different between windows (14) and ubuntu (13). Both are responding in console with the same error as before.

What environment in do you use it? Does it work for you?

Of course i am using a new clone now, but as i told, before you implemented the sampler parameter, i tried myself. I managed to do it in a kind of "ugly" way. I was able to use sampler=euler or ddim. Just had problems at samplers with a space. This did work - when the shown error message (TypeError: unhashable type: 'slice') appeared and is staying.

I thought, somehow i fucked up my environment or pyhton (even if i dont know how when i am editing files in a clone of your repository?), but i am not sure about this anymore. I tried the same in different directories. I uninstalled the packages needed for your bot and even deleted the packages and reinstalled them --> same error. I used python to create a virtual environment (venv) in another directory and even drive and did repeat the installation procedure --> same error.

I tried the same on ubuntu (windows virtualized, but works well). I had the same error. Now i tried a git pull there too which worked just fine. --> same error.

I even did create a new discord bot, set the permissions again and added the new token. --> same error.

Right now, i am completely confused about this :)

Darkflo264 commented 1 year ago

I want to give a quick update. I installed a new VM using ubuntu. I installed the packages from scratch, so no old remains or broken packages. I installed pip and python. I cloned your repository. I used pip to install discord, python-dotenv, requests (already was installed), pybase64 and pillow. I used my existing bot and copied my bot-token into a new created .env file in the bot´s main-directory.

When using "python3 bot.py" the bot starts up normally, connects to its user and is able to receive normal text-messages.

startup

If i am using "!dale help" now, it is indeed exactely the same behaviour as before. At least now i can see, the bot does receive the message. But there is a Warning about beeing rate limited by Discord. See picture:

error

The matching img2imgjson.json file:

img2img

I sadly lack experience about this, but this does (after trying on a fresh install) look like a problem with my python environment. Neither on windows or on ubuntu. For me this looks like an problem with the repositorys .py or .json files, the discord package or the connection between both. I dont know about the limited rate warning from discord. but i think this is not the reason for the error. As a update: After waiting or using a vpn and trying the same thing again, the limited rate warning for discord is gone. Sadly thats the only thing which is gone.

without_warning1

For me, this does more look like there is a problem with "imgdata" or [data] as stated in the Error. As if the response fails because there´s a problem with the values in data or the base64 encoding? (sorry if i might talk nonsense here - i try to understand whats happening)

Best wishes and thank you for your effort and time! I think your bot is amazing and does have a lot of potential. Also i did not find something similar somewhere else to work with this SD-GUI.

When i can provide any info or help - tell me please.

gingivere0 commented 1 year ago

I typed up a long response to this before deciding I should update my SD-UI. After updating, I'm getting the same error as you. I'll fix this error on my end and then ping you and let you know to try another pull.

In the mean time, I've pushed an update that will generate a schema.txt on startup. Can you post that file here? You should be able to just drag and drop it into the comment box

gingivere0 commented 1 year ago

Ok, I've pushed an update that should fix your "TypeError: unhashable type: 'slice'" error. The SD-UI repository pushed an update that changed the response format, causing this issue. Pull dalebot again and give it a try

Darkflo264 commented 1 year ago

Your update is working very well! I will have a look at your changes and try to understand where the problem was. I hope it will keep stable with further updates of the SD-UI now :D

Thank you for your support! I got another feature-request, but i will open a new topic for this one.

Once again, thank you very much!

Darkflo264 commented 1 year ago

schema.txt