toriato / stable-diffusion-webui-wd14-tagger

Labeling extension for Automatic1111's Web UI
1.34k stars 235 forks source link

Request - Is it possible to implement a text box that places the following folders in any location? #30

Closed fumitakayano closed 1 year ago

fumitakayano commented 1 year ago

Is it possible to implement a text box that places the following folders in any location? An error occurs in an environment where UAC is above a certain level, so I would like to ask for a countermeasure.

models-SmillingWolf-wd-v1-4-convert-tagger models-smillingWolf-wd-1-4-vt-tagger

SmilingWolf commented 1 year ago

The Huggingface Hub Client library, used to manage files downloaded from HF repos, supports the requested functionality out of the box.

From https://huggingface.co/docs/huggingface_hub/how-to-cache:

The is usually your user’s home directory. However, it is customizable with the cache_dir argument on all methods, or by specifying either HF_HOME or HUGGINGFACE_HUB_CACHE environment variable.

So I believe it should only be a matter of adding set HUGGINGFACE_HUB_CACHE=D:\some\path to the webui-user.bat file. Please let us know if that works for you.

fumitakayano commented 1 year ago

SmilingWolf san. Thank you for letting me know about the fix!

Added set HUGGGINGFACE_HUB_CACHE=D:\some\path to webui-user.bat.

I was able to download models-SmillingWolf-wd-v1-4-convert-tagger and models-smillingWolf-wd-1-4-vt-tagger in the specified folder.But I got OSError: [WinError 1314].I may have a fundamental misunderstanding.

Could you please confirm the content of the error?

Loading Waifu Diffusion tagger model file from SmilingWolf/wd-v1-4-vit-tagger
Error completing request
Arguments: (<PIL.Image.Image image mode=RGB size=750x1334 at 0x1E3FE3CC250>, '', False, '', '[name].[output_extension]', 'ignore', False, 'wd14-vit', 0.35, '', '', False, False, True, '0_0, (o)_(o), +_+, +_-, ._., <o>_<o>, <|>_<|>, =_=, >_<, 3_3, 6_9, >_o, @_@, ^_^, o_o, u_u, x_x, |_|, ||_||', False) {}
Traceback (most recent call last):
  File "D:\git\stable-diffusion-webui\venv\lib\site-packages\huggingface_hub\file_download.py", line 837, in _create_relative_symlink
    os.symlink(relative_src, dst)
OSError: [WinError 1314] クライアントは要求された特権を保有していません。: '..\\..\\blobs\\22e88a3226e427998fdf669bdbd035ee7040f3229796dd66ec35b8dd90e852b5' -> 'D:\\git\\.cache\\models--SmilingWolf--wd-v1-4-vit-tagger\\snapshots\\213a7bd66d93407911b8217e806a95edc3593eed\\model.onnx'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\git\stable-diffusion-webui\modules\call_queue.py", line 45, in f
    res = list(func(*args, **kwargs))
  File "D:\git\stable-diffusion-webui\modules\call_queue.py", line 28, in f
    res = func(*args, **kwargs)
  File "D:\git\stable-diffusion-webui\extensions\stable-diffusion-webui-wd14-tagger\scripts\tagger.py", line 310, in give_me_the_tags
    ratings, tags = interrogator.interrogate(image)
  File "D:\git\stable-diffusion-webui\extensions\stable-diffusion-webui-wd14-tagger\tagger\interrogator.py", line 234, in interrogate
    self.load()
  File "D:\git\stable-diffusion-webui\extensions\stable-diffusion-webui-wd14-tagger\tagger\interrogator.py", line 197, in load
    model_path, tags_path = self.download()
  File "D:\git\stable-diffusion-webui\extensions\stable-diffusion-webui-wd14-tagger\tagger\interrogator.py", line 192, in download
    model_path = Path(hf_hub_download(self.repo, filename=self.model_path))
  File "D:\git\stable-diffusion-webui\venv\lib\site-packages\huggingface_hub\file_download.py", line 1218, in hf_hub_download
    _create_relative_symlink(blob_path, pointer_path)
  File "D:\git\stable-diffusion-webui\venv\lib\site-packages\huggingface_hub\file_download.py", line 841, in _create_relative_symlink
    raise OSError(
OSError: Windows requires Developer Mode to be activated, or to run Python as an administrator, in order to create symlinks.
In order to activate Developer Mode, see this article: https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development

Traceback (most recent call last):
  File "D:\git\stable-diffusion-webui\venv\lib\site-packages\gradio\routes.py", line 284, in run_predict
    output = await app.blocks.process_api(
  File "D:\git\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 983, in process_api
    data = self.postprocess_data(fn_index, result["prediction"], state)
  File "D:\git\stable-diffusion-webui\venv\lib\site-packages\gradio\blocks.py", line 913, in postprocess_data
    if predictions[i] is components._Keywords.FINISHED_ITERATING:
IndexError: tuple index out of range

that's all

SmilingWolf commented 1 year ago

Ah, I see the problem now. The installed version of huggingface-hub is v.0.9, which is somewhat unreliable because of the way it handles symlinks on Windows. The proper fix is to update to at least v0.10, or better yet to the latest version. Running pip install -U huggingface-hub from within the webui venv should fix the problem.

fumitakayano commented 1 year ago

Smiling Wolf-san. Thanks for pointing out the update on huggingface-hub. After dealing with it, stable-broadcast-webui-wd14-tagger was successfully started.

Thank you again.