distyapps / safe-and-stable-ckpt2safetensors-conversion-tool-gui Goto Github PK
View Code? Open in Web Editor NEWConvert your Stable Diffusion checkpoints quickly and easily.
License: MIT License
Convert your Stable Diffusion checkpoints quickly and easily.
License: MIT License
Hi, i followed all step and got this. Thanks
$ python3.8 run_app_gui.py
Error: Invalid folder path.
Traceback (most recent call last):
File "run_app_gui.py", line 310, in <module>
main()
File "run_app_gui.py", line 93, in main
window = sg.Window(APP_TITLE,layout,finalize=True, resizable=True,enable_close_attempted_event=False,background_color=color.GRAY_9900)
File "/media/sherlock/data/krita-ai/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/venv/lib/python3.8/site-packages/PySimpleGUI/PySimpleGUI.py", line 9614, in __init__
self.Finalize()
File "/media/sherlock/data/krita-ai/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/venv/lib/python3.8/site-packages/PySimpleGUI/PySimpleGUI.py", line 10300, in finalize
self.Read(timeout=1)
File "/media/sherlock/data/krita-ai/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/venv/lib/python3.8/site-packages/PySimpleGUI/PySimpleGUI.py", line 10075, in read
results = self._read(timeout=timeout, timeout_key=timeout_key)
File "/media/sherlock/data/krita-ai/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/venv/lib/python3.8/site-packages/PySimpleGUI/PySimpleGUI.py", line 10146, in _read
self._Show()
File "/media/sherlock/data/krita-ai/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/venv/lib/python3.8/site-packages/PySimpleGUI/PySimpleGUI.py", line 9886, in _Show
StartupTK(self)
File "/media/sherlock/data/krita-ai/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/venv/lib/python3.8/site-packages/PySimpleGUI/PySimpleGUI.py", line 16866, in StartupTK
_convert_window_to_tk(window)
File "/media/sherlock/data/krita-ai/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/venv/lib/python3.8/site-packages/PySimpleGUI/PySimpleGUI.py", line 16753, in _convert_window_to_tk
PackFormIntoFrame(window, master, window)
File "/media/sherlock/data/krita-ai/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/venv/lib/python3.8/site-packages/PySimpleGUI/PySimpleGUI.py", line 15991, in PackFormIntoFrame
PackFormIntoFrame(element, labeled_frame, toplevel_form)
File "/media/sherlock/data/krita-ai/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/venv/lib/python3.8/site-packages/PySimpleGUI/PySimpleGUI.py", line 15991, in PackFormIntoFrame
PackFormIntoFrame(element, labeled_frame, toplevel_form)
File "/media/sherlock/data/krita-ai/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/venv/lib/python3.8/site-packages/PySimpleGUI/PySimpleGUI.py", line 15520, in PackFormIntoFrame
max_line_len = max([len(str(l)) for l in element.Values]) if len(element.Values) else 0
TypeError: object of type 'NoneType' has no len()
Converting Anything-V3.0-pruned.ckpt, or CandyMissionBerryF222-hassan.ckpt, to safetensors fails with the below error:
Converting H:/ai/models/Stable-diffusion\Anything-V3.0-pruned.ckpt to safetensors.
Saving H:/ai/models/Stable-diffusion\Anything-V3.0-pruned.safetensors.
FILE NOT SUPPORTED
Error: No module named 'pytorch_lightning'
Converting H:/ai/models/Stable-diffusion\CandyMissionBerryF222-hassan.ckpt to safetensors.
Saving H:/ai/models/Stable-diffusion\CandyMissionBerryF222-hassan.safetensors.
FILE NOT SUPPORTED
Error: No module named 'pytorch_lightning'
Ckpt should be converted to safetensors.
AUTOMATIC1111/stable-diffusion-webui#4930 (comment)
Use torch.load(..., weight_only=True) (torch 1.13.0 only). But this will fail on the original checkpoint since it uses some real pickled class (pytorch_lightning). There is no way to load those file securely with PyTorch in that format afaik.
got an error after fresh install
"ModuleNotFoundError: No module named 'tkinter'"
fixed it with sudo apt-get install python3-tk, maybe its worth to add to notes or someting.
Exception in thread Thread-1 (process_directory):
Traceback (most recent call last):
File "/home/wilk/.local/lib/python3.10/site-packages/pandas/core/arrays/datetimes.py", line 2192, in objects_to_datetime64ns
values, tz_parsed = conversion.datetime_to_datetime64(data.ravel("K"))
File "pandas/_libs/tslibs/conversion.pyx", line 359, in pandas._libs.tslibs.conversion.datetime_to_datetime64
TypeError: Unrecognized value type: <class 'str'>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/usr/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/media/wilk/PV/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/run_app_gui.py", line 153, in process_directory
cpbar.progress_bar_custom(idx-1,len(input_directory_path_list),start_time,window,PBAR_KEY,"file")
File "/media/wilk/PV/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/util/progress_bar_custom.py", line 110, in progress_bar_custom
time_left = format_sec((range/it_per_sec)-(time_diff))
File "/media/wilk/PV/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/util/progress_bar_custom.py", line 103, in format_sec
formated_sec = pd.to_datetime(formated_sec_step_1).strftime('%H:%M:%S')
File "/home/wilk/.local/lib/python3.10/site-packages/pandas/core/tools/datetimes.py", line 914, in to_datetime
result = convert_listlike(np.array([arg]), format)[0]
File "/home/wilk/.local/lib/python3.10/site-packages/pandas/core/tools/datetimes.py", line 401, in _convert_listlike_datetimes
result, tz_parsed = objects_to_datetime64ns(
File "/home/wilk/.local/lib/python3.10/site-packages/pandas/core/arrays/datetimes.py", line 2198, in objects_to_datetime64ns
raise err
File "/home/wilk/.local/lib/python3.10/site-packages/pandas/core/arrays/datetimes.py", line 2180, in objects_to_datetime64ns
result, tz_parsed = tslib.array_to_datetime(
File "pandas/_libs/tslib.pyx", line 379, in pandas._libs.tslib.array_to_datetime
File "pandas/_libs/tslib.pyx", line 611, in pandas._libs.tslib.array_to_datetime
File "pandas/_libs/tslib.pyx", line 749, in pandas._libs.tslib._array_to_datetime_object
File "pandas/_libs/tslib.pyx", line 740, in pandas._libs.tslib._array_to_datetime_object
File "pandas/_libs/tslibs/parsing.pyx", line 257, in pandas._libs.tslibs.parsing.parse_datetime_string
File "/usr/lib/python3/dist-packages/dateutil/parser/_parser.py", line 1374, in parse
return DEFAULTPARSER.parse(timestr, **kwargs)
File "/usr/lib/python3/dist-packages/dateutil/parser/_parser.py", line 649, in parse
raise ParserError("Unknown string format: %s", timestr)
dateutil.parser._parser.ParserError: Unknown string format: -1 day, 23:59:54.730000
set up the venv and was able to install requirements but get a Error : Invalid folder path when i run python run_app_gui.py. Is there folders I have to create/files I need to move into the env in order for it to work?
Error: Invalid folder path. Traceback (most recent call last): File "/home/fuckyou/workspace/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/run_app_gui.py", line 309, in <module> main() File "/home/fuckyou/workspace/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/run_app_gui.py", line 93, in main window = sg.Window(APP_TITLE,layout,finalize=True, resizable=True,enable_close_attempted_event=False,background_color=color.GRAY_9900) File "/home/fuckyou/workspace/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/venv/lib/python3.9/site-packages/PySimpleGUI/PySimpleGUI.py", line 9614, in __init__ self.Finalize() File "/home/fuckyou/workspace/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/venv/lib/python3.9/site-packages/PySimpleGUI/PySimpleGUI.py", line 10300, in finalize self.Read(timeout=1) File "/home/fuckyou/workspace/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/venv/lib/python3.9/site-packages/PySimpleGUI/PySimpleGUI.py", line 10075, in read results = self._read(timeout=timeout, timeout_key=timeout_key) File "/home/fuckyou/workspace/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/venv/lib/python3.9/site-packages/PySimpleGUI/PySimpleGUI.py", line 10146, in _read self._Show() File "/home/fuckyou/workspace/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/venv/lib/python3.9/site-packages/PySimpleGUI/PySimpleGUI.py", line 9886, in _Show StartupTK(self) File "/home/fuckyou/workspace/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/venv/lib/python3.9/site-packages/PySimpleGUI/PySimpleGUI.py", line 16866, in StartupTK _convert_window_to_tk(window) File "/home/fuckyou/workspace/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/venv/lib/python3.9/site-packages/PySimpleGUI/PySimpleGUI.py", line 16753, in _convert_window_to_tk PackFormIntoFrame(window, master, window) File "/home/fuckyou/workspace/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/venv/lib/python3.9/site-packages/PySimpleGUI/PySimpleGUI.py", line 15991, in PackFormIntoFrame PackFormIntoFrame(element, labeled_frame, toplevel_form) File "/home/fuckyou/workspace/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/venv/lib/python3.9/site-packages/PySimpleGUI/PySimpleGUI.py", line 15991, in PackFormIntoFrame PackFormIntoFrame(element, labeled_frame, toplevel_form) File "/home/fuckyou/workspace/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/venv/lib/python3.9/site-packages/PySimpleGUI/PySimpleGUI.py", line 15520, in PackFormIntoFrame max_line_len = max([len(str(l)) for l in element.Values]) if len(element.Values) else 0 TypeError: object of type 'NoneType' has no len()
environment: macos m1
python 3.9
python3 run_app_gui.py
/Users/songkeys/Library/Python/3.9/lib/python/site-packages/PySimpleGUI/PySimpleGUI.py:24845: UserWarning: You are running a VERY old version of tkinter 8.5.9. You cannot use PNG formatted images for example. Please upgrade to 8.6.x
warnings.warn('You are running a VERY old version of tkinter {}. You cannot use PNG formatted images for example. Please upgrade to 8.6.x'.format(tclversion_detailed), UserWarning)
Mac OS Version is 13.2 and patch enabled so applying the patch
Applyting Mac OS 12.3+ Alpha Channel fix. Your default Alpha Channel is now 0.99
DEPRECATION WARNING: The system version of Tk is deprecated and may be removed in a future release. Please don't rely on it. Set TK_SILENCE_DEPRECATION=1 to suppress this warning.
Traceback (most recent call last):
File "/Users/songkeys/Downloads/convertor/run_app_gui.py", line 309, in <module>
main()
File "/Users/songkeys/Downloads/convertor/run_app_gui.py", line 93, in main
window = sg.Window(APP_TITLE,layout,finalize=True, resizable=True,enable_close_attempted_event=False,background_color=color.GRAY_9900)
File "/Users/songkeys/Library/Python/3.9/lib/python/site-packages/PySimpleGUI/PySimpleGUI.py", line 9614, in __init__
self.Finalize()
File "/Users/songkeys/Library/Python/3.9/lib/python/site-packages/PySimpleGUI/PySimpleGUI.py", line 10300, in finalize
self.Read(timeout=1)
File "/Users/songkeys/Library/Python/3.9/lib/python/site-packages/PySimpleGUI/PySimpleGUI.py", line 10075, in read
results = self._read(timeout=timeout, timeout_key=timeout_key)
File "/Users/songkeys/Library/Python/3.9/lib/python/site-packages/PySimpleGUI/PySimpleGUI.py", line 10146, in _read
self._Show()
File "/Users/songkeys/Library/Python/3.9/lib/python/site-packages/PySimpleGUI/PySimpleGUI.py", line 9886, in _Show
StartupTK(self)
File "/Users/songkeys/Library/Python/3.9/lib/python/site-packages/PySimpleGUI/PySimpleGUI.py", line 16866, in StartupTK
_convert_window_to_tk(window)
File "/Users/songkeys/Library/Python/3.9/lib/python/site-packages/PySimpleGUI/PySimpleGUI.py", line 16753, in _convert_window_to_tk
PackFormIntoFrame(window, master, window)
File "/Users/songkeys/Library/Python/3.9/lib/python/site-packages/PySimpleGUI/PySimpleGUI.py", line 15991, in PackFormIntoFrame
PackFormIntoFrame(element, labeled_frame, toplevel_form)
File "/Users/songkeys/Library/Python/3.9/lib/python/site-packages/PySimpleGUI/PySimpleGUI.py", line 15991, in PackFormIntoFrame
PackFormIntoFrame(element, labeled_frame, toplevel_form)
File "/Users/songkeys/Library/Python/3.9/lib/python/site-packages/PySimpleGUI/PySimpleGUI.py", line 15216, in PackFormIntoFrame
photo = tk.PhotoImage(data=element.ImageData)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 4064, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 4009, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: couldn't recognize image data
I tried python3.9 run_app_gui.py
, it's another error:
python3.9 run_app_gui.py
Traceback (most recent call last):
File "/Users/songkeys/Downloads/convertor/run_app_gui.py", line 1, in <module>
import PySimpleGUI as sg
File "/Users/songkeys/Library/Python/3.9/lib/python/site-packages/PySimpleGUI/__init__.py", line 2, in <module>
from .PySimpleGUI import *
File "/Users/songkeys/Library/Python/3.9/lib/python/site-packages/PySimpleGUI/PySimpleGUI.py", line 136, in <module>
import tkinter as tk
File "/opt/homebrew/Cellar/[email protected]/3.9.16/Frameworks/Python.framework/Versions/3.9/lib/python3.9/tkinter/__init__.py", line 37, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
I have run both pip install -r requirements.txt
and pip3 install -r requirements.txt
.
ubuntu 20, python3.8
pip install -r requirements worked fine. when i run python3 run_app_gui.py it gives
Traceback (most recent call last): File "run_app_gui.py", line 309, in <module> main() File "run_app_gui.py", line 66, in main file_explorer.layout(), File "/home/user/Data/github/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/util/file_explorer_component.py", line 85, in layout sg.Listbox(key=FILE_EXPLORER_LSTBOX_KEY,values=get_system_files_list(),text_color=color.TERMINAL_BLUE,background_color=color.GRAY_1111, File "/home/user/Data/github/Safe-and-Stable-Ckpt2Safetensors-Conversion-Tool-GUI/util/file_explorer_component.py", line 79, in get_system_files_list return get_system_files(os.path.join(os.getenv("SystemDrive"), "\\")) File "/usr/lib/python3.8/posixpath.py", line 76, in join a = os.fspath(a) TypeError: expected str, bytes or os.PathLike object, not NoneType
Trojan was removed from pc with only files affected being ckpt converted files of protogenX34Photorealism_1.
I have some older pipeline working and don't have the ability yet to update it.
Is there something out there?
title
am i just stupid? i don't even see anything in this program to actually run the program, an explanation on how to run it would be great.
I try to convert safetensor back to ckpt for using with some old webui with faster iteration feature. Unfortunately it didnt support safetensor so I have to convert it back to ckpt. But when I use your GUI why it shows Error: [Errno 13] Permission denied: 'C:\Safetensor2-cnvrtd.ckpt'?
Thank you
It would nice if this could be run as a cmdline, or even better make it a separate python lib w/ cmdline support.
After extracting the zip file, I tried running the run_app_gui.exe file and received this error:
Traceback (most recent call last):
File "run_app_gui.py", line 3, in
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "torch_init_.py", line 192, in
from torch._C import * # noqa: F403
ImportError: DLL load failed: The specified module could not be found.
i experienced crashes with long file names, i dont know if there is a limit on the total path length but after debugging it seems that
selected_path = file_explorer.SelectedFileSystem.path
is not the correct full path.
NOT working import to DiffusionBee(MAC M2platform) after conversion safttensors to ckpt, ERROR information as below.
Error Traceback (most recent call last):
File "convert_model.py", line 28, in
KeyError: 'state_dict'
[18150] Failed to execute script 'convert_model' due to unhandled exception!
can you add converting from CKPT/Safetensors to Tensorflow Lite?
Line
loads the .ckpt file without any checks or safety, and will execute any code in a tampered checkpoint file. This implementation is fine if you're running the tool on checkpoints that you know are safe, but the tool needs a VERY BIG WARNING sign to not use it on any checkpoints from unknown sources. It completely negates the benefit of the safetensors format when used in that way.Edit: Just noticed it is mentioned in the readme, but easily missed by anyone just using the tool. Do not call your tool "safe" if it isn't though.
Certain ckpt fail to convert with the following error message:
Error: Key state_dict
is invalid, expected torch.Tensor but received <class 'dict'>
Ckpt should be converted to safetensors.
NAI can be converted by adding weights.pop("state_dict") to the conversion script in the GitHub pull request.
Edit: I would also recommend the script from @Tumppi066 which lists and converts models from sub-directories as well as working directory. You can get a NAI compatible version I patched here.
import torch
from safetensors.torch import save_file
weights = torch.load("nai.ckpt")["state_dict"]
weights.pop("state_dict")
save_file(weights, "nai.safetensors")
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.