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

merge dev to master #2814

Merged
merged 470 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
470 commits
Select commit Hold shift + click to select a range
ced3b2e
control add inpaint masked only
vladmandic Jan 20, 2024
dc67fc9
autodownload yaml with safetensors if present
vladmandic Jan 20, 2024
2c0b3ac
add additional controlnets
vladmandic Jan 20, 2024
b2d38ae
update icons/hints
vladmandic Jan 20, 2024
927ad16
add lama to control masking options
vladmandic Jan 20, 2024
3f8fa36
fix en display
vladmandic Jan 21, 2024
f2b99d6
fix update commit info
vladmandic Jan 21, 2024
ddae987
add simple-dark and simple-light themes
vladmandic Jan 21, 2024
23a65de
tweak theme and increse image sizes
vladmandic Jan 21, 2024
d9ffb12
enable diffusers by default and disable move/offload by default
vladmandic Jan 21, 2024
4f8f2e5
disable shadows in black-teal
vladmandic Jan 21, 2024
624b0c8
cleanup
vladmandic Jan 21, 2024
14aac11
minor fixes
vladmandic Jan 22, 2024
f0ec1a1
update changelog
vladmandic Jan 22, 2024
d6083ec
IPEX hijack cuda.is_built
Disty0 Jan 23, 2024
36578d6
fix mask invert
vladmandic Jan 23, 2024
60671b0
IPEX fix SegmentAnything
Disty0 Jan 23, 2024
6f2ad14
update k-diffusion
vladmandic Jan 23, 2024
f83f4ed
add depth_anywhere processor
vladmandic Jan 23, 2024
edf1dc6
add depth-anything controlnet
vladmandic Jan 23, 2024
abc991a
add compat layer for wrap_queued_call
vladmandic Jan 23, 2024
867f10d
vae approx cast
vladmandic Jan 24, 2024
b15e13a
opportunistic locking
vladmandic Jan 24, 2024
9ef930b
cleanup
vladmandic Jan 24, 2024
7e88fe8
update install-sf
vladmandic Jan 24, 2024
f097259
expand sdxl autodetect range
vladmandic Jan 24, 2024
9fcc196
update changelog
vladmandic Jan 24, 2024
dad7fe7
autodetect fallback by name
vladmandic Jan 24, 2024
ca70748
fix lora with latest torch
vladmandic Jan 24, 2024
4a9dc8a
Update OpenVINO
Disty0 Jan 24, 2024
3009359
Fix Pruning
AI-Casanova Jan 24, 2024
06081f6
fix img2img with non-standard aspect ratio
vladmandic Jan 25, 2024
3f33224
explicit define mimetypes
vladmandic Jan 25, 2024
c19f951
ipadapter interop
vladmandic Jan 25, 2024
7aa6876
refactor all control processors to support unload and offload
vladmandic Jan 25, 2024
d1bb51e
enable lama offloading
vladmandic Jan 25, 2024
db6fd95
OpenVINO Quantization support with NNCF
Disty0 Jan 25, 2024
8fd081a
add SD_CONFIG_DEBUG
vladmandic Jan 25, 2024
f281109
fix default sampler
vladmandic Jan 25, 2024
e924cc9
make control interrogate more flexible
vladmandic Jan 25, 2024
1440e07
Fix TI loading from legacy formats
AI-Casanova Jan 26, 2024
dbe4d2f
Cleanup upscalers
Disty0 Jan 26, 2024
0bfb17b
implement complete face module
vladmandic Jan 27, 2024
e6a1946
fix blipdiffusion
vladmandic Jan 27, 2024
ffee8d6
fix unidiffuser
vladmandic Jan 27, 2024
389f86d
fix model variant
vladmandic Jan 27, 2024
640b827
add hf token to settings
vladmandic Jan 27, 2024
426aed5
Cleanup
Disty0 Jan 27, 2024
e7e5324
ipadapter match encoder
vladmandic Jan 27, 2024
d92f854
OpenVINO reverse NNCF order
Disty0 Jan 27, 2024
d6c4f60
Cleanup IPEX Optimize
Disty0 Jan 27, 2024
898d535
version lock for controlnet and image-browser
vladmandic Jan 27, 2024
0e141a7
fix fastapi redocs
vladmandic Jan 27, 2024
4085363
fix face model caching
vladmandic Jan 27, 2024
5c78268
Add Auto-conversion of SD 1.5 Embeddings to SDXL
AI-Casanova Jan 27, 2024
a614170
cleanup
AI-Casanova Jan 27, 2024
ebdc214
add embedding convert notes
vladmandic Jan 27, 2024
4b30d6a
IPEX improve autocast hijack
Disty0 Jan 27, 2024
dc70246
cleanup corrections
AI-Casanova Jan 28, 2024
7e44722
refactor api
vladmandic Jan 28, 2024
1ed97c7
update changelog
vladmandic Jan 28, 2024
b79d8ea
cleanup api model defs
vladmandic Jan 28, 2024
1fe544a
improve control enums
vladmandic Jan 28, 2024
c6f6c80
dynamic pipelines
vladmandic Jan 28, 2024
6d2924f
Update shared.py
brknsoul Jan 29, 2024
d1e11d1
Update locale_en.json
brknsoul Jan 29, 2024
786c355
Update locale_en.json
brknsoul Jan 29, 2024
2d32add
Update shared.py
brknsoul Jan 29, 2024
157ddd2
update requirements
vladmandic Jan 29, 2024
753bfeb
fix img2img batch
vladmandic Jan 29, 2024
682da60
improve live preview
vladmandic Jan 29, 2024
f45655f
civitai enable embedding download
vladmandic Jan 29, 2024
f04fa75
add on_after_ui callback
vladmandic Jan 29, 2024
79eef74
unblock controlnet
vladmandic Jan 29, 2024
7fa0120
fix control multi-unit
vladmandic Jan 29, 2024
b13d40d
Diffusers lock preview latent range
Disty0 Jan 29, 2024
f74637e
control process override improvements
vladmandic Jan 29, 2024
325b9eb
add live preview thread lock
vladmandic Jan 29, 2024
b949c04
fix using sd15 model as refiner in second pass
vladmandic Jan 29, 2024
6c75539
fix api image to bas64
vladmandic Jan 29, 2024
3b09027
cleanup
vladmandic Jan 29, 2024
09c7020
add mixture tiling
vladmandic Jan 29, 2024
076e16c
IPEX fix mixture tiling
Disty0 Jan 29, 2024
20b5d95
add ipadapter unapply and switch_pipe cross-family
vladmandic Jan 30, 2024
ca51bfe
control units mixing
vladmandic Jan 30, 2024
ab8b0ae
add star history
vladmandic Jan 30, 2024
80bd17d
Update API for latest face module
Trojaner Jan 29, 2024
a76647c
Fix referencing old faceid model in api models
Trojaner Jan 29, 2024
44a0429
Fix get_scripts_list
Trojaner Jan 29, 2024
625d29d
Fix face script not showing up unless experimental
Trojaner Jan 29, 2024
c125721
fix face script error when images are base64 strings
Trojaner Jan 29, 2024
9dc5fe4
fix ValueError on api img gen when face script is enabled
Trojaner Jan 29, 2024
3baff59
control enable image drag, prompt parse, add metadata
vladmandic Jan 30, 2024
413d58f
fix sag
vladmandic Jan 30, 2024
5faa144
fix imports
vladmandic Jan 30, 2024
1c40ebf
restore pipe at the end of ops
vladmandic Jan 30, 2024
d0ff929
update api compatibility
vladmandic Jan 30, 2024
8f1f538
add api compatibility layer for civitai
vladmandic Jan 30, 2024
ccc38dd
fix ipadapter unload/reapply and use in control
vladmandic Jan 30, 2024
b1ccadf
quickfix ipadapter
vladmandic Jan 31, 2024
09d1f1e
add sa solver and prototype instaflow
vladmandic Jan 31, 2024
778f54e
remove dependency on diffusers dev
vladmandic Jan 31, 2024
f7842d9
fix typo
vladmandic Jan 31, 2024
21516c3
cleanup
vladmandic Jan 31, 2024
def8a30
Initial Olive implementation.
lshqqytiger Oct 21, 2023
b7cce01
cleanup
lshqqytiger Oct 21, 2023
ff6acb4
olive_cache_optimized
lshqqytiger Oct 21, 2023
f22bc3f
remove optimize error log
lshqqytiger Oct 21, 2023
b22d552
optimized model downloading
lshqqytiger Oct 21, 2023
c327331
update olive configs
lshqqytiger Oct 25, 2023
df021b3
support more backends
lshqqytiger Oct 25, 2023
fd2c1e2
add onnxruntime-openvino support.
lshqqytiger Oct 25, 2023
150c3ad
Use get_raw_openvino_device with ONNX
Disty0 Oct 25, 2023
b7cfd09
add optimization on gpu
lshqqytiger Oct 29, 2023
98ee584
customizable execution provider.
lshqqytiger Oct 29, 2023
18e2579
update footprint filename of cpuep
lshqqytiger Oct 30, 2023
507f8c2
add license of olive
lshqqytiger Oct 30, 2023
ae5e407
fix ep option save
lshqqytiger Oct 30, 2023
583116e
fix cached model pipeline
lshqqytiger Oct 30, 2023
f154c78
directly load submodels
lshqqytiger Oct 30, 2023
204d9b7
vae channels last
lshqqytiger Oct 31, 2023
e954695
fix olive not found
lshqqytiger Oct 31, 2023
84f2a9d
make olive optional
lshqqytiger Nov 1, 2023
ee818d9
fixes
lshqqytiger Nov 1, 2023
5ce83bb
specify provider
lshqqytiger Nov 1, 2023
8c819df
ONNX OpenVINO fixes
Disty0 Nov 1, 2023
af4302d
update olive by #2429
lshqqytiger Nov 2, 2023
ba66bf7
add sdxl configs
lshqqytiger Nov 4, 2023
b70258c
add sdxl configs
lshqqytiger Nov 4, 2023
6507491
refactor onnx and olive
lshqqytiger Nov 4, 2023
c8814c4
img2img wip
lshqqytiger Nov 7, 2023
cef798b
implement olive img2img
lshqqytiger Nov 7, 2023
d685426
refactor onnx/olive
lshqqytiger Nov 9, 2023
f832f62
add onnx pipeline for inpaint
lshqqytiger Nov 9, 2023
5b2f778
reduce memory usage (conversion/optimization)
lshqqytiger Nov 14, 2023
9d602ea
load pipeline before removing temp dir
lshqqytiger Nov 15, 2023
68b3178
update configs
lshqqytiger Nov 20, 2023
88faafe
wip: sdxl optimization
lshqqytiger Nov 20, 2023
106a1ea
batch size
lshqqytiger Nov 25, 2023
86b56d2
follow up
lshqqytiger Dec 16, 2023
f10b257
Olive SDXL optimization.
lshqqytiger Dec 16, 2023
82523bd
separate onnx & add pipeline for SDXL Img2Img
lshqqytiger Dec 18, 2023
7ac30fb
minor
lshqqytiger Dec 20, 2023
3cad532
SDXL Turbo with Olive optimization.
lshqqytiger Dec 22, 2023
286ec8e
Integrate Olive into compile backend.
lshqqytiger Dec 23, 2023
34ffba9
other devices
lshqqytiger Dec 27, 2023
208c877
Add ui for olive
lshqqytiger Dec 28, 2023
bdd6b2b
vae override for onnx
lshqqytiger Dec 28, 2023
2fc7a94
Add pass for QUInt8 Quantization.
lshqqytiger Dec 29, 2023
4e5f0d3
Add static dims option.
lshqqytiger Dec 29, 2023
364c3be
Fix onnx model downloading & more fixes.
lshqqytiger Dec 30, 2023
3fb2130
ONNX Stable Diffusion Inpaint WIP
lshqqytiger Dec 31, 2023
701c656
ONNX/Olive SD/SDXL Img2Img Fix.
lshqqytiger Jan 1, 2024
f5a7a53
olive 0.4.x support
lshqqytiger Jan 13, 2024
d55d92b
Implement Olive config editor.
lshqqytiger Jan 13, 2024
0fac69c
AutoExecutionProvider
lshqqytiger Jan 13, 2024
ea2ac32
ONNX/Olive support .safetensors VAE.
lshqqytiger Jan 14, 2024
d848958
ONNX/Olive fix from huggingface cache
lshqqytiger Jan 14, 2024
fc465f9
ONNX ROCm Linux.
lshqqytiger Jan 23, 2024
8bcd600
OnnxConversion pass (temp)
lshqqytiger Jan 25, 2024
393e36e
cleanup
lshqqytiger Jan 25, 2024
250f145
fix
lshqqytiger Jan 25, 2024
192b9db
cleanup
lshqqytiger Jan 30, 2024
88882a3
cleanup, remove torch 1.13.1 hack
lshqqytiger Jan 30, 2024
49b13b9
Restruct ONNX-related files & change olive-ai to optional dependency.
lshqqytiger Jan 30, 2024
6a6d282
fix
lshqqytiger Jan 30, 2024
df6d6e1
fix
lshqqytiger Jan 31, 2024
c26c53a
premerge 1
lshqqytiger Jan 31, 2024
10a8dd3
premerge 2
lshqqytiger Jan 31, 2024
8c7c510
remove duplicated preprocess
lshqqytiger Jan 31, 2024
f493ab8
onnx cpu-only torch fix
lshqqytiger Jan 31, 2024
016fd03
overwrite orig_pipeline for onnx models
lshqqytiger Jan 31, 2024
d6885a5
post merge cleanup
vladmandic Jan 31, 2024
bc66ed1
move save messages to info level
vladmandic Jan 31, 2024
060c92c
fixed pillow font scaling
Jan 31, 2024
90b6052
onnx python 3.9 compatability
lshqqytiger Feb 1, 2024
9884fa7
Merge branch 'dev' of https://github.com/vladmandic/automatic into dev
lshqqytiger Feb 1, 2024
d7074e8
onnx/olive detailed error log
lshqqytiger Feb 1, 2024
b7046df
update changelog
vladmandic Feb 1, 2024
b4c41a7
IPEX hijacks dupe detect
Disty0 Feb 1, 2024
40653d5
olive installation and initialization
lshqqytiger Feb 1, 2024
970b839
Merge branch 'dev' of https://github.com/vladmandic/automatic into dev
lshqqytiger Feb 1, 2024
a227652
major refactor: processing, taesd, scripts
vladmandic Feb 1, 2024
48e4a41
update github actions
vladmandic Feb 1, 2024
a4e1fc7
oliver module loader
vladmandic Feb 1, 2024
fcf00bd
move initialization of onnx pipelines & create onnx folder automatically
lshqqytiger Feb 1, 2024
8309dde
Quick fix xyz_grid after refactor
AI-Casanova Feb 1, 2024
be4534c
Add missing alias
AI-Casanova Feb 1, 2024
69599f0
olive do not ignore venv path
lshqqytiger Feb 2, 2024
df7564a
olive fix mat1 mat2 mismatch
lshqqytiger Feb 2, 2024
1eaa406
OnnxStableDiffusionUpscalePipeline, enable hires for onnx.
lshqqytiger Feb 2, 2024
7c0d1d8
onnx sdxl vae
lshqqytiger Feb 2, 2024
40e1e10
update diffusers
vladmandic Feb 2, 2024
8c3e92b
ipadapter dont cache image encoder between models
vladmandic Feb 2, 2024
9acc625
control auto-install process depenencies
vladmandic Feb 2, 2024
307fc35
fix sd_turbo and sdxl_turbo reference models
vladmandic Feb 2, 2024
5463768
prototype image2video
vladmandic Feb 2, 2024
5c9ca79
First Callback Commit
AI-Casanova Feb 2, 2024
94332fe
tweaks to latent corrections
vladmandic Feb 2, 2024
a78fb4e
update tooltips
vladmandic Feb 2, 2024
cd66300
update changelog
vladmandic Feb 2, 2024
dbb79c9
fix control
vladmandic Feb 3, 2024
01d77ff
multiple control fixes
vladmandic Feb 3, 2024
4fa23ee
fix t2iadapter
vladmandic Feb 3, 2024
2d75e37
fix embeddings refresh
vladmandic Feb 3, 2024
df9b509
controlnet fixes
vladmandic Feb 3, 2024
ace8c3d
face module apply style
vladmandic Feb 3, 2024
fe68776
simplify reference
vladmandic Feb 3, 2024
d94b8f0
update changelog
vladmandic Feb 3, 2024
139ea79
reorg advanced section
vladmandic Feb 3, 2024
36cb64e
OpenVINO change recompile order
Disty0 Feb 3, 2024
b0553f6
Add tooltips for DirectML & ONNX/Olive.
lshqqytiger Feb 4, 2024
a93c816
fix ipadapter clip switch
vladmandic Feb 4, 2024
0a0efa3
fix upscale api
vladmandic Feb 4, 2024
10f6b2c
fix control separate init
vladmandic Feb 4, 2024
a4dbdc0
cache sampler
vladmandic Feb 4, 2024
c463edb
cleanup typos
vladmandic Feb 4, 2024
e2e6743
fix masking
vladmandic Feb 5, 2024
8049053
update changelog
vladmandic Feb 5, 2024
ae113ca
update onnx pipelines.
lshqqytiger Feb 5, 2024
220498c
update onnx utils.
lshqqytiger Feb 5, 2024
ef29f1a
fix control ipadapter inpaint
vladmandic Feb 5, 2024
ff2c1db
fix code formatting under modules/dml
lshqqytiger Feb 5, 2024
e32220c
experimental segmoe support
vladmandic Feb 5, 2024
2ee0baf
unified move-model
vladmandic Feb 5, 2024
b8ea66b
Add Latent Tint
AI-Casanova Feb 5, 2024
3b4d598
color grading
vladmandic Feb 5, 2024
d74f82c
fix batch size
vladmandic Feb 5, 2024
6f0547b
cleanup
vladmandic Feb 5, 2024
07726ea
fix olive recompile
lshqqytiger Feb 6, 2024
cdc29fa
check olive recompile
lshqqytiger Feb 6, 2024
70a15de
add onnx initialization log
lshqqytiger Feb 6, 2024
4bfa0a5
cleanup
lshqqytiger Feb 6, 2024
fe93ea4
SegMoE LoRA
AI-Casanova Feb 6, 2024
6a55f0c
Ctrl-C Ctrl-V Issues
AI-Casanova Feb 6, 2024
cfb142f
update wiki and hints
vladmandic Feb 6, 2024
bbc52fc
fix lora
vladmandic Feb 6, 2024
b3f6f24
cleanup
vladmandic Feb 6, 2024
ad47d81
OpenVINO fix cache and Lora loading
Disty0 Feb 6, 2024
deecedf
update readme and screenshots and add themes wiki
vladmandic Feb 6, 2024
ca5645d
update readme
vladmandic Feb 6, 2024
ad69dcc
update readme and screenshots
vladmandic Feb 6, 2024
593dae4
handle huggingface model variant fallback
vladmandic Feb 6, 2024
4c5e05b
fix control test fonts
vladmandic Feb 7, 2024
b5f32de
fix samplers
vladmandic Feb 7, 2024
d967bd0
update submodule
vladmandic Feb 7, 2024
f6131c3
Update CHANGELOG.md
Aptronymist Feb 7, 2024
24b4cd7
update benchmarks and api endpoints
vladmandic Feb 7, 2024
f768caa
upadate changelog and todo
vladmandic Feb 7, 2024
659ad2e
Merge branch 'master' into dev
vladmandic Feb 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"max-len": [1, 275, 3],
"camelcase":"off",
"default-case":"off",
"no-await-in-loop":"off",
"no-bitwise":"off",
"no-confusing-arrow":"off",
"no-console":"off",
Expand Down Expand Up @@ -71,6 +72,8 @@
"restartReload": "readonly",
"updateInput": "readonly",
"toggleCompact": "readonly",
"setFontSize": "readonly",
"setTheme": "readonly",
// settings.js
"registerDragDrop": "readonly",
//extraNetworks.js
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build_readme.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout-code
uses: actions/checkout@v3
uses: actions/checkout@main
- name: update-readme
uses: JamesIves/github-sponsors-readme-action@v1
uses: JamesIves/github-sponsors-readme-action@v1.3.1
with:
token: ${{ secrets.PAT }}
file: 'README.md'
- name: deploy-readme
uses: JamesIves/github-pages-deploy-action@v4
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
branch: master
folder: '.'
4 changes: 2 additions & 2 deletions .github/workflows/on_pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout-code
uses: actions/checkout@v3
uses: actions/checkout@main
- name: setup-python
uses: actions/setup-python@v4
uses: actions/setup-python@main
with:
python-version: 3.10.6
cache: pip
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ cache
.idea/
/localizations

.*/

# force included
!/models/VAE-approx
!/models/VAE-approx/model.pt
Expand Down
363 changes: 360 additions & 3 deletions CHANGELOG.md

Large diffs are not rendered by default.

1,326 changes: 663 additions & 663 deletions LICENSE.txt

Large diffs are not rendered by default.

486 changes: 243 additions & 243 deletions README.md

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# TODO

ToDo list has moved to [GitHub projects](https://github.com/users/vladmandic/projects)
Main ToDo list can be found at [GitHub projects](https://github.com/users/vladmandic/projects)

## Candidates for next release

- multi-ipadapter: <https://github.com/huggingface/diffusers/pull/6573>
- control second pass: <https://github.com/vladmandic/automatic/issues/2783>
- diffusers public callbacks
- image2video: pia and vgen pipelines
- video2video
- control api
- masking api
- preprocess api
- remove kohya from submodules
- bind panZoom to control input
43 changes: 35 additions & 8 deletions cli/image-exif.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
import io
import re
import sys
import json
from PIL import Image, ExifTags, TiffImagePlugin, PngImagePlugin
from rich import print # pylint: disable=redefined-builtin

# warnings.filterwarnings("ignore", category=UserWarning)


class Exif: # pylint: disable=single-string-used-for-slots
__slots__ = ('__dict__') # pylint: disable=superfluous-parens
Expand Down Expand Up @@ -69,6 +66,36 @@ def decode(self, s: bytes):
pass
return None

def parse(self):
re_param_code = r'\s*([\w ]+):\s*("(?:\\"[^,]|\\"|\\|[^\"])+"|[^,]*)(?:,|$)'
re_param = re.compile(re_param_code)
x = self.exif.pop('parameters', None) or self.exif.pop('UserComment', None)
res = {}
if x is None:
return res
remaining = x.replace('\n', ' ').strip()
if len(remaining) == 0:
return res
remaining = x[7:] if x.startswith('Prompt: ') else x
remaining = x[11:] if x.startswith('parameters: ') else x
if 'Steps: ' in remaining and 'Negative prompt: ' not in remaining:
remaining = remaining.replace('Steps: ', 'Negative prompt: Steps: ')
prompt, remaining = remaining.strip().split('Negative prompt: ', maxsplit=1) if 'Negative prompt: ' in remaining else (remaining, '')
res["Prompt"] = prompt.strip()
negative, remaining = remaining.strip().split('Steps: ', maxsplit=1) if 'Steps: ' in remaining else (remaining, None)
res["Negative prompt"] = negative.strip()
if remaining is None:
return res
remaining = f'Steps: {remaining}'
for k, v in re_param.findall(remaining.strip()):
if v.isdigit():
res[k] = float(v) if '.' in v else int(v)
else:
res[k] = v
from types import SimpleNamespace
ns = SimpleNamespace(**res)
return ns

def get_bytes(self):
ifd = TiffImagePlugin.ImageFileDirectory_v2()
exif_stream = io.BytesIO()
Expand All @@ -87,13 +114,13 @@ def read_exif(filename: str):
from pi_heif import register_heif_opener
register_heif_opener()
try:
img = Image.open(filename)
exif = Exif(img)
print('image:', filename, 'format:', img.format, 'metadata:', json.dumps(vars(exif.exif)['_data'], indent=2))
image = Image.open(filename)
exif = Exif(image)
print('image:', filename, 'format:', image)
print('exif:', vars(exif.exif)['_data'])
print('info:', exif.parse())
except Exception as e:
print('metadata error reading:', filename, e)
# exif.exif['Software'] = 'This is a Test'
# img.save('input-scored.jpg', exif=exif.bytes())


if __name__ == '__main__':
Expand Down
87 changes: 87 additions & 0 deletions cli/install-sf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/usr/bin/env python
import os
import re
import sys

torch_supported = ['211', '212']
cuda_supported = ['cu118', 'cu121']
python_supported = ['39', '310', '311']
repo_url = 'https://github.com/chengzeyi/stable-fast'
api_url = 'https://api.github.com/repos/chengzeyi/stable-fast/releases/tags/nightly'
path_url = '/releases/download/nightly'


def install_pip(arg: str):
import subprocess
cmd = f'"{sys.executable}" -m pip install -U {arg}'
print(f'Running: {cmd}')
result = subprocess.run(cmd, shell=True, check=False, env=os.environ)
return result.returncode == 0


def get_nightly():
import requests
r = requests.get(api_url, timeout=10)
if r.status_code != 200:
print('Failed to get nightly version')
return None
json = r.json()
assets = json.get('assets', [])
if len(assets) == 0:
print('Failed to get nightly version')
return None
asset = assets[0].get('name', '')
pattern = r"-(.+?)\+"
match = re.search(pattern, asset)
if match:
ver = match.group(1)
print(f'Nightly version: {ver}')
return ver
else:
print('Failed to get nightly version')
return None


def install_stable_fast():
import torch

python_ver = f'{sys.version_info.major}{sys.version_info.minor}'
if python_ver not in python_supported:
raise ValueError(f'StableFast unsupported python: {python_ver} required {python_supported}')
if sys.platform == 'linux':
bin_url = 'manylinux2014_x86_64.whl'
elif sys.platform == 'win32':
bin_url = 'win_amd64.whl'
else:
raise ValueError(f'StableFast unsupported platform: {sys.platform}')

torch_ver, cuda_ver = torch.__version__.split('+')
torch_ver = torch_ver.replace('.', '')
sf_ver = get_nightly()

if torch_ver not in torch_supported:
print(f'StableFast unsupported torch: {torch_ver} required {torch_supported}')
print('Installing from source...')
url = 'git+https://github.com/chengzeyi/stable-fast.git@main#egg=stable-fast'
elif cuda_ver not in cuda_supported:
print(f'StableFast unsupported CUDA: {cuda_ver} required {cuda_supported}')
print('Installing from source...')
url = 'git+https://github.com/chengzeyi/stable-fast.git@main#egg=stable-fast'
elif sf_ver is None:
print('StableFast cannot determine version')
print('Installing from source...')
url = 'git+https://github.com/chengzeyi/stable-fast.git@main#egg=stable-fast'
else:
print('Installing wheel...')
file_url = f'stable_fast-{sf_ver}+torch{torch_ver}{cuda_ver}-cp{python_ver}-cp{python_ver}-{bin_url}'
url = f'{repo_url}/{path_url}/{file_url}'

ok = install_pip(url)
if ok:
import sfast
print(f'StableFast installed: {sfast.__version__}')
else:
print('StableFast install failed')

if __name__ == '__main__':
install_stable_fast()
82 changes: 54 additions & 28 deletions cli/run-benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,21 @@
"""
sd api txt2img benchmark
"""
import os
import asyncio
import base64
import io
import json
import time
import argparse
from PIL import Image
import sdapi
from util import Map, log


options = Map({
'restore_faces': False,
'prompt': 'photo of two dice on a table',
'negative_prompt': 'foggy, blurry',
'steps': 50,
'batch_size': 1,
'n_iter': 1,
'seed': -1,
'sampler_name': 'Euler a',
'cfg_scale': 0,
'width': 512,
'height': 512
})


# batch = [1, 1, 2, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128]
batch = [1, 1, 2, 4, 8, 12, 16]
oom = 0
args = None
options = None


async def txt2img():
Expand All @@ -46,9 +33,15 @@ async def txt2img():
else:
return 0
log.debug({ 'info': info })
if options['batch_size'] != len(data['images']):
log.error({ 'requested': options['batch_size'], 'received': len(data['images']) })
for i in range(len(data['images'])):
data['images'][i] = Image.open(io.BytesIO(base64.b64decode(data['images'][i].split(',',1)[0])))
log.debug({ 'image': data['images'][i].size })
if args.save:
fn = os.path.join(args.save, f'benchmark-{i}-{len(data["images"])}.png')
data["images"][i].save(fn)
log.debug({ 'save': fn })
log.debug({ "images": data["images"] })
t1 = time.perf_counter()
return t1 - t0

Expand All @@ -75,28 +68,30 @@ def gb(val: float):


async def main():
log.info({ 'benchmark': { 'batch-sizes': batch } })
sdapi.quiet = True
await sdapi.session()
await sdapi.interrupt()
ver = await sdapi.get("/sdapi/v1/version")
log.info({ 'version': ver})
platform = await sdapi.get("/sdapi/v1/platform")
log.info({ 'platform': platform })
opts = await sdapi.get('/sdapi/v1/options')
opts = Map(opts)
log.info({ 'options': {
'resolution': [options.width, options.height],
'model': opts.sd_model_checkpoint,
'vae': opts.sd_vae,
'hypernetwork': opts.sd_hypernetwork,
'sampler': options.sampler_name,
'preview': opts.show_progress_every_n_steps
} })
log.info({ 'model': opts.sd_model_checkpoint })
cpu, gpu = memstats()
log.info({ 'system': { 'cpu': cpu, 'gpu': gpu }})
batch = [1, 1, 2, 4, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256]
batch = [b for b in batch if b <= args.maxbatch]
log.info({"batch-sizes": batch})
for i in range(len(batch)):
if oom > 0:
continue
options['batch_size'] = batch[i]
warmup = await txt2img()
ts = await txt2img()
if ts > 0:
if i == 0:
ts += warmup
if ts > 0.01: # cannot be faster than 10ms per run
await asyncio.sleep(0)
cpu, gpu = memstats()
if i == 0:
Expand All @@ -115,6 +110,37 @@ async def main():


if __name__ == '__main__':
log.info({ 'run-benchmark' })
parser = argparse.ArgumentParser(description = 'run-benchmark')
parser.add_argument("--steps", type=int, default=50, required=False, help="steps")
parser.add_argument("--sampler", type=str, default='Euler a', required=False, help="max batch size")
parser.add_argument("--prompt", type=str, default='photo of two dice on a table', required=False, help="prompt")
parser.add_argument("--negative", type=str, default='foggy, blurry', required=False, help="prompt")
parser.add_argument("--maxbatch", type=int, default=16, required=False, help="max batch size")
parser.add_argument("--width", type=int, default=512, required=False, help="width")
parser.add_argument("--height", type=int, default=512, required=False, help="height")
parser.add_argument('--debug', default = False, action='store_true', help = 'debug logging')
parser.add_argument('--taesd', default = False, action='store_true', help = 'use taesd as vae')
parser.add_argument("--save", type=str, default='', required=False, help="save images to folder")
args = parser.parse_args()
if args.debug:
log.setLevel('DEBUG')
options = Map(
{
"prompt": args.prompt,
"negative_prompt": args.negative,
"steps": args.steps,
"sampler_name": args.sampler,
"width": args.width,
"height": args.height,
"full_quality": not args.taesd,
"cfg_scale": 0,
"batch_size": 1,
"n_iter": 1,
"seed": -1,
}
)
log.info({"options": options})
try:
asyncio.run(main())
except KeyboardInterrupt:
Expand Down
Loading
Loading