Upload 2 files
Browse files- app.py +68 -0
- requirements.txt +16 -0
app.py
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# -*- coding: utf-8 -*-
|
| 2 |
+
# Copyright @ 2023 wdcqc/aieud project.
|
| 3 |
+
# Open-source under license obtainable in project root (LICENSE.md).
|
| 4 |
+
|
| 5 |
+
import subprocess
|
| 6 |
+
|
| 7 |
+
# taken from automatic1111 UI
|
| 8 |
+
def run(command, desc=None, errdesc=None, custom_env=None):
|
| 9 |
+
if desc is not None:
|
| 10 |
+
print(desc)
|
| 11 |
+
|
| 12 |
+
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, env=os.environ if custom_env is None else custom_env)
|
| 13 |
+
|
| 14 |
+
if result.returncode != 0:
|
| 15 |
+
|
| 16 |
+
message = f"""{errdesc or 'Error running command'}.
|
| 17 |
+
Command: {command}
|
| 18 |
+
Error code: {result.returncode}
|
| 19 |
+
stdout: {result.stdout.decode(encoding="utf8", errors="ignore") if len(result.stdout)>0 else '<empty>'}
|
| 20 |
+
stderr: {result.stderr.decode(encoding="utf8", errors="ignore") if len(result.stderr)>0 else '<empty>'}
|
| 21 |
+
"""
|
| 22 |
+
raise RuntimeError(message)
|
| 23 |
+
|
| 24 |
+
return result.stdout.decode(encoding="utf8", errors="ignore")
|
| 25 |
+
|
| 26 |
+
# taken from automatic1111 UI
|
| 27 |
+
def check_run(command):
|
| 28 |
+
result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
| 29 |
+
return result.returncode == 0
|
| 30 |
+
|
| 31 |
+
# taken from automatic1111 UI, didn't even fix the TODO
|
| 32 |
+
def git_clone(url, dir, name, commithash=None):
|
| 33 |
+
# TODO clone into temporary dir and move if successful
|
| 34 |
+
git = os.environ.get('GIT', "git")
|
| 35 |
+
|
| 36 |
+
if os.path.exists(dir):
|
| 37 |
+
if commithash is None:
|
| 38 |
+
return
|
| 39 |
+
|
| 40 |
+
current_hash = run(f'"{git}" -C {dir} rev-parse HEAD', None, f"Couldn't determine {name}'s hash: {commithash}").strip()
|
| 41 |
+
if current_hash == commithash:
|
| 42 |
+
return
|
| 43 |
+
|
| 44 |
+
run(f'"{git}" -C {dir} fetch', f"Fetching updates for {name}...", f"Couldn't fetch {name}")
|
| 45 |
+
run(f'"{git}" -C {dir} checkout {commithash}', f"Checking out commit for {name} with hash: {commithash}...", f"Couldn't checkout commit {commithash} for {name}")
|
| 46 |
+
return
|
| 47 |
+
|
| 48 |
+
run(f'"{git}" clone "{url}" "{dir}"', f"Cloning {name} into {dir}...", f"Couldn't clone {name}")
|
| 49 |
+
|
| 50 |
+
if commithash is not None:
|
| 51 |
+
run(f'"{git}" -C {dir} checkout {commithash}', None, "Couldn't checkout {name}'s hash: {commithash}")
|
| 52 |
+
|
| 53 |
+
if __name__ == "__main__":
|
| 54 |
+
import time
|
| 55 |
+
import argparse
|
| 56 |
+
|
| 57 |
+
git_clone("https://github.com/wdcqc/WaveFunctionDiffusion.git", ".", "WaveFunctionDiffusion")
|
| 58 |
+
time.sleep(5.88)
|
| 59 |
+
|
| 60 |
+
from wfd.webui import start_demo
|
| 61 |
+
parser = argparse.ArgumentParser(description="Demo script for WaveFunctionDiffusion.")
|
| 62 |
+
parser.add_argument(
|
| 63 |
+
"--colab",
|
| 64 |
+
action="store_true",
|
| 65 |
+
help="Use it in Google Colab.",
|
| 66 |
+
)
|
| 67 |
+
args = parser.parse_args()
|
| 68 |
+
start_demo(args)
|
requirements.txt
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
accelerate
|
| 2 |
+
bitsandbytes
|
| 3 |
+
diffusers
|
| 4 |
+
doki_theme_jupyter
|
| 5 |
+
einops
|
| 6 |
+
gradio
|
| 7 |
+
huggingface_hub
|
| 8 |
+
numpy
|
| 9 |
+
opencv_python
|
| 10 |
+
packaging
|
| 11 |
+
Pillow
|
| 12 |
+
torch
|
| 13 |
+
torchinfo
|
| 14 |
+
torchvision
|
| 15 |
+
tqdm
|
| 16 |
+
transformers
|