|
|
|
|
|
|
|
import argparse |
|
import os |
|
import urllib.request |
|
import json |
|
import tqdm |
|
|
|
|
|
SITE_PACKAGES_DIR = os.path.dirname(os.path.dirname(tqdm.__file__)) |
|
WFD_DIR = os.path.join(SITE_PACKAGES_DIR, "wfd") |
|
|
|
def fix_theme(theme): |
|
try: |
|
with open(os.path.join(WFD_DIR, "webui/doki_settings.json"), encoding = "utf-8") as fp: |
|
doki = json.load(fp) |
|
|
|
doki["theme"] = theme |
|
|
|
with open(os.path.join(WFD_DIR, "webui/doki_settings.json"), "w", encoding = "utf-8") as fp: |
|
json.dump(doki, fp) |
|
except Exception as e: |
|
print(e) |
|
|
|
def fix_local_file(path): |
|
|
|
if not os.path.exists(path): |
|
try: |
|
os.makedirs(os.path.dirname(path)) |
|
except Exception as e: |
|
print(e) |
|
try: |
|
urllib.request.urlretrieve( |
|
"https://github.com/wdcqc/WaveFunctionDiffusion/raw/remaster/{}".format(path), |
|
path |
|
) |
|
except Exception as e: |
|
print(e) |
|
|
|
def fix_package_file(path): |
|
|
|
target_path = os.path.join(WFD_DIR, path) |
|
if not os.path.exists(target_path): |
|
try: |
|
os.makedirs(os.path.join(WFD_DIR, os.path.dirname(path))) |
|
except Exception as e: |
|
print(e) |
|
try: |
|
urllib.request.urlretrieve( |
|
"https://github.com/wdcqc/WaveFunctionDiffusion/raw/remaster/wfd/{}".format(path), |
|
target_path |
|
) |
|
except Exception as e: |
|
print(e) |
|
else: |
|
print("{} is fixed!".format(path)) |
|
|
|
if __name__ == "__main__": |
|
print("SITE_PACKAGES_DIR =", SITE_PACKAGES_DIR) |
|
print("WFD_DIR =", WFD_DIR, "and it", "exists" if os.path.exists(WFD_DIR) else "does not exist") |
|
fix_package_file("mpqapi/libstorm.so") |
|
fix_package_file("webui/templates/tempura.css") |
|
fix_package_file("webui/templates/background.css") |
|
fix_package_file("webui/doki_settings.json") |
|
fix_local_file("tile_data/platform.cv5.bin") |
|
fix_local_file("tile_data/platform.png") |
|
fix_local_file("tile_data/platform_mapping.npz") |
|
fix_local_file("tile_data/platform_v2.npz") |
|
fix_local_file("tile_data/wfc/platform_32x32.npz") |
|
fix_local_file("default/base.chk") |
|
|
|
fix_theme("KonoSuba: Darkness Light") |
|
|
|
from wfd.webui import start_demo |
|
class Arguments: |
|
colab = False |
|
link_to_colab = True |
|
args = Arguments() |
|
start_demo(args) |
|
|