Skip to content

Commit 3e62374

Browse files
authored
Merge pull request #38 from sunxfancy/dev
Merge dev
2 parents c4bee66 + b95b8e6 commit 3e62374

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+3576
-539
lines changed

.github/workflows/quicktest.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@ jobs:
1515
runs-on: ${{ matrix.os }}
1616
strategy:
1717
matrix:
18-
os: [windows-latest, macOS-latest]
18+
include:
19+
- os: windows-latest
20+
platform: windows
21+
- os: macOS-latest
22+
platform: macosx
23+
- os: ubuntu-latest
24+
platform: linux
1925

2026
steps:
2127
- uses: actions/checkout@v4
22-
28+
2329
- name: Set Node.js 22.x
2430
uses: actions/setup-node@v4
2531
with:
@@ -39,7 +45,13 @@ jobs:
3945
activate-environment: true
4046

4147
- name: Install requirements
42-
run: yarn requirements && uv pip install -r .venv/requirements.txt
48+
run: uv pip install -r dependencies/${{ matrix.platform }}.lock
49+
50+
- name: Install system dependencies
51+
if: ${{ matrix.platform == 'linux' }}
52+
run: |
53+
sudo apt-get update
54+
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libglib2.0-dev pkg-config
4355
4456
- name: Setup Rust
4557
uses: actions-rust-lang/setup-rust-toolchain@v1

