invoke-ai / InvokeAI

InvokeAI is a leading creative engine for Stable Diffusion models, empowering professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry leading WebUI, supports terminal use through a CLI, and serves as the foundation for multiple commercial products.
https://invoke-ai.github.io/InvokeAI/
Apache License 2.0
22.81k stars 2.36k forks source link

[bug]: invokeai-import-images throws a TypeError #6776

Closed SkyrimLL closed 2 weeks ago

SkyrimLL commented 2 weeks ago

Is there an existing issue for this problem?

Operating system

Windows

GPU vendor

Nvidia (CUDA)

GPU model

RTX3090

GPU VRAM

24GB

Version number

4.2.8

Browser

Chrome (up to date)

Python dependencies

No response

What happened

I am trying to run invokeai-import-images to consolidate multiple image folders from old versions of Invoke into one instance and database. Running the command in the developer console results in this error message:

Python version is:
Python 3.10.9
*************************
You are now in the system shell, with the local InvokeAI Python virtual environment activated,
so that you can troubleshoot this InvokeAI installation as necessary.
*************************
*** Type `exit` to quit this shell and deactivate the Python virtual environment ***
(.venv) E:\Tools\Invoke>invokeai-import-images
===============================================================================
This script will import images generated by earlier versions of
InvokeAI into the currently installed root directory:
   E:\Tools\Invoke
If this is not what you want to do, type ctrl-C now to cancel.
===============================================================================
= Configuration & Settings
Traceback (most recent call last):
  File "C:\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "E:\Tools\Invoke\.venv\Scripts\invokeai-import-images.exe\__main__.py", line 7, in <module>
  File "E:\Tools\Invoke\.venv\lib\site-packages\invokeai\frontend\install\import_images.py", line 780, in main
    processor.process()
  File "E:\Tools\Invoke\.venv\lib\site-packages\invokeai\frontend\install\import_images.py", line 698, in process
    config.find_and_load()
  File "E:\Tools\Invoke\.venv\lib\site-packages\invokeai\frontend\install\import_images.py", line 65, in find_and_load
    if not self.confirm_and_load(os.path.abspath(root)):
  File "E:\Tools\Invoke\.venv\lib\site-packages\invokeai\frontend\install\import_images.py", line 77, in confirm_and_load
    if os.path.isabs(db_dir):
  File "C:\Python\Python310\lib\ntpath.py", line 89, in isabs
    s = os.fspath(s)
TypeError: expected str, bytes or os.PathLike object, not NoneType

(.venv) E:\Tools\Invoke>

What you expected to happen

I expected the script to run as described on this page: https://invoke-ai.github.io/InvokeAI/features/UTILITIES/

How to reproduce the problem

Start invoke.bat Select option 2. Open the developer console Enter 'invokeai-import-images'

Additional context

No response

Discord username

No response

SkyrimLL commented 2 weeks ago

What I meant to report is that the import images script is currently not working at all after a fresh install of Invoke 4.2.8 I tried launching the bat file with the root and config parameters in case they were not automatically detected but that didn't help. invoke-web is working fine otherwise. It is just there is something breaking that import script only.

DustyShoe commented 2 weeks ago

Images do not get automatically detected in the output folder if database file is removed or changed. If i'm not mistaken, support for import images and DB management scripts were abandoned somewhere between 3.7.x-4.0.x versions. So it is not a bug. Documentation is pretty much outdated in some places. As a work around you can just drag and drop your old images into Invoke UI window. Although they will be places into assets tab. Still, you can recall parameters, read metadata and workflow from them. Keep in mind, these settings anyways wont produce you similar images if they are older than 3.0.2 or something. Something was changes in the way models respond to prompts or something along the line. Well, there's a chance someone will volunteer to write a script one day, though.

SkyrimLL commented 2 weeks ago

Thanks for the reply.. good to know.

I developed a script to back up invoke db images to an archive folder, both into time based sessions and boards folders, to make them more easily useable outside of Invoke. I was thinking of writing something for the reverse direction but that import script seemed to do what I wanted, so maybe I will work on it after all :)

I saw the 'invokeai-import-images' is only available as an .exe file. Is the source code available anywhere? I am interested in how Board IDs are generated.

Edit: Answering my own question. I got the script from the repo: InvokeAI/invokeai/frontend/install/import_images.py

psychedelicious commented 2 weeks ago

This script isn't supposed to be bundled with the app - it doesn't work. Strongly suggest not running it as it can cause data loss.

SkyrimLL commented 2 weeks ago

Out of curiosity, can you share details about what causes data loss with that script? Is it because UUIDs in file names are not guaranteed to be unique between instances of Invoke AI?

psychedelicious commented 2 weeks ago

I don't recall the specifics, sorry - was few months ago. Actually, it could have been the "db maintenance" script that caused data loss. But per user reports, neither work as they are intended to as their contributor hasn't been around for a while and we haven't got anybody to keep them up to date.

They were actually removed from the app launcher script some time ago, but we forgot to remove them from the python package's config. As a result, they were still distributed with the package, just a bit harder to stumble across.

SkyrimLL commented 2 weeks ago

Thanks for the reply. I reused some of the code of the import script to allow me to merge multiple image folders into one, at the risk of potentially missing an image or two if their IDs were the same. Looks like it worked so far. I now have a single database with the latest version instead of multiple old ones, so I am happy.