toshiaki1729 / dataset-tag-editor-standalone

WebUI to edit dataset captions for txt2img models
MIT License
135 stars 15 forks source link

Python 3.10.6, gradio 3.22.1: Image files cannot be fetched #26

Closed FilkerZero closed 7 months ago

FilkerZero commented 1 year ago

When I attempt to start working in a directory that contains the images I want to tag, I get the following for each file within the directory:

ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "D:\ai-tools\dataset-tag-editor-standalone\venv\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 408, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "D:\ai-tools\dataset-tag-editor-standalone\venv\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 84, in __call__
    return await self.app(scope, receive, send)
  File "D:\ai-tools\dataset-tag-editor-standalone\venv\lib\site-packages\fastapi\applications.py", line 276, in __call__
    await super().__call__(scope, receive, send)
  File "D:\ai-tools\dataset-tag-editor-standalone\venv\lib\site-packages\starlette\applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "D:\ai-tools\dataset-tag-editor-standalone\venv\lib\site-packages\starlette\middleware\errors.py", line 184, in __call__
    raise exc
  File "D:\ai-tools\dataset-tag-editor-standalone\venv\lib\site-packages\starlette\middleware\errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "D:\ai-tools\dataset-tag-editor-standalone\venv\lib\site-packages\starlette\middleware\cors.py", line 83, in __call__
    await self.app(scope, receive, send)
  File "D:\ai-tools\dataset-tag-editor-standalone\venv\lib\site-packages\starlette\middleware\exceptions.py", line 79, in __call__
    raise exc
  File "D:\ai-tools\dataset-tag-editor-standalone\venv\lib\site-packages\starlette\middleware\exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "D:\ai-tools\dataset-tag-editor-standalone\venv\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 21, in __call__
    raise e
  File "D:\ai-tools\dataset-tag-editor-standalone\venv\lib\site-packages\fastapi\middleware\asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "D:\ai-tools\dataset-tag-editor-standalone\venv\lib\site-packages\starlette\routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "D:\ai-tools\dataset-tag-editor-standalone\venv\lib\site-packages\starlette\routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "D:\ai-tools\dataset-tag-editor-standalone\venv\lib\site-packages\starlette\routing.py", line 66, in app
    response = await func(request)
  File "D:\ai-tools\dataset-tag-editor-standalone\venv\lib\site-packages\fastapi\routing.py", line 237, in app
    raw_response = await run_endpoint_function(
  File "D:\ai-tools\dataset-tag-editor-standalone\venv\lib\site-packages\fastapi\routing.py", line 163, in run_endpoint_function
    return await dependant.call(**values)
  File "D:\ai-tools\dataset-tag-editor-standalone\venv\lib\site-packages\gradio\routes.py", line 336, in file
    raise ValueError(
ValueError: File cannot be fetched: D:/ai-training/93140265_041_bfdc.jpg. All files must contained within the Gradio python app working directory, or be a temp file created by the Gradio python app.

While looking around, I found a closed issue for the webui extension version of the tool from a while ago that says something about gr.Blocks(), though that was about getting at the JavaScript files themselves. I am wondering if this is an incompatibility with the installed version of the gradio package enforcing new access restrictions to sandbox the application, and if there is a simple way to set the access policy to allow the access.

Below is the listing of installed Python packages along with their versions.

Thanks

$ pip list
Package                   Version
------------------------- ------------
aiofiles                  23.2.1
aiohttp                   3.8.5
aiosignal                 1.3.1
altair                    5.1.1
annotated-types           0.5.0
anyio                     3.7.1
async-timeout             4.0.3
attrs                     23.1.0
certifi                   2023.7.22
charset-normalizer        3.2.0
click                     8.1.7
colorama                  0.4.6
contourpy                 1.1.1
customtkinter             5.2.0
cycler                    0.11.0
darkdetect                0.8.0
exceptiongroup            1.1.3
fairscale                 0.4.13
fastapi                   0.95.2
ffmpy                     0.3.1
filelock                  3.12.4
fonttools                 4.42.1
frozenlist                1.4.0
fsspec                    2023.9.2
gradio                    3.22.1
h11                       0.14.0
httpcore                  0.18.0
httpx                     0.25.0
huggingface-hub           0.17.2
idna                      3.4
Jinja2                    3.1.2
jsonschema                4.19.1
jsonschema-specifications 2023.7.1
kiwisolver                1.4.5
linkify-it-py             2.0.2
markdown-it-py            2.2.0
MarkupSafe                2.1.3
matplotlib                3.8.0
mdit-py-plugins           0.3.3
mdurl                     0.1.2
mpmath                    1.3.0
multidict                 6.0.4
networkx                  3.1
numpy                     1.26.0
orjson                    3.9.7
packaging                 23.1
pandas                    2.1.1
Pillow                    10.0.1
pip                       23.2.1
pydantic                  1.10.12
pydantic_core             2.6.3
pydub                     0.25.1
pyparsing                 3.1.1
python-dateutil           2.8.2
python-multipart          0.0.6
pytz                      2023.3.post1
PyYAML                    6.0.1
referencing               0.30.2
regex                     2023.8.8
requests                  2.31.0
rpds-py                   0.10.3
safetensors               0.3.3
setuptools                63.2.0
six                       1.16.0
sniffio                   1.3.0
starlette                 0.27.0
sympy                     1.12
timm                      0.9.7
tokenizers                0.13.3
toolz                     0.12.0
torch                     2.0.1+cu117
torchaudio                2.0.2+cu117
torchvision               0.15.2+cu117
tqdm                      4.66.1
transformers              4.33.2
typing_extensions         4.8.0
tzdata                    2023.3
uc-micro-py               1.0.2
urllib3                   2.0.5
uvicorn                   0.23.2
websockets                11.0.3
xformers                  0.0.21
yarl                      1.9.2
(venv)
danie@Dodecagon MINGW64 /d/ai-tools/dataset-tag-editor-standalone (main)
$
toshiaki1729 commented 7 months ago

The reason is this app cannot fetch image from directories other than this app is stored (it's been from some version of gradio). You can solve this issue by using temporal images, which is in "Settings" tab.

In ver0.0.6 or higher, this app fetch images in different way (with faster response). You also can solve by adding paths to whitelist in "Settings" tab.