.github/workflows/release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ jobs:
1818
matrix:
1919
include:
2020
- os: windows-latest
21+
platform: windows
2122
artifacts: |
2223
desktop/src-tauri/target/release/bundle/msi/*.msi
2324
desktop/src-tauri/target/release/bundle/nsis/*.exe
2425
2526
- os: macOS-latest
27+
platform: macosx
2628
artifacts: |
2729
desktop/src-tauri/target/release/bundle/dmg/*.dmg
2830
@@ -48,7 +50,7 @@ jobs:
4850
activate-environment: true
4951

5052
- name: Install requirements
51-
run: yarn requirements && uv pip install -r .venv/requirements.txt
53+
run: uv pip install -r dependencies/${{ matrix.platform }}.lock
5254

5355
- name: Setup Rust
5456
uses: actions-rust-lang/setup-rust-toolchain@v1

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ dist/
99
test_env/
1010
resources/
1111
log/
12+
models/
1213

1314
*.safetensors
1415
*.pt

Dockerfile

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# 构建阶段
2+
FROM nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04 as builder
3+
4+
# 设置环境变量
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
ENV PYTHONUNBUFFERED=1
7+
ENV PYTHONDONTWRITEBYTECODE=1
8+
9+
# 安装 Python 3.12
10+
RUN apt update && apt install -y software-properties-common \
11+
&& add-apt-repository ppa:deadsnakes/ppa \
12+
&& apt update \
13+
&& apt install -y \
14+
python3.12 \
15+
python3-pip \
16+
python3.12-venv \
17+
curl \
18+
&& rm -rf /var/lib/apt/lists/*
19+
20+
# 安装 Node.js 22
21+
ENV NVM_DIR /usr/local/nvm
22+
RUN mkdir -p $NVM_DIR \
23+
&& curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash \
24+
&& . $NVM_DIR/nvm.sh && nvm install 22 && nvm use 22 \
25+
&& corepack enable yarn && node -v && yarn -v
26+
27+
# 设置工作目录
28+
WORKDIR /app
29+
30+
# 创建 .dockerignore 文件
31+
RUN echo "__pycache__\n*.pyc\n*.pyo\n*.pyd\n.Python\nenv\npip-log.txt\npip-delete-this-directory.txt\n.tox\n.coverage\n.coverage.*\n.cache\nnosetests.xml\ncoverage.xml\n*.cover\n*.log\n.pytest_cache\n.env\n.venv\nvenv\nENV\nnode_modules\ndist\nbuild\n*.egg-info\n.installed.cfg\n*.egg" > .dockerignore
32+
33+
# 复制必要的项目文件
34+
COPY ssui/ ssui/
35+
COPY ss_executor/ ss_executor/
36+
COPY server/ server/
37+
COPY frontend/ frontend/
38+
COPY extension_builder/ extension_builder/
39+
COPY extensions/ extensions/
40+
COPY dependencies/ dependencies/
41+
COPY backend/ backend/
42+
COPY package.json package.json
43+
COPY yarn.lock yarn.lock
44+
45+
46+
# 创建并激活 Python 虚拟环境
47+
RUN python3.12 -m venv /app/.venv
48+
ENV PATH="/app/.venv/bin:$PATH"
49+
50+
# 安装 Python 依赖
51+
RUN pip install uv
52+
RUN uv pip install --no-cache-dir -r /app/dependencies/requirements-linux.txt
53+
54+
55+
# 安装 Node.js 依赖
56+
ENV SSUI_CI_SKIP_INSTALL=1
57+
RUN . $NVM_DIR/nvm.sh && yarn
58+
59+
# 构建前端
60+
RUN . $NVM_DIR/nvm.sh && yarn build:frontend
61+
62+
# 运行阶段
63+
FROM nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04
64+
65+
# 设置环境变量
66+
ENV DEBIAN_FRONTEND=noninteractive
67+
ENV PYTHONUNBUFFERED=1
68+
ENV PYTHONDONTWRITEBYTECODE=1
69+
70+
# 安装运行时依赖
71+
RUN apt update && apt install -y software-properties-common \
72+
&& add-apt-repository ppa:deadsnakes/ppa \
73+
&& apt update \
74+
&& apt install -y \
75+
python3.12 \
76+
python3-pip \
77+
python3.12-venv \
78+
&& rm -rf /var/lib/apt/lists/*
79+
80+
# 设置工作目录
81+
WORKDIR /app
82+
83+
# 从构建阶段复制虚拟环境
84+
COPY --from=builder /app/.venv /app/.venv
85+
ENV PATH="/app/.venv/bin:$PATH"
86+
87+
# 从构建阶段复制必要的目录
88+
COPY --from=builder /app/ssui /app/ssui
89+
COPY --from=builder /app/ss_executor /app/ss_executor
90+
COPY --from=builder /app/server /app/server
91+
COPY --from=builder /app/frontend/functional_ui/dist /app/frontend/functional_ui/dist
92+
COPY --from=builder /app/extensions /app/extensions
93+
COPY --from=builder /app/dependencies /app/dependencies
94+
COPY --from=builder /app/backend /app/backend
95+
96+
RUN apt update && apt install -y ffmpeg libsm6 libxext6
97+
98+
99+
# 暴露端口
100+
EXPOSE 7422
101+
102+
# 设置启动命令
103+
CMD ["bash", "-c", "python -m ss_executor & exec python -m server --host 0.0.0.0"]

backend/patches/layers/lora_layer_base.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ def get_parameters(self, orig_parameters: dict[str, torch.Tensor], weight: float
7171
params[param_name] = param_weight.reshape(get_param_shape(orig_param))
7272

7373
return params
74+
75+
@classmethod
76+
def warn_on_unhandled_keys(cls, values: dict[str, torch.Tensor], handled_keys: set[str]):
77+
"""Log a warning if values contains unhandled keys."""
78+
unknown_keys = set(values.keys()) - handled_keys
79+
if unknown_keys:
80+
# logger.warning(
81+
# f"Unexpected keys found in LoRA/LyCORIS layer, model might work incorrectly! Unexpected keys: {unknown_keys}"
82+
# )
83+
pass
7484

7585
def calc_size(self) -> int:
7686
return calc_tensors_size([self.bias])

backend/stable_diffusion/extensions/lora.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __init__(
2525

2626
@contextmanager
2727
def patch_unet(self, unet: UNet2DConditionModel, original_weights: OriginalWeightsStorage):
28-
lora_model = self._lora_model
28+
lora_model = self._lora_model.lora.model
2929
assert isinstance(lora_model, ModelPatchRaw)
3030
LayerPatcher.apply_smart_model_patch(
3131
model=unet,

dependencies/install.cmd

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
@echo off
22
@setlocal enabledelayedexpansion
33

4-
rem 创建.build文件夹并将Python放入其中
4+
rem Create .build folder and put Python in it
55
if not exist ".venv" mkdir .venv
66

7-
rem 检查Python是否已经存在
7+
rem Check if Python already exists
88
if not exist ".venv\python\python.exe" (
9-
rem 检查操作系统类型
9+
rem Check operating system type
1010
set PYTHON_VERSION=3.12.8
1111
set RELEASE_DATE=20241219
1212

13-
rem 检查处理器架构
13+
rem Check processor architecture
1414
if /I "!PROCESSOR_ARCHITECTURE!"=="x86" (
1515
set ARCH=i686-pc-windows-msvc
1616
) else if /I "!PROCESSOR_ARCHITECTURE!"=="AMD64" (
@@ -20,11 +20,11 @@ if not exist ".venv\python\python.exe" (
2020
exit /b
2121
)
2222

23-
rem 设置下载链接
23+
rem Set download URLs
2424
set DOWNLOAD_URL=https://github.com/astral-sh/python-build-standalone/releases/download/!RELEASE_DATE!/cpython-!PYTHON_VERSION!+!RELEASE_DATE!-!ARCH!-install_only_stripped.tar.gz
2525
set CHINA_MIRROR=https://gitee.com/Swordtooth/ssui_assets/releases/download/v0.0.2/cpython-!PYTHON_VERSION!%!RELEASE_DATE!-!ARCH!-install_only_stripped.tar.gz
2626

27-
rem 尝试从GitHub下载Python
27+
rem Try to download Python from GitHub
2828
echo "Trying to download Python from GitHub..."
2929
curl -L !DOWNLOAD_URL! -o .venv\python.tar.gz
3030
if errorlevel 1 (
@@ -40,9 +40,9 @@ if not exist ".venv\python\python.exe" (
4040
powershell -Command "Remove-Item -Path '.venv\python.tar.gz' -Force"
4141
)
4242

43-
rem 检查虚拟环境是否已经存在
43+
rem Check if virtual environment already exists
4444
if not exist ".venv\Scripts\python.exe" (
45-
rem 使用virtualenv创建虚拟环境
45+
rem Create virtual environment using venv
4646
echo "Creating virtual environment..."
4747
.venv\python\python.exe -m venv .venv
4848
)

dependencies/install.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
#!/bin/bash
22

3-
# 创建.venv文件夹
3+
# Create .venv folder
44
mkdir -p .venv
55

6-
# 检查Python是否已经存在
6+
# Check if Python already exists
77
if [ ! -f ".venv/python/bin/python3" ]; then
8-
# 设置Python版本和发布日期
8+
# Set Python version and release date
99
PYTHON_VERSION="3.12.8"
1010
RELEASE_DATE="20241219"
1111

12-
# 检查操作系统类型
12+
# Check operating system type
1313
OS_TYPE=$(uname -s)
1414
ARCHITECTURE=$(uname -m)
1515

16-
# 根据操作系统和架构设置下载参数
16+
# Set download parameters based on OS and architecture
1717
if [ "$OS_TYPE" = "Darwin" ]; then
1818
# macOS
1919
if [ "$ARCHITECTURE" = "x86_64" ]; then
@@ -40,11 +40,11 @@ if [ ! -f ".venv/python/bin/python3" ]; then
4040
fi
4141
https://github.com/astral-sh/python-build-standalone/releases/download/20241219/cpython-3.12.8+20241219-${ARCH}-install_only_stripped.tar.gz
4242

43-
# 设置下载链接
43+
# Set download URLs
4444
DOWNLOAD_URL="https://github.com/astral-sh/python-build-standalone/releases/download/${RELEASE_DATE}/cpython-${PYTHON_VERSION}+${RELEASE_DATE}-${ARCH}-install_only_stripped.tar.gz"
4545
CHINA_MIRROR="https://gitee.com/Swordtooth/ssui_assets/releases/download/v0.0.2/cpython-${PYTHON_VERSION}%${RELEASE_DATE}-${ARCH}-install_only_stripped.tar.gz"
4646

47-
# 下载并解压Python
47+
# Download and extract Python
4848
echo "Downloading Python from ${DOWNLOAD_URL}..."
4949
if ! curl -L "${DOWNLOAD_URL}" -o .venv/python.tar.gz; then
5050
echo "Failed to download from primary source, trying Chinese mirror..."
@@ -54,19 +54,19 @@ if [ ! -f ".venv/python/bin/python3" ]; then
5454
fi
5555
fi
5656

57-
# 解压文件
57+
# Extract files
5858
tar -xzf .venv/python.tar.gz -C .venv
5959
rm .venv/python.tar.gz
6060
fi
6161

62-
# 检查虚拟环境是否已经存在
62+
# Check if virtual environment already exists
6363
if [ ! -f ".venv/bin/python" ]; then
64-
# 创建虚拟环境
64+
# Create virtual environment
6565
echo "Creating virtual environment..."
6666
.venv/python/bin/python3 -m venv .venv
6767
fi
6868

69-
# 检查并安装uv工具
69+
# Check and install uv tool
7070
if [ ! -f ".venv/bin/uv" ]; then
7171
echo "Installing uv tool..."
7272
.venv/bin/python -m pip install uv==0.6.11
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const { platform } = require('os');
2+
const { execSync } = require('child_process');
3+
const path = require('path');
4+
5+
function getRequirementsFile() {
6+
const os = platform();
7+
if (os === 'win32') {
8+
return path.join(__dirname, 'windows.lock');
9+
} else if (os === 'darwin') {
10+
return path.join(__dirname, 'macosx.lock');
11+
} else if (os === 'linux') {
12+
return path.join(__dirname, 'linux.lock');
13+
} else {
14+
throw new Error(`Unsupported operating system: ${os}`);
15+
}
16+
}
17+
18+
try {
19+
const requirementsFile = getRequirementsFile();
20+
console.log(`Installing requirements from: ${requirementsFile}`);
21+
22+
// 使用 venv.cjs 来执行 uv pip 命令
23+
execSync(`node ${path.join(__dirname, 'venv.cjs')} uv pip install -r "${requirementsFile}"`, {
24+
stdio: 'inherit'
25+
});
26+
27+
console.log('Requirements installed successfully!');
28+
} catch (error) {
29+
console.error('Error installing requirements:', error.message);
30+
process.exit(1);
31+
}

0 commit comments

Comments
 (0)