wfd / app.py
wdcqc's picture
Update app.py
fdf60dd
raw
history blame
2.56 kB
# -*- coding: utf-8 -*-
# Copyright @ 2023 wdcqc/aieud project.
# Open-source under license obtainable in project root (LICENSE.md).
import argparse
import os
import urllib.request
import json
def fix_theme(theme):
try:
with open("/home/user/.local/lib/python3.8/site-packages/wfd/webui/doki_settings.json", encoding = "utf-8") as fp:
doki = json.load(fp)
doki["theme"] = theme
with open("/home/user/.local/lib/python3.8/site-packages/wfd/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):
# probably should include the tile files in the package. let's get it running first.
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):
# fixed by adding files to package_data and set include_package_data=True in setup.py
target_path = "/home/user/.local/lib/python3.8/site-packages/wfd/{}".format(path)
if not os.path.exists(target_path):
try:
os.makedirs("/home/user/.local/lib/python3.8/site-packages/wfd/{}".format(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__":
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)