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

Error running on colab webui automatic111 as an extension. #55

Closed
imesha10 opened this issue Oct 31, 2022 · 4 comments
Closed

Error running on colab webui automatic111 as an extension. #55

imesha10 opened this issue Oct 31, 2022 · 4 comments

Comments

@imesha10
Copy link

imesha10 commented Oct 31, 2022

Quick Description how I got this error.

I installed this as instructed in the readme as an extension. Then once the webui is in final stages of loading up this error pops up. (note that the webui still functions and I can produce images, just the extention keeps spitting out errors constantly, the error following is the first error I get").

Error Log

Error loading script: tag_autocomplete_helper.py
Traceback (most recent call last):
File "/content/stable-diffusion-webui/modules/scripts.py", line 168, in load_scripts
exec(compiled, module.dict)
File "/content/stable-diffusion-webui/extensions/tag-autocomplete/scripts/tag_autocomplete_helper.py", line 24, in
TAGS_PATH = get_tags_base_path()
File "/content/stable-diffusion-webui/extensions/tag-autocomplete/scripts/tag_autocomplete_helper.py", line 18, in get_tags_base_path
if (script_path.is_relative_to(EXT_PATH)):
AttributeError: 'PosixPath' object has no attribute 'is_relative_to'

My guess on what this could be

Looking at the error message I think the issue is script_path is not initialized. I looked at the code and the following is where its initialized.

def get_tags_base_path():
script_path = Path(scripts.basedir())
if (script_path.is_relative_to(EXT_PATH)):

@DominikDoom
Copy link
Owner

The error states that is_relative_to can't be found. This is a python version problem, that attribute was only added in python 3.9. For local it isn't a problem since 3.10.6 is recommended for the webui, but it seems Colab is running 3.7.x by default, which I wasn't aware of. You can technically change the version since you have full access to the instance Debian backend, but it seems pretty annoying to do.

One workaround is the option used in #45, which I originally didn't want to use, but now that I know it's needed on colab maybe I should use it after all or add a version check / fallback to it.

@imesha10
Copy link
Author

Wow lol you are right, I forgot about the python version requirment. Thanks, I managed to get around it somehow. By the way I was looking at the code and looking at what that was trying to do.

# Webui root path
FILE_DIR = Path().absolute()
# The extension base path
EXT_PATH = FILE_DIR.joinpath('extensions')
# Tags base path
def get_tags_base_path():
script_path = Path(scripts.basedir())
if (script_path.is_relative_to(EXT_PATH)):
return script_path.joinpath('tags')
else:
return FILE_DIR.joinpath('tags')
TAGS_PATH = get_tags_base_path()

From what I can see line 8-24 is trying to get the tags base path. I was looking through what the scripts.basedir() does in the documentation(code) from automatic111webui and found this.

def basedir():
    """returns the base directory for the current script. For scripts in the main scripts directory,
    this is the main directory (where webui.py resides), and for scripts in extensions directory
    (ie extensions/aesthetic/script/aesthetic.py), this is extension's directory (extensions/aesthetic)
    """
    return current_basedir

I might be wrong but doesn't both of these produce the same result without the check?
If it was not installed as an extension then it would return .../stable-diff-webui/.
If it was an extension it would return .../stable-diff-webui/extensions/a111-sd-webui-tagcomplete/.
Either way when appending 'tags' to scripts.basedir(), you get the right path.

import os

def get_tags_base_path():
    return os.path.join(scripts.basedir(), "tags")
(I have not tested the code)

Anyways thanks for the help.

@DominikDoom
Copy link
Owner

I might be wrong but doesn't both of these produce the same result without the check?

Huh I actually never thought about that, since it wasn't mentioned in the Wiki about extension development.
But from a quick look it seems like it would work. I'll try it out later.

@DominikDoom
Copy link
Owner

You were correct, this makes the whole check unnecessary. Thanks for the pointer!
That should also make it work with Python 3.7 out of the box.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants