Skip to content

Commit

Permalink
Cleanup some local script
Browse files Browse the repository at this point in the history
  • Loading branch information
tqchen committed Mar 8, 2023
1 parent 05aa87d commit 0387ce4
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 31 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dist/
params/
**/*.png

*.bak
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -315,3 +315,5 @@ gallery/how_to/work_with_microtvm/micro_tvmc.py

# GDB history file
.gdb_history

3rdparty
16 changes: 6 additions & 10 deletions web/local_deploy.sh → scripts/build_site.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
#!/bin/bash
set -euxo pipefail
PROJ_ROOT=`pwd`

if [[ ! -f $1 ]]; then
echo "cannot find config" $1
fi

rm -rf site/dist
mkdir -p site/dist site/_inlcudes

echo "Copy local configurations.."
cp web/local-config.json site/stable-diffusion-config.json

cp $1 site/stable-diffusion-config.json
echo "Copy files..."
cp web/stable_diffusion.html site/_includes
cp web/stable_diffusion.js site/dist


cp dist/scheduler_consts.json site/dist
cp dist/stable_diffusion_webgpu.wasm site/dist

cp dist/tvmjs_runtime.wasi.js site/dist
cp dist/tvmjs.bundle.js site/dist
cp -r dist/tokenizers-wasm site/dist

cd site && jekyll b

echo "symlink parameter location to site.."
ln -s ${PROJ_ROOT}/dist/params _site/dist/webgpu-sd-v1-5

jekyll serve --skip-initial-build --baseurl /web-stable-diffusion --port 8888
cd site && jekyll b && cd ..
17 changes: 17 additions & 0 deletions scripts/gh_deploy_site.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
set -euxo pipefail

scripts/build_site.sh dist/gh-page-config.json

git fetch
git checkout -B gh-pages origin/gh-pages
rm -rf docs .gitignore
mkdir -p docs
cp -rf site/_site/* docs
touch docs/.nojekyll

DATE=`date`
git add docs && git commit -am "Build at ${DATE}"
git push origin gh-pages
git checkout main && git submodule update
echo "Finish deployment at ${DATE}"
9 changes: 9 additions & 0 deletions scripts/local_deploy_site.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -euxo pipefail

scripts/build_site.sh web/local-config.json

echo "symlink parameter location to site.."

ln -s `pwd`/dist/params site/_site/dist/webgpu-sd-v1-5
cd site && jekyll serve --skip-initial-build --host localhost --baseurl /web-stable-diffusion --port 8888
29 changes: 29 additions & 0 deletions scripts/prep_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
# This file prepares all the necessary dependencies for the web build.
set -euxo pipefail

emcc --version
npm --version
cargo --version

TVM_HOME_SET="${TVM_HOME:-}"

if [[ -z ${TVM_HOME_SET} ]]; then
if [[ ! -d "3rdparty/tvm" ]]; then
echo "Do not find TVM_HOME env variable, cloning a version as source".
git clone https://github.com/apache/tvm 3rdparty/tvm --branch unity --recursive
fi
export TVM_HOME="${TVM_HOME:-3rdparty/tvm}"
fi

export TOKENZIER_WASM_HOME="3rdparty/tokenizers-wasm"

mkdir -p dist
cd ${TVM_HOME}/web && make && npm install && npm run bundle && cd -
git submodule update --init
cd ${TOKENZIER_WASM_HOME} && wasm-pack build --target web && cd -
rm -rf dist/tokenizers-wasm
cp -r ${TOKENZIER_WASM_HOME}/pkg dist/tokenizers-wasm

echo "Exporting tvmjs runtime dist files"
python -c "from tvm.contrib import tvmjs; tvmjs.export_runtime(\"dist\")"
29 changes: 29 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from distutils.core import setup
from setuptools import find_packages

# Note there is no need to setup when
# running locally in this folder.

setup(
name = "web-stable-diffusion",
version = "0.1.0",
license="Apache-2.0",
description = "Stable diffusion on browser",
author = "Web stable diffusion contributors",
url = "https://github.com/mlc-ai/web-stable-diffusion",
keywords = [],
packages = find_packages(),
install_requires = [
"torch",
"diffusers",
"transformers"
],
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Topic :: Software Development :: Build Tools",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
],
)
2 changes: 1 addition & 1 deletion site/_config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

name: "Web Stable Diffusion"
short_name: "WiSe"
short_name: "WebSD"

url: https://mlc.ai/web-stable-diffusion

Expand Down
3 changes: 0 additions & 3 deletions site/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,4 @@ notitle: true

# Web Stable Diffusion


This is a page

{% include stable_diffusion.html %}
15 changes: 0 additions & 15 deletions web/prep_deps.sh

This file was deleted.

2 changes: 1 addition & 1 deletion web/stable_diffusion.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ <h2> Image Generation Demo </h2>
id="inputPrompt"
type="text"
value="A photo of an astronaut riding a horse on mars"
size="77"/>
size="77"/> <br>
Negative Prompt(can be left empty) <input
name="negativePrompt"
id="negativePrompt"
Expand Down

0 comments on commit 0387ce4

Please sign in to comment.