mirror of https://github.com/vladmandic/automatic
post-merge update
parent
cb72d69970
commit
ee410df5a5
|
|
@ -13,6 +13,7 @@ __pycache__
|
|||
*.lock
|
||||
*.zip
|
||||
*.rar
|
||||
*.pyc
|
||||
|
||||
# all dynamic stuff
|
||||
/repositories/**/*
|
||||
|
|
|
|||
216
README.md
216
README.md
|
|
@ -1,162 +1,80 @@
|
|||
# Stable Diffusion web UI
|
||||
A browser interface based on Gradio library for Stable Diffusion.
|
||||
# Stable Diffusion - Automatic
|
||||
|
||||

|
||||
*Heavily opinionated custom fork of* <https://github.com/AUTOMATIC1111/stable-diffusion-webui>
|
||||
|
||||
## Features
|
||||
[Detailed feature showcase with images](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Features):
|
||||
- Original txt2img and img2img modes
|
||||
- One click install and run script (but you still must install python and git)
|
||||
- Outpainting
|
||||
- Inpainting
|
||||
- Color Sketch
|
||||
- Prompt Matrix
|
||||
- Stable Diffusion Upscale
|
||||
- Attention, specify parts of text that the model should pay more attention to
|
||||
- a man in a ((tuxedo)) - will pay more attention to tuxedo
|
||||
- a man in a (tuxedo:1.21) - alternative syntax
|
||||
- select text and press ctrl+up or ctrl+down to automatically adjust attention to selected text (code contributed by anonymous user)
|
||||
- Loopback, run img2img processing multiple times
|
||||
- X/Y/Z plot, a way to draw a 3 dimensional plot of images with different parameters
|
||||
- Textual Inversion
|
||||
- have as many embeddings as you want and use any names you like for them
|
||||
- use multiple embeddings with different numbers of vectors per token
|
||||
- works with half precision floating point numbers
|
||||
- train embeddings on 8GB (also reports of 6GB working)
|
||||
- Extras tab with:
|
||||
- GFPGAN, neural network that fixes faces
|
||||
- CodeFormer, face restoration tool as an alternative to GFPGAN
|
||||
- RealESRGAN, neural network upscaler
|
||||
- ESRGAN, neural network upscaler with a lot of third party models
|
||||
- SwinIR and Swin2SR([see here](https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/2092)), neural network upscalers
|
||||
- LDSR, Latent diffusion super resolution upscaling
|
||||
- Resizing aspect ratio options
|
||||
- Sampling method selection
|
||||
- Adjust sampler eta values (noise multiplier)
|
||||
- More advanced noise setting options
|
||||
- Interrupt processing at any time
|
||||
- 4GB video card support (also reports of 2GB working)
|
||||
- Correct seeds for batches
|
||||
- Live prompt token length validation
|
||||
- Generation parameters
|
||||
- parameters you used to generate images are saved with that image
|
||||
- in PNG chunks for PNG, in EXIF for JPEG
|
||||
- can drag the image to PNG info tab to restore generation parameters and automatically copy them into UI
|
||||
- can be disabled in settings
|
||||
- drag and drop an image/text-parameters to promptbox
|
||||
- Read Generation Parameters Button, loads parameters in promptbox to UI
|
||||
- Settings page
|
||||
- Running arbitrary python code from UI (must run with --allow-code to enable)
|
||||
- Mouseover hints for most UI elements
|
||||
- Possible to change defaults/mix/max/step values for UI elements via text config
|
||||
- Tiling support, a checkbox to create images that can be tiled like textures
|
||||
- Progress bar and live image generation preview
|
||||
- Can use a separate neural network to produce previews with almost none VRAM or compute requirement
|
||||
- Negative prompt, an extra text field that allows you to list what you don't want to see in generated image
|
||||
- Styles, a way to save part of prompt and easily apply them via dropdown later
|
||||
- Variations, a way to generate same image but with tiny differences
|
||||
- Seed resizing, a way to generate same image but at slightly different resolution
|
||||
- CLIP interrogator, a button that tries to guess prompt from an image
|
||||
- Prompt Editing, a way to change prompt mid-generation, say to start making a watermelon and switch to anime girl midway
|
||||
- Batch Processing, process a group of files using img2img
|
||||
- Img2img Alternative, reverse Euler method of cross attention control
|
||||
- Highres Fix, a convenience option to produce high resolution pictures in one click without usual distortions
|
||||
- Reloading checkpoints on the fly
|
||||
- Checkpoint Merger, a tab that allows you to merge up to 3 checkpoints into one
|
||||
- [Custom scripts](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Custom-Scripts) with many extensions from community
|
||||
- [Composable-Diffusion](https://energy-based-model.github.io/Compositional-Visual-Generation-with-Composable-Diffusion-Models/), a way to use multiple prompts at once
|
||||
- separate prompts using uppercase `AND`
|
||||
- also supports weights for prompts: `a cat :1.2 AND a dog AND a penguin :2.2`
|
||||
- No token limit for prompts (original stable diffusion lets you use up to 75 tokens)
|
||||
- DeepDanbooru integration, creates danbooru style tags for anime prompts
|
||||
- [xformers](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Xformers), major speed increase for select cards: (add --xformers to commandline args)
|
||||
- via extension: [History tab](https://github.com/yfszzx/stable-diffusion-webui-images-browser): view, direct and delete images conveniently within the UI
|
||||
- Generate forever option
|
||||
- Training tab
|
||||
- hypernetworks and embeddings options
|
||||
- Preprocessing images: cropping, mirroring, autotagging using BLIP or deepdanbooru (for anime)
|
||||
- Clip skip
|
||||
- Hypernetworks
|
||||
- Loras (same as Hypernetworks but more pretty)
|
||||
- A sparate UI where you can choose, with preview, which embeddings, hypernetworks or Loras to add to your prompt.
|
||||
- Can select to load a different VAE from settings screen
|
||||
- Estimated completion time in progress bar
|
||||
- API
|
||||
- Support for dedicated [inpainting model](https://github.com/runwayml/stable-diffusion#inpainting-with-stable-diffusion) by RunwayML.
|
||||
- via extension: [Aesthetic Gradients](https://github.com/AUTOMATIC1111/stable-diffusion-webui-aesthetic-gradients), a way to generate images with a specific aesthetic by using clip images embeds (implementation of [https://github.com/vicgalle/stable-diffusion-aesthetic-gradients](https://github.com/vicgalle/stable-diffusion-aesthetic-gradients))
|
||||
- [Stable Diffusion 2.0](https://github.com/Stability-AI/stablediffusion) support - see [wiki](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Features#stable-diffusion-20) for instructions
|
||||
- [Alt-Diffusion](https://arxiv.org/abs/2211.06679) support - see [wiki](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Features#alt-diffusion) for instructions
|
||||
- Now without any bad letters!
|
||||
- Load checkpoints in safetensors format
|
||||
- Eased resolution restriction: generated image's domension must be a multiple of 8 rather than 64
|
||||
- Now with a license!
|
||||
- Reorder elements in the UI from settings screen
|
||||
-
|
||||

|
||||
|
||||
## Installation and Running
|
||||
Make sure the required [dependencies](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Dependencies) are met and follow the instructions available for both [NVidia](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Install-and-Run-on-NVidia-GPUs) (recommended) and [AMD](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Install-and-Run-on-AMD-GPUs) GPUs.
|
||||
<br>
|
||||
|
||||
Alternatively, use online services (like Google Colab):
|
||||
## Notes
|
||||
|
||||
- [List of Online Services](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Online-Services)
|
||||
Fork is as close as up-to-date with origin as time allows
|
||||
All code changes are merged upstream whenever possible
|
||||
|
||||
### Automatic Installation on Windows
|
||||
1. Install [Python 3.10.6](https://www.python.org/downloads/windows/), checking "Add Python to PATH"
|
||||
2. Install [git](https://git-scm.com/download/win).
|
||||
3. Download the stable-diffusion-webui repository, for example by running `git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git`.
|
||||
4. Place stable diffusion checkpoint (`model.ckpt`) in the `models/Stable-diffusion` directory (see [dependencies](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Dependencies) for where to get it).
|
||||
5. Run `webui-user.bat` from Windows Explorer as normal, non-administrator, user.
|
||||
Fork adds extra functionality:
|
||||
- Ships with additional **extensions**
|
||||
e.g. `System Info`, `Steps Animation`, etc.
|
||||
- Ships with set of **CLI** tools that rely on *SD API* for execution:
|
||||
e.g. `generate`, `train`, `bench`, etc.
|
||||
[Full list](<cli/>)
|
||||
|
||||
### Automatic Installation on Linux
|
||||
1. Install the dependencies:
|
||||
```bash
|
||||
# Debian-based:
|
||||
sudo apt install wget git python3 python3-venv
|
||||
# Red Hat-based:
|
||||
sudo dnf install wget git python3
|
||||
# Arch-based:
|
||||
sudo pacman -S wget git python3
|
||||
```
|
||||
2. To install in `/home/$(whoami)/stable-diffusion-webui/`, run:
|
||||
```bash
|
||||
bash <(wget -qO- https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/webui.sh)
|
||||
```
|
||||
Simplified start script: `automatic.sh`
|
||||
*Existing `webui.sh`/`webui.bat` still exist for backward compatibility, fresh installs to auto-install dependencies, etc.*
|
||||
|
||||
### Installation on Apple Silicon
|
||||
> ./automatic.sh
|
||||
|
||||
Find the instructions [here](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Installation-on-Apple-Silicon).
|
||||
- Start in default mode with optimizations enabled
|
||||
|
||||
## Contributing
|
||||
Here's how to add code to this repo: [Contributing](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Contributing)
|
||||
> ./automatic.sh env
|
||||
|
||||
## Documentation
|
||||
The documentation was moved from this README over to the project's [wiki](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki).
|
||||
- Print env info and exit
|
||||
Example:
|
||||
|
||||
## Credits
|
||||
Licenses for borrowed code can be found in `Settings -> Licenses` screen, and also in `html/licenses.html` file.
|
||||
Version: c07487a Tue Jan 24 08:04:31 2023 -0500
|
||||
Platform: Ubuntu 22.04.1 LTS 5.15.79.1-microsoft-standard-WSL2 x86_64
|
||||
Python 3.10.6
|
||||
Torch: 2.0.0.dev20230118+cu118 CUDA: 11.8 cuDNN: 8700 GPU: NVIDIA GeForce RTX 3060 Arch: (8, 6)
|
||||
|
||||
- Stable Diffusion - https://github.com/CompVis/stable-diffusion, https://github.com/CompVis/taming-transformers
|
||||
- k-diffusion - https://github.com/crowsonkb/k-diffusion.git
|
||||
- GFPGAN - https://github.com/TencentARC/GFPGAN.git
|
||||
- CodeFormer - https://github.com/sczhou/CodeFormer
|
||||
- ESRGAN - https://github.com/xinntao/ESRGAN
|
||||
- SwinIR - https://github.com/JingyunLiang/SwinIR
|
||||
- Swin2SR - https://github.com/mv-lab/swin2sr
|
||||
- LDSR - https://github.com/Hafiidz/latent-diffusion
|
||||
- MiDaS - https://github.com/isl-org/MiDaS
|
||||
- Ideas for optimizations - https://github.com/basujindal/stable-diffusion
|
||||
- Cross Attention layer optimization - Doggettx - https://github.com/Doggettx/stable-diffusion, original idea for prompt editing.
|
||||
- Cross Attention layer optimization - InvokeAI, lstein - https://github.com/invoke-ai/InvokeAI (originally http://github.com/lstein/stable-diffusion)
|
||||
- Sub-quadratic Cross Attention layer optimization - Alex Birch (https://github.com/Birch-san/diffusers/pull/1), Amin Rezaei (https://github.com/AminRezaei0x443/memory-efficient-attention)
|
||||
- Textual Inversion - Rinon Gal - https://github.com/rinongal/textual_inversion (we're not using his code, but we are using his ideas).
|
||||
- Idea for SD upscale - https://github.com/jquesnelle/txt2imghd
|
||||
- Noise generation for outpainting mk2 - https://github.com/parlance-zz/g-diffuser-bot
|
||||
- CLIP interrogator idea and borrowing some code - https://github.com/pharmapsychotic/clip-interrogator
|
||||
- Idea for Composable Diffusion - https://github.com/energy-based-model/Compositional-Visual-Generation-with-Composable-Diffusion-Models-PyTorch
|
||||
- xformers - https://github.com/facebookresearch/xformers
|
||||
- DeepDanbooru - interrogator for anime diffusers https://github.com/KichangKim/DeepDanbooru
|
||||
- Sampling in float32 precision from a float16 UNet - marunine for the idea, Birch-san for the example Diffusers implementation (https://github.com/Birch-san/diffusers-play/tree/92feee6)
|
||||
- Instruct pix2pix - Tim Brooks (star), Aleksander Holynski (star), Alexei A. Efros (no star) - https://github.com/timothybrooks/instruct-pix2pix
|
||||
- Security advice - RyotaK
|
||||
- Initial Gradio script - posted on 4chan by an Anonymous user. Thank you Anonymous user.
|
||||
- (You)
|
||||
> ./automatic.sh install
|
||||
|
||||
- Install requirements and exit
|
||||
|
||||
> ./automatic.sh public
|
||||
|
||||
- Start with listen on public IP with authentication enabled
|
||||
|
||||
> ./automatic.sh clean
|
||||
|
||||
- Start with all optimizations disabled
|
||||
Use this for troubleshooting
|
||||
|
||||
<br>
|
||||
|
||||
## Differences
|
||||
|
||||
Fork does differ in few things:
|
||||
- Drops compatibility with `python` **3.7** and requires **3.9**
|
||||
- Updated **Python** libraries to latest known compatible versions
|
||||
e.g. `accelerate`, `transformers`, `numpy`, etc.
|
||||
- Includes opinionated **System** and **Options** configuration
|
||||
e.g. `samplers`, `upscalers`, etc.
|
||||
- Includes reskinned **UI**
|
||||
Black and orange dark theme with fixed width options panels and larger previews
|
||||
- Includes **SD2** configuration files
|
||||
- Uses simplified folder structure
|
||||
e.g. `/train`, `/outputs/*`
|
||||
- Modified training templates
|
||||
|
||||
Only Python library which is not auto-updated is `PyTorch` itself as that is very system specific
|
||||
For some Torch optimizations notes, see Wiki
|
||||
|
||||
Fork is compatible with regular **PyTorch 1.13** as well as pre-release of **PyTorch 2.0**
|
||||
See [Wiki](https://github.com/vladmandic/automatic/wiki) for **Torch** optimization notes
|
||||
|
||||
|
||||
<br>
|
||||
|
||||
## Docs
|
||||
|
||||
Everything is in [Wiki](https://github.com/vladmandic/automatic/wiki)
|
||||
Except my current [TODO](TODO.md)
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ from modules.sdapi import get, post, close
|
|||
from modules.grid import grid
|
||||
|
||||
|
||||
default = 'sd-v15-runwayml.ckpt [cc6cb27103]'
|
||||
embeddings = ['blonde', 'bruntette', 'sexy', 'naked', 'mia', 'lin', 'kelly', 'hanna', 'rreid-random-v0']
|
||||
exclude = ['sd-v20', 'sd-v21', 'inpainting', 'pix2pix']
|
||||
prompt = "photo of beautiful woman <embedding>, photograph, posing, pose, high detailed, intricate, elegant, sharp focus, skin texture, looking forward, facing camera, 135mm, shot on dslr, canon 5d, 4k, modelshoot style, cinematic lighting"
|
||||
|
|
@ -69,16 +70,16 @@ async def models(params):
|
|||
models.append(short)
|
||||
log.info({ 'models preview' })
|
||||
log.info({ 'models': len(models), 'excluded': len(excluded) })
|
||||
log.info({ 'embeddings': len(embeddings) })
|
||||
log.info({ 'batch size': options.generate.batch_size })
|
||||
log.info({ 'embeddings': embeddings })
|
||||
log.info({ 'total jobs': len(models) * len(embeddings) * options.generate.batch_size, 'per-model': len(embeddings) * options.generate.batch_size })
|
||||
log.info(json.dumps(options, indent=2))
|
||||
# models = ['sd-v15-runwayml.ckpt [cc6cb27103]']
|
||||
|
||||
for model in models:
|
||||
fn = os.path.join(params.output, model + '.jpg')
|
||||
if os.path.exists(fn):
|
||||
log.info({ 'model': model, 'model preview exists': fn })
|
||||
if os.path.exists(fn) and len(params.input) == 0: # if model preview exists and not manually included
|
||||
log.info({ 'model preview exists': model })
|
||||
continue
|
||||
log.info({ 'model load': model })
|
||||
opt = await get('/sdapi/v1/options')
|
||||
opt['sd_model_checkpoint'] = model
|
||||
await post('/sdapi/v1/options', opt)
|
||||
|
|
@ -87,7 +88,7 @@ async def models(params):
|
|||
t0 = time.time()
|
||||
for embedding in embeddings:
|
||||
options.generate.prompt = prompt.replace('<embedding>', f'\"{embedding}\"')
|
||||
log.info({ 'model': model, 'embedding': embedding, 'prompt': options.generate.prompt })
|
||||
log.info({ 'model generating': model, 'embedding': embedding, 'prompt': options.generate.prompt })
|
||||
data = await generate(options = options, quiet=True)
|
||||
if 'image' in data:
|
||||
for img in data['image']:
|
||||
|
|
@ -99,8 +100,15 @@ async def models(params):
|
|||
image = grid(images = images, labels = labels, border = 8)
|
||||
image.save(fn)
|
||||
t = t1 - t0
|
||||
its = 1.0 * options.generate.batch_size * len(images) / t
|
||||
log.info({ 'model': model, 'created preview': fn, 'images': len(images), 'grid': [image.width, image.height], 'time': round(t, 2), 'its': round(its, 2) })
|
||||
its = 1.0 * options.generate.steps * len(images) / t
|
||||
log.info({ 'model preview created': model, 'image': fn, 'images': len(images), 'grid': [image.width, image.height], 'time': round(t, 2), 'its': round(its, 2) })
|
||||
|
||||
opt = await get('/sdapi/v1/options')
|
||||
if opt['sd_model_checkpoint'] != default:
|
||||
log.info({ 'model set default': default })
|
||||
opt['sd_model_checkpoint'] = default
|
||||
await post('/sdapi/v1/options', opt)
|
||||
|
||||
await close()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@
|
|||
"training_enable_tensorboard": false,
|
||||
"training_tensorboard_save_images": false,
|
||||
"training_tensorboard_flush_every": 120,
|
||||
"sd_model_checkpoint": "zeipher-f222",
|
||||
"sd_model_checkpoint": "sd-v15-runwayml.ckpt [cc6cb27103]",
|
||||
"sd_checkpoint_cache": 0,
|
||||
"sd_vae_checkpoint_cache": 0,
|
||||
"sd_vae": "vae-ft-mse-840000-ema-pruned.ckpt",
|
||||
|
|
@ -144,7 +144,7 @@
|
|||
"sdweb-merge-board",
|
||||
"ScuNET"
|
||||
],
|
||||
"sd_checkpoint_hash": "22fdccddef1a2466198c02851f26d76cd5a08430d231083ee4958de662c1a8e0",
|
||||
"sd_checkpoint_hash": "cc6cb27103417325ff94f52b7a5d2dde45a7515b25c255d8e396c90014281516",
|
||||
"ldsr_steps": 100,
|
||||
"ldsr_cached": false,
|
||||
"SWIN_tile": 192,
|
||||
|
|
@ -179,5 +179,6 @@
|
|||
"lora_apply_to_outputs": false,
|
||||
"outdir_ip2p_samples": "outputs/ip2p-images",
|
||||
"postprocessing_enable_in_main_ui": [],
|
||||
"postprocessing_operation_order": []
|
||||
"postprocessing_operation_order": [],
|
||||
"sd_lora": "None"
|
||||
}
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit a89b56057be0d13d28e0a3149243a9b188e8aa6e
|
||||
Subproject commit 4748f4a90e180ecfd585e46d7338659eeacafe77
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit e91497c0dea92cb6fcccdd1109a648be4b86bea0
|
||||
Subproject commit 4325abb42b6ad25f9e8816b4787cb71307e2994c
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 82a51b31f37439dd571747196820e42ef26d4572
|
||||
Subproject commit 50e4a2d86f8eb95a48799b4c3c3c31d930698c67
|
||||
|
|
@ -37,7 +37,7 @@ parser.add_argument("--no-half-vae", action='store_true', help="do not switch th
|
|||
parser.add_argument("--no-progressbar-hiding", action='store_true', help="do not hide progressbar in gradio UI (we hide it because it slows down ML if you have hardware acceleration in browser)")
|
||||
parser.add_argument("--max-batch-count", type=int, default=16, help="maximum batch count value for the UI")
|
||||
parser.add_argument("--embeddings-dir", type=str, default=os.path.join(data_path, 'embeddings'), help="embeddings directory for textual inversion (default: embeddings)")
|
||||
parser.add_argument("--textual-inversion-templates-dir", type=str, default=os.path.join(script_path, 'textual_inversion_templates'), help="directory with textual inversion templates")
|
||||
parser.add_argument("--textual-inversion-templates-dir", type=str, default=os.path.join(script_path, 'train/templates'), help="directory with textual inversion templates")
|
||||
parser.add_argument("--hypernetwork-dir", type=str, default=os.path.join(models_path, 'hypernetworks'), help="hypernetwork directory")
|
||||
parser.add_argument("--localizations-dir", type=str, default=os.path.join(script_path, 'localizations'), help="localizations directory")
|
||||
parser.add_argument("--allow-code", action='store_true', help="allow custom script execution from webui")
|
||||
|
|
@ -105,6 +105,7 @@ parser.add_argument("--tls-keyfile", type=str, help="Partially enables TLS, requ
|
|||
parser.add_argument("--tls-certfile", type=str, help="Partially enables TLS, requires --tls-keyfile to fully function", default=None)
|
||||
parser.add_argument("--server-name", type=str, help="Sets hostname of server", default=None)
|
||||
parser.add_argument("--gradio-queue", action='store_true', help="Uses gradio queue; experimental option; breaks restart UI button")
|
||||
parser.add_argument("--compile", type=str, help="Use Torch Dynamo compile with specified backend", default=None)
|
||||
|
||||
|
||||
script_loading.preload_extensions(extensions.extensions_dir, parser)
|
||||
|
|
|
|||
|
|
@ -842,5 +842,7 @@
|
|||
"customscript/xyz_grid.py/img2img/Include Sub Grids/visible": true,
|
||||
"customscript/xyz_grid.py/img2img/Include Sub Grids/value": false,
|
||||
"customscript/xyz_grid.py/img2img/Keep -1 for seeds/visible": true,
|
||||
"customscript/xyz_grid.py/img2img/Keep -1 for seeds/value": false
|
||||
"customscript/xyz_grid.py/img2img/Keep -1 for seeds/value": false,
|
||||
"img2img/Inpaint batch mask directory (required for inpaint batch processing only)/visible": true,
|
||||
"img2img/Inpaint batch mask directory (required for inpaint batch processing only)/value": ""
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
@echo off
|
||||
|
||||
if not defined PYTHON (set PYTHON=python)
|
||||
if not defined VENV_DIR (set "VENV_DIR=%~dp0%venv")
|
||||
|
||||
|
||||
set ERROR_REPORTING=FALSE
|
||||
|
||||
mkdir tmp 2>NUL
|
||||
|
||||
%PYTHON% -c "" >tmp/stdout.txt 2>tmp/stderr.txt
|
||||
if %ERRORLEVEL% == 0 goto :check_pip
|
||||
echo Couldn't launch python
|
||||
goto :show_stdout_stderr
|
||||
|
||||
:check_pip
|
||||
%PYTHON% -mpip --help >tmp/stdout.txt 2>tmp/stderr.txt
|
||||
if %ERRORLEVEL% == 0 goto :start_venv
|
||||
if "%PIP_INSTALLER_LOCATION%" == "" goto :show_stdout_stderr
|
||||
%PYTHON% "%PIP_INSTALLER_LOCATION%" >tmp/stdout.txt 2>tmp/stderr.txt
|
||||
if %ERRORLEVEL% == 0 goto :start_venv
|
||||
echo Couldn't install pip
|
||||
goto :show_stdout_stderr
|
||||
|
||||
:start_venv
|
||||
if ["%VENV_DIR%"] == ["-"] goto :skip_venv
|
||||
if ["%SKIP_VENV%"] == ["1"] goto :skip_venv
|
||||
|
||||
dir "%VENV_DIR%\Scripts\Python.exe" >tmp/stdout.txt 2>tmp/stderr.txt
|
||||
if %ERRORLEVEL% == 0 goto :activate_venv
|
||||
|
||||
for /f "delims=" %%i in ('CALL %PYTHON% -c "import sys; print(sys.executable)"') do set PYTHON_FULLNAME="%%i"
|
||||
echo Creating venv in directory %VENV_DIR% using python %PYTHON_FULLNAME%
|
||||
%PYTHON_FULLNAME% -m venv "%VENV_DIR%" >tmp/stdout.txt 2>tmp/stderr.txt
|
||||
if %ERRORLEVEL% == 0 goto :activate_venv
|
||||
echo Unable to create venv in directory "%VENV_DIR%"
|
||||
goto :show_stdout_stderr
|
||||
|
||||
:activate_venv
|
||||
set PYTHON="%VENV_DIR%\Scripts\Python.exe"
|
||||
echo venv %PYTHON%
|
||||
|
||||
:skip_venv
|
||||
if [%ACCELERATE%] == ["True"] goto :accelerate
|
||||
goto :launch
|
||||
|
||||
:accelerate
|
||||
echo Checking for accelerate
|
||||
set ACCELERATE="%VENV_DIR%\Scripts\accelerate.exe"
|
||||
if EXIST %ACCELERATE% goto :accelerate_launch
|
||||
|
||||
:launch
|
||||
%PYTHON% launch.py %*
|
||||
pause
|
||||
exit /b
|
||||
|
||||
:accelerate_launch
|
||||
echo Accelerating
|
||||
%ACCELERATE% launch --num_cpu_threads_per_process=6 launch.py
|
||||
pause
|
||||
exit /b
|
||||
|
||||
:show_stdout_stderr
|
||||
|
||||
echo.
|
||||
echo exit code: %errorlevel%
|
||||
|
||||
for /f %%i in ("tmp\stdout.txt") do set size=%%~zi
|
||||
if %size% equ 0 goto :show_stderr
|
||||
echo.
|
||||
echo stdout:
|
||||
type tmp\stdout.txt
|
||||
|
||||
:show_stderr
|
||||
for /f %%i in ("tmp\stderr.txt") do set size=%%~zi
|
||||
if %size% equ 0 goto :show_stderr
|
||||
echo.
|
||||
echo stderr:
|
||||
type tmp\stderr.txt
|
||||
|
||||
:endofscript
|
||||
|
||||
echo.
|
||||
echo Launch unsuccessful. Exiting.
|
||||
pause
|
||||
2
wiki
2
wiki
|
|
@ -1 +1 @@
|
|||
Subproject commit d475aa073b421bfe695326dbc9aedd9100c2425a
|
||||
Subproject commit e3290140e6cfdb57b523dbbb0aba90963ec90138
|
||||
Loading…
Reference in New Issue