yfszzx / stable-diffusion-webui-inspiration

114 stars 23 forks source link

UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 5514: character maps to <undefined> #3

Open djkacevedo opened 1 year ago

djkacevedo commented 1 year ago

When I run the create inspiration images script with the artists.txt file, I get this:

artists
Error completing request
Arguments: ('', '', 'None', 'None', 28, 0, False, False, 1, 1, 12, -1.0, -1.0, 0, 0, 0, False, 768, 512, False, 0.7, 0, 0, 12, 0.9, 5, '0.0001', False, 'None', '', 0.1, False, 'Not set', 'Not set', 'Not set', 'Not set', 'No focus', 'None', False, '\n            <h3><strong>Combinations</strong></h3>\n            Choose a number of terms from a list, in this case we choose two artists\n            <code>{2$$artist1|artist2|artist3}</code>\n            If $$ is not provided, then 1$$ is assumed.\n            <br>\n            A range can be provided:\n            <code>{1-3$$artist1|artist2|artist3}</code>\n            In this case, a random number of artists between 1 and 3 is chosen.\n            <br/><br/>\n\n            <h3><strong>Wildcards</strong></h3>\n            <p>Available wildcards</p>\n            <ul>\n        <li>__body__</li><li>__eye_color__</li></ul>\n            <br/>\n            <code>WILDCARD_DIR: scripts/wildcards</code><br/>\n            <small>You can add more wildcards by creating a text file with one term per line and name is mywildcards.txt. Place it in scripts/wildcards. <code>__mywildcards__</code> will then become available.</small>\n        ', '', False, False, False, False, False, False, '<p style="margin-bottom:0.75em">Keyframe Format: <br>Seed | Prompt or just Prompt</p>', '', 25, True, 5.0, False, None, '', False, 4.0, '', 10.0, False, False, True, 30.0, True, False, False, 0, 10.0, True, 30.0, True, '', False, [], [], [], [], [], [], [], [], [], 1, '', 0, '', True, False, False, 4.0, 1.0, 'a painting in', 'style', 'picture frame, portrait photo', [<tempfile._TemporaryFileWrapper object at 0x000002B57E952560>]) {}
Traceback (most recent call last):
  File "D:\dev\stable-diffusion\stable-diffusion-webui\modules\ui.py", line 221, in f
    res = list(func(*args, **kwargs))
  File "D:\dev\stable-diffusion\stable-diffusion-webui\webui.py", line 63, in f
    res = func(*args, **kwargs)
  File "D:\dev\stable-diffusion\stable-diffusion-webui\modules\txt2img.py", line 45, in txt2img
    processed = modules.scripts.scripts_txt2img.run(p, *args)
  File "D:\dev\stable-diffusion\stable-diffusion-webui\modules\scripts.py", line 286, in run
    processed = script.run(p, *script_args)
  File "D:\dev\stable-diffusion\stable-diffusion-webui\extensions\stable-diffusion-webui-inspiration\scripts\inspiration.py", line 45, in run
    line = f.readline()
  File "C:\Users\user one\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 5514: character maps to <undefined>
yfszzx commented 1 year ago

what OS? have you edited the artists.txt file?

djkacevedo commented 1 year ago

Windows 11, and nope. Just downloaded the files you linked, I tried with all at once, and one at a time, and the same error.

yfszzx commented 1 year ago

Windows 11, and nope. Just downloaded the files you linked, I tried with all at once, and one at a time, and the same error.

did you download files from here ?

https://github.com/pharmapsychotic/clip-interrogator/tree/main/data

downloaded ? git clone ? or copy-paste?

djkacevedo commented 1 year ago

I cloned clip-interrogator, and then picked the files from clip-interrogator\data with the "click here to upload" button.

yfszzx commented 1 year ago

I cloned,picked files, and run the script.But I haven't encountered such problems as yours. I don't know how to reproduce this mistake.Maybe you can try updating webui?

wbecher commented 1 year ago

Windows 11, and nope. Just downloaded the files you linked, I tried with all at once, and one at a time, and the same error.

I`ve got the same error here, also on Windows 11. I've tried to clone the repository and use the files without any edit, then I tried to download the raw content of the files and got the same error. Also tried to re-save the files, forcing the UTF-8 encoding, with VSCode. Here is the log:

artists
Error completing request
Arguments: ('', '', 'None', 'None', 20, 0, False, False, 1, 1, 7, -1.0, -1.0, 0, 0, 0, False, 512, 512, False, 0.7, 0, 0, 4, 0.9, 5, '0.0001', False, 'None', '', 0.1, False, False, False, None, '', 1, '', 0, '', True, False, False, 4.0, 1.0, 'a painting in', 'style', 'picture frame, portrait photo', [<tempfile._TemporaryFileWrapper object at 0x00000228332C2170>, <tempfile._TemporaryFileWrapper object at 0x00000228332C3280>, <tempfile._TemporaryFileWrapper object at 0x00000228332C2F50>, <tempfile._TemporaryFileWrapper object at 0x00000228332C2E00>]) {}
Traceback (most recent call last):
  File "C:\stable-diffusion-automatic1111\modules\ui.py", line 221, in f
    res = list(func(*args, **kwargs))
  File "C:\stable-diffusion-automatic1111\webui.py", line 63, in f
    res = func(*args, **kwargs)
  File "C:\stable-diffusion-automatic1111\modules\txt2img.py", line 45, in txt2img
    processed = modules.scripts.scripts_txt2img.run(p, *args)
  File "C:\stable-diffusion-automatic1111\modules\scripts.py", line 286, in run
    processed = script.run(p, *script_args)
  File "C:\stable-diffusion-automatic1111\extensions\inspiration\scripts\inspiration.py", line 45, in run
    line = f.readline()
  File "C:\Program Files\Python310\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 5196: character maps to <undefined>
wbecher commented 1 year ago

I was able to solve by using UTF-8 when reading the file, made this PR: https://github.com/yfszzx/stable-diffusion-webui-inspiration/pull/7

misakitchi commented 1 year ago

I have still this error. Can you explain more how you fix it? I don't understand... :(

Edit: i used the same method from wbecher to resolve the problem

modify inspiration.py Line 73: f = open(file, "r")
f = open(file, "r", encoding='utf-8')
Line 89 with open(file, "a") as f: with open(file, "a", encoding='utf-8') as f:

Edit2: need to change line 173 too...

Artemonim commented 1 year ago

To solve a similar problem, I used this for the list of artists: