Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Web Mode not working 'NoneType' object is not callable #799

Closed
eren-ay opened this issue Dec 22, 2024 · 55 comments · Fixed by #800
Closed

[Bug]: Web Mode not working 'NoneType' object is not callable #799

eren-ay opened this issue Dec 22, 2024 · 55 comments · Fixed by #800
Labels
bug Something isn't working

Comments

@eren-ay
Copy link

eren-ay commented Dec 22, 2024

Issue

notify function never returns 0

Command Line Arguments

No response

Console logs

def notify(code: int, data: bytes, transform_to_bytes, messages: asyncio.Queue):
    if code == 0:
        result_bytes = transform_to_bytes(pickle.loads(data))
        encoded_result = b'\x00' + len(result_bytes).to_bytes(4, 'big') + result_bytes
        messages.put_nowait(encoded_result)
    else:
        encoded_result =code.to_bytes(1, 'big') + len(data).to_bytes(4, 'big') + data
        messages.put_nowait(encoded_result)
@eren-ay eren-ay added the bug Something isn't working label Dec 22, 2024
@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

my real problem it was never working code == 0 .
There is nothing that satisfies this condition.

because of it the image never loads in web mode and constantly gives a nonetype error.
'NoneType' object is not callable

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

I thought this was the part that caused this error, maybe it could be something else, I'm not sure.
local mode works without any problems.
When I switched to Windows, I first got the Error: 'charmap' codec can't encode characters in position 25-26: character maps to error, but I solved it by running Python as utf-8, but I could not solve this nonetype error.

I was running it in Linux without using stream and it was working. In Windows, it does not work in normal mode or stream mode. I also tried it in the manual section via web mode, not as API, but it did not work.

@eren-ay eren-ay changed the title [Bug]: Web Mode not working with stream [Bug]: Web Mode not working 'NoneType' object is not callable Dec 22, 2024
@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

@frederik-uni can you help please. i

@frederik-uni
Copy link
Contributor

@eren-ay
code should come from the server & on success the first byte is this: b'\x00' equals 0. this code is working as it worked with the demo images. It would be great if I could get the actual stack trace.

for explanation. code == 0 is a context dump, code > 0 are strings like progress & error.

the pattern in which it is encoded is 1 byte status code, 4 bytes data chunk size, n bytes data. could you tell me which variable is of type NoneType?

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

import asyncio
import pickle

async def stream(messages):
while True:
message = await messages.get()
yield message
if message[0] == 0 or message[0] == 2:
if message[0] == 2:
print("always break with 2")
break

def notify(code: int, data: bytes, transform_to_bytes, messages: asyncio.Queue) -> bytes:
if code == 0:
print("not working")
result_bytes = transform_to_bytes(pickle.loads(data))
encoded_result = b'\x00' + len(result_bytes).to_bytes(4, 'big') + result_bytes
messages.put_nowait(encoded_result)
else:
encoded_result =code.to_bytes(1, 'big') + len(data).to_bytes(4, 'big') + data
messages.put_nowait(encoded_result)

my commandline is:
python server/main.py --port 8000 --use-gpu
Nonce:
INFO: Started server process [22664]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
[shared] Running in shared mode
INFO: Started server process [5252]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8001 (Press CTRL+C to quit)
INFO: 127.0.0.1:51124 - "POST /translate/with-form/json/stream HTTP/1.1" 200 OK
[shared] Loading models
[shared] Running text detection
INFO: 127.0.0.1:51125 - "POST /execute/translate HTTP/1.1" 200 OK
[DefaultDetector] Detection resolution: 1536x1536
[shared] Running ocr
[Model48pxOCR] prob: 0.9996090531349182 私、 fg: (0, 0, 0) bg: (0, 0, 0)
[Model48pxOCR] prob: 0.9739822149276733 ひっ‼ fg: (0, 1, 1) bg: (0, 1, 1)
[Model48pxOCR] prob: 0.9898279309272766 違うっ! fg: (0, 0, 0) bg: (0, 0, 0)
[Model48pxOCR] prob: 0.982326328754425 しない‼ fg: (0, 1, 0) bg: (0, 1, 0)
[Model48pxOCR] prob: 0.9995996952056885 普通の人は fg: (0, 0, 0) bg: (0, 0, 0)
[Model48pxOCR] prob: 0.9110857248306274 読みません‼ fg: (0, 0, 0) bg: (0, 0, 0)
[Model48pxOCR] prob: 0.9665096998214722 あぶないっ‼ fg: (3, 3, 1) bg: (3, 3, 1)
[Model48pxOCR] prob: 0.9998820424079895 まんがなんて fg: (0, 0, 0) bg: (0, 0, 0)
[Model48pxOCR] prob: 0.9999647736549377 そん fg: (0, 0, 0) bg: (0, 0, 0)
[shared] No pre-translation replacements made.
[shared] Running text translation
[SugoiTranslator] Translating into English
[SugoiTranslator] 0: あぶないっ‼ => Watch out!!
[SugoiTranslator] 1: ひっ‼ => Eek!!
[SugoiTranslator] 2: 違うっ! => That's not it!
[SugoiTranslator] 3: 普通の人はそんしない‼ => Normal people wouldn't do that!!
[SugoiTranslator] 4: 私、まんがなんて読みません‼ => I don't read buns!!
[shared] No post-translation replacements made.
[shared] Running mask refinement
[mask]: 100%|███████████████████████████████████████████████████████████████████████| 9/9 [00:00<00:00, 818.12it/s]
[shared] Running rendering
[render]: 100%|██████████████████████████████████████████████████████████████████████| 5/5 [00:04<00:00, 1.11it/s]
always break with 2
webpageimage

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

Which one did you say was nonetype? When I looked before, the last value is ​​nonetype. value length is 5

@frederik-uni
Copy link
Contributor

the issue isn't with the server.
from share.py

try:
            if asyncio.iscoroutinefunction(method):
                result = await method(**attributes)
            else:
                result = method(**attributes)
            result_bytes = pickle.dumps(result)
            encoded_result = b'\x00' + len(result_bytes).to_bytes(4, 'big') + result_bytes
            await self.progress_queue.put(encoded_result)
        except Exception as e:
            err_bytes = str(e).encode("utf-8")
            encoded_result = b'\x02' + len(err_bytes).to_bytes(4, 'big') + err_bytes
            await self.progress_queue.put(encoded_result)
        finally:
            self.lock.release()

this is the error handling from the server. the translate function failed to translate was caught and was returned as an error

@frederik-uni
Copy link
Contributor

for more information modify the encoding manga_translator/mode/share.py:71 to go into more detail to debug the actual issue.

@frederik-uni
Copy link
Contributor

you could also log method, **attributes in line 62 to verify that this is correct & matches the shape it should have

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

this problem with the utf-8. I ran Python with utf-8

the problem used to be: Error: 'charmap' codec can't encode characters in position 25-26: character maps to error

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

and you r right it was the line run method exception: line 61
encoded result is from the exception: b"\x02\x00\x00\x00!'NoneType' object is not callable" excepstion is: 'NoneType' object is not callable

@frederik-uni
Copy link
Contributor

frederik-uni commented Dec 22, 2024

everything after 61 and the line

l61: async def run_method(self, method, **attributes):
        try:
            # im pretty sure it reaches here
            # print(method, attributes)
            if asyncio.iscoroutinefunction(method):
                result = await method(**attributes)
            else:
                result = method(**attributes)
            # does it reach here? if not translate failed. checkout what the server logged for method & attributes
            result_bytes = pickle.dumps(result)
            # if it fails here, than the translate function did not return anything. None is the default return type. if it failed at line result_bytes = pickle.dumps(result) than there is an issue with the translate function where it returns nothing instead of a context
            encoded_result = b'\x00' + len(result_bytes).to_bytes(4, 'big') + result_bytes
            await self.progress_queue.put(encoded_result)
        except Exception as e:
            err_bytes = str(e).encode("utf-8")

            encoded_result = b'\x02' + len(err_bytes).to_bytes(4, 'big') + err_bytes
            await self.progress_queue.put(encoded_result)
        finally:
            self.lock.release()

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

result_bytes = pickle.dumps(result)
issue is here

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

Is this problem only with me? I reinstalled it, I'm running it from the manual section in the url without any changes, I don't understand why it happened.

@frederik-uni
Copy link
Contributor

the issue is with line 173 actually in the function _translate(config, ctx) in manga_translator.py
line 173 looks like this: return await self._translate(config, ctx) _translate(config, ctx) should return ctx. it returns None. this can be fixed by

self._translate(config, ctx)
return ctx;

This should work, but is not fixing the underlying issue that _translate(config, ctx) should return ctx but is not.

@frederik-uni
Copy link
Contributor

@eren-ay someone prob made a change. I am not running on the latest version & there might be some special cases where the function does not execute to the end where it is returned, but stops midway and returns nothing.

@frederik-uni
Copy link
Contributor

oh wait can you print the result before it is dumped?

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

yes
[shared] Running text translation
[SugoiTranslator] Translating into English
[SugoiTranslator] 0: あぶないっ‼ => Watch out!!
[SugoiTranslator] 1: ひっ‼ => Eek!!
[SugoiTranslator] 2: 違うっ! => That's not it!
[SugoiTranslator] 3: 普通の人はそんしない‼ => Normal people wouldn't do that!!
[SugoiTranslator] 4: 私、まんがなんて読みません‼ => I don't read buns!!
[shared] No post-translation replacements made.
[shared] Running mask refinement
[mask]: 100%|███████████████████████████████████████████████████████████████████████| 9/9 [00:00<00:00, 818.37it/s]
[shared] Running rendering
[render]: 100%|██████████████████████████████████████████████████████████████████████| 5/5 [00:02<00:00, 1.82it/s]
encoded result is from the exception: b"\x02\x00\x00\x00!'NoneType' object is not callable" excepstion is: 'NoneType' object is not callable
always break with 2

@frederik-uni
Copy link
Contributor

this is probably the issue.

ray-project/ray#9098

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

and this solution not worked if i don't use await it gives error

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

wait i'm looking

@frederik-uni
Copy link
Contributor

could you add a print(result) above result_bytes = pickle.dumps(result)

@frederik-uni
Copy link
Contributor

would help quite a bit what it tries to dump to pinpoint the data that causes the error

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

Context(input=<PIL.PngImagePlugin.PngImageFile image mode=P size=533x464 at 0x264CB02E170>, result=<PIL.Image.Image image mode=RGBA size=533x464 at 0x264CB943C40>, img_colorized=<PIL.PngImagePlugin.PngImageFile image mode=P size=533x464 at 0x264CB02E170>, upscaled=<PIL.PngImagePlugin.PngImageFile image mode=P size=533x464 at 0x264CB02E170>, img_rgb=array([[[255, 255, 255],
[255, 255, 255],
[255, 255, 255],
...,
[255, 255, 255],
[255, 255, 255],
[255, 255, 255]],

   [[255, 255, 255],
    [255, 255, 255],
    [207, 207, 207],
    ...,
    [ 97,  97,  97],
    [ 97,  97,  97],
    [141, 141, 141]],

   [[255, 255, 255],
    [234, 234, 234],
    [ 97,  97,  97],
    ...,
    [255, 255, 255],
    [141, 141, 141],
    [ 97,  97,  97]],

   ...,

   [[255, 255, 255],
    [141, 141, 141],
    [141, 141, 141],
    ...,
    [ 50,  50,  50],
    [ 50,  50,  50],
    [141, 141, 141]],

   [[255, 255, 255],
    [177, 177, 177],
    [ 50,  50,  50],
    ...,
    [234, 234, 234],
    [234, 234, 234],
    [255, 255, 255]],

   [[255, 255, 255],
    [255, 255, 255],
    [207, 207, 207],
    ...,
    [255, 255, 255],
    [255, 255, 255],
    [255, 255, 255]]], dtype=uint8), img_alpha=<PIL.Image.Image image mode=L size=533x464 at 0x264CB943C70>, textlines=[<manga_translator.utils.generic.Quadrilateral object at 0x00000264CD0A8160>, <manga_translator.utils.generic.Quadrilateral object at 0x00000264CD0A8C10>, <manga_translator.utils.generic.Quadrilateral object at 0x00000264CD0A8CD0>, <manga_translator.utils.generic.Quadrilateral object at 0x00000264CD0A8B20>, <manga_translator.utils.generic.Quadrilateral object at 0x00000264CD0A8910>, <manga_translator.utils.generic.Quadrilateral object at 0x00000264CD0A8D30>, <manga_translator.utils.generic.Quadrilateral object at 0x00000264CD0A8D00>, <manga_translator.utils.generic.Quadrilateral object at 0x00000264CD0A8190>, <manga_translator.utils.generic.Quadrilateral object at 0x00000264CD0A8E20>], mask_raw=array([[0, 0, 0, ..., 0, 0, 0],
   [0, 0, 0, ..., 0, 0, 0],
   [0, 0, 0, ..., 0, 0, 0],
   ...,
   [0, 0, 0, ..., 0, 0, 0],
   [0, 0, 0, ..., 0, 0, 0],
   [0, 0, 0, ..., 0, 0, 0]], dtype=uint8), mask=array([[0, 0, 0, ..., 0, 0, 0],
   [0, 0, 0, ..., 0, 0, 0],
   [0, 0, 0, ..., 0, 0, 0],
   ...,
   [0, 0, 0, ..., 0, 0, 0],
   [0, 0, 0, ..., 0, 0, 0],
   [0, 0, 0, ..., 0, 0, 0]], dtype=uint8), text_regions=[<manga_translator.utils.textblock.TextBlock object at 0x00000264CD0A9930>, <manga_translator.utils.textblock.TextBlock object at 0x00000264CD0A9840>, <manga_translator.utils.textblock.TextBlock object at 0x00000264CD0AA950>, <manga_translator.utils.textblock.TextBlock object at 0x00000264CD0AB0D0>, <manga_translator.utils.textblock.TextBlock object at 0x00000264CD0A9330>], translations={'ENG': ['Watch out!!', 'Eek!!', "That's not it!", "Normal people wouldn't do that!!", "I don't read buns!!"]}, img_inpainted=array([[[255, 255, 255],
    [255, 255, 255],
    [255, 255, 255],
    ...,
    [255, 255, 255],
    [255, 255, 255],
    [255, 255, 255]],

   [[255, 255, 255],
    [255, 255, 255],
    [207, 207, 207],
    ...,
    [ 97,  97,  97],
    [ 97,  97,  97],
    [141, 141, 141]],

   [[255, 255, 255],
    [234, 234, 234],
    [ 97,  97,  97],
    ...,
    [255, 255, 255],
    [141, 141, 141],
    [ 97,  97,  97]],

   ...,

   [[255, 255, 255],
    [141, 141, 141],
    [141, 141, 141],
    ...,
    [ 50,  50,  50],
    [ 50,  50,  50],
    [141, 141, 141]],

   [[255, 255, 255],
    [177, 177, 177],
    [ 50,  50,  50],
    ...,
    [234, 234, 234],
    [234, 234, 234],
    [255, 255, 255]],

   [[255, 255, 255],
    [255, 255, 255],
    [207, 207, 207],
    ...,
    [255, 255, 255],
    [255, 255, 255],
    [255, 255, 255]]], dtype=uint8), gimp_mask=array([[[255, 255, 255,   0],
    [255, 255, 255,   0],
    [255, 255, 255,   0],
    ...,
    [255, 255, 255,   0],
    [255, 255, 255,   0],
    [255, 255, 255,   0]],

   [[255, 255, 255,   0],
    [255, 255, 255,   0],
    [207, 207, 207,   0],
    ...,
    [ 97,  97,  97,   0],
    [ 97,  97,  97,   0],
    [141, 141, 141,   0]],

   [[255, 255, 255,   0],
    [234, 234, 234,   0],
    [ 97,  97,  97,   0],
    ...,
    [255, 255, 255,   0],
    [141, 141, 141,   0],
    [ 97,  97,  97,   0]],

   ...,

   [[255, 255, 255,   0],
    [141, 141, 141,   0],
    [141, 141, 141,   0],
    ...,
    [ 50,  50,  50,   0],
    [ 50,  50,  50,   0],
    [141, 141, 141,   0]],

   [[255, 255, 255,   0],
    [177, 177, 177,   0],
    [ 50,  50,  50,   0],
    ...,
    [234, 234, 234,   0],
    [234, 234, 234,   0],
    [255, 255, 255,   0]],

   [[255, 255, 255,   0],
    [255, 255, 255,   0],
    [207, 207, 207,   0],
    ...,
    [255, 255, 255,   0],
    [255, 255, 255,   0],
    [255, 255, 255,   0]]], dtype=uint8), img_rendered=array([[[255, 255, 255],
    [255, 255, 255],
    [255, 255, 255],
    ...,
    [255, 255, 255],
    [255, 255, 255],
    [255, 255, 255]],

   [[255, 255, 255],
    [255, 255, 255],
    [207, 207, 207],
    ...,
    [ 97,  97,  97],
    [ 97,  97,  97],
    [141, 141, 141]],

   [[255, 255, 255],
    [234, 234, 234],
    [ 97,  97,  97],
    ...,
    [255, 255, 255],
    [141, 141, 141],
    [ 97,  97,  97]],

   ...,

   [[255, 255, 255],
    [141, 141, 141],
    [141, 141, 141],
    ...,
    [ 50,  50,  50],
    [ 50,  50,  50],
    [141, 141, 141]],

   [[255, 255, 255],
    [177, 177, 177],
    [ 50,  50,  50],
    ...,
    [234, 234, 234],
    [234, 234, 234],
    [255, 255, 255]],

   [[255, 255, 255],
    [255, 255, 255],
    [207, 207, 207],
    ...,
    [255, 255, 255],
    [255, 255, 255],
    [255, 255, 255]]], dtype=uint8))

@frederik-uni
Copy link
Contributor

what python version are you using. pickle should be able to handle None types as far as I know.

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

3.10.11

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

windows 3.10.11
on linux 3.12 latest version I have the problem in both versions

@frederik-uni
Copy link
Contributor

kinda hard to find the issue:

does this test script run on your machine?

import pickle

class TestPickle:
    def __init__(self):
        self.a = None
        self.b = ""
if __name__ == '__main__':
    print(pickle.loads(pickle.dumps(None)))
    print(pickle.loads(pickle.dumps(TestPickle())))

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

python .\example.py
None
<main.TestPickle object at 0x000002CB671ABFD0>
(venv) PS C:\Users\eren-\projects\mangaTranslator\new-manga-translator>

@frederik-uni
Copy link
Contributor

wtf is the damn issue. It works on my machine(Python 3.12.3 (v3.12.3:f6650f9ad7, Apr 9 2024, 08:18:47) [Clang 13.0.0 (clang-1300.0.29.30)]). you verified that the issue is result_bytes = pickle.dumps(result). pickle seems to be able to serialize & deserialize NoneType values. result isn't even none and none of the values inside are. you could try to verify if the issue is with pickle and the Context. if its not the only thing that might be the issue that some values are not allowed to be serialized/deserialized that are in the references in ctx. But I somehow doubt that too, since python3.10 is quite new

import pickle


class Context(dict):
    __getattr__ = dict.get
    __setattr__ = dict.__setitem__
    __delattr__ = dict.__delitem__

    def __init__(self, **kwargs):
        for name in kwargs:
            setattr(self, name, kwargs[name])

    def __eq__(self, other):
        if not isinstance(other, Context):
            return NotImplemented
        return dict(self) == dict(other)

    def __contains__(self, key):
        return key in self.keys()

    def __repr__(self):
        type_name = type(self).__name__
        arg_strings = []
        star_args = {}
        for arg in self._get_args():
            arg_strings.append(repr(arg))
        for name, value in self._get_kwargs():
            if name.isidentifier():
                arg_strings.append('%s=%r' % (name, value))
            else:
                star_args[name] = value
        if star_args:
            arg_strings.append('**%s' % repr(star_args))
        return '%s(%s)' % (type_name, ', '.join(arg_strings))

    def _get_kwargs(self):
        return list(self.items())

    def _get_args(self):
        return []
if __name__ == '__main__':
    ctx = Context()
    ctx.a = "aa"
    print(pickle.loads(pickle.dumps(None)))
    print(pickle.loads(pickle.dumps(ctx)))
    ```

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

(venv) PS C:\Users\eren-\projects\mangaTranslator\new-manga-translator> python .\example.py
None
Traceback (most recent call last):
File "C:\Users\eren-\projects\mangaTranslator\new-manga-translator\example.py", line 45, in
print(pickle.loads(pickle.dumps(ctx)))
TypeError: 'NoneType' object is not callable

same issue

@frederik-uni
Copy link
Contributor

well at least we isolated the issue

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

I will download this version and try it

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

wait a minute, let me switch to Ubuntu and try again, there was version 3.12.6 if I'm not mistaken.

@frederik-uni
Copy link
Contributor

I would assume that the attributes that are actually functions are the issue and they changed how they behave in newer versions.

__getattr__ = dict.get
    __setattr__ = dict.__setitem__
    __delattr__ = dict.__delitem__

maybe rewriting the functions will help

def __getattr__(self, name):
        try:
            return self[name]
        except KeyError:
            raise AttributeError(f"'Context' object has no attribute '{name}'")

    def __setattr__(self, name, value):
        self[name] = value

    def __delattr__(self, name):
        try:
            del self[name]
        except KeyError:
            raise AttributeError(f"'Context' object has no attribute '{name}'")

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

I looked at Linux, there is version 3.10.6, same error.

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

Now I will switch to Windows and update Python

@frederik-uni
Copy link
Contributor

try the fix above first. that may be faster

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

Where are these functions I couldn't find them in the library packages

@frederik-uni
Copy link
Contributor

the simple test that failed

import pickle


class Context(dict):
    __getattr__ = dict.get
    __setattr__ = dict.__setitem__
    __delattr__ = dict.__delitem__

@frederik-uni
Copy link
Contributor

I think it tries to process the lambda functions, but it can't so it fails. making actual functions out of them might fix the issue

@frederik-uni
Copy link
Contributor

@eren-ay did that fix it?

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

None
Context(a='aa') yes it worked

@frederik-uni
Copy link
Contributor

would you open a pull request for that?

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

sorry for wait
I was switching to windows And suddenly Windows asked me to reset my password.

@frederik-uni
Copy link
Contributor

manga_translator/utils/generic.py is the context location in the project. Such a dumb issue that only affects older python versions

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

Okay, I'll fix it now. I bought a new computer. I don't know why. I've encountered some ridiculous problems in Linux.
thank you so much, you are truly a genius

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

sorry i tried now it's giving error encoded result is from the exception: b"\x02\x00\x00\x003'Context' object has no get attribute 'render_mask'" excepstion is: 'Context' object has no get attribute 'render_mask'

Additionally, it worked when I made the following change:

in the manga_translator.py
async def _run_text_rendering(self, config: Config, ctx: Context):
if config.render.renderer == Renderer.none:
output = ctx.img_inpainted
# manga2eng currently only supports horizontal left to right rendering
elif config.render.renderer == Renderer.manga2Eng and ctx.text_regions and LANGUAGE_ORIENTATION_PRESETS.get(
ctx.text_regions[0].target_lang) == 'h':
output = await dispatch_eng_render(ctx.img_inpainted, ctx.img_rgb, ctx.text_regions, self.font_path, config.render.line_spacing)
else:
ctx.render_mask = None
output = await dispatch_rendering(ctx.img_inpainted, ctx.text_regions, self.font_path, config.render.font_size,
config.render.font_size_offset,
config.render.font_size_minimum, not config.render.no_hyphenation, ctx.render_mask, config.render.line_spacing)
return output

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

ctx.render_mask = None
just this line

@frederik-uni
Copy link
Contributor

that should make it work

   def __getattr__(self, item):
       return self.get(item)
   def __delattr__(self, __key) -> None:
       return self.__delitem__(__key)

   def __setattr__(self, __key, __value):
       return self.__setitem__(__key, __value)

@eren-ay eren-ay closed this as completed Dec 22, 2024
@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

@frederik-uni It works fine but I still installed version 3.12.3
and I checked to see if the problem was the Python version. Do you know what happened? The problem persisted in 3.12.3 Anyway, it works like this with the changes you made, so there is no problem.

@frederik-uni
Copy link
Contributor

no clue. id suggest to create a pull request if you haven't already which adds the changes

@eren-ay
Copy link
Author

eren-ay commented Dec 22, 2024

I am using the current version, I updated it yesterday.

@frederik-uni
Copy link
Contributor

the issue was that the functions were defined as arguments. My runtime ignores lambda functions & just treats them like functions, but this does not seem to be the same for you. I have no clue why it is working in my machine ;D

frederik-uni added a commit to frederik-uni/manga-image-translator that referenced this issue Dec 22, 2024
zyddnys#799 it teems like some runtimes do not like lambda attributes in pickle.dumps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@eren-ay @frederik-uni and others