Skip to content

Commit ee3f6b9

Browse files
authored
add ci/cd pipeline (#2)
* add pre-commit Signed-off-by: Niclas Wesemann <niclas.wesmann@motius.de>
1 parent 5414e0c commit ee3f6b9

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

.github/workflows/pre-commit.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v3
13+
- uses: actions/setup-python@v3
14+
- uses: pre-commit/action@v3.0.1

src/touchdesigner_plugin/stream_diffusion_server.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
import glob
1+
import os
22
import socket
33
import struct
4-
import os
54
import sys
6-
from typing import Literal, Dict, Optional
5+
from typing import Literal
76

87
import cv2 as cv
98
import numpy as np
109

1110
from touchdesigner_plugin.constants import HOST, JPEG_ENCODE_QUALITY_PERCENT, PORT
12-
from touchdesigner_plugin.utilities import get_random_image
1311

1412
sys.path.append(os.path.join(os.path.dirname(__file__), "..", ".."))
1513

16-
from utils.wrapper import StreamDiffusionWrapper
14+
from utils.wrapper import StreamDiffusionWrapper # noqa: E402
1715

1816
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
1917

@@ -25,7 +23,7 @@ def __init__(self):
2523
self.server_socket.listen(5)
2624

2725
model_id_or_path: str = "KBlueLeaf/kohaku-v2.1"
28-
lora_dict: Optional[Dict[str, float]] = None
26+
lora_dict: dict[str, float] | None = None
2927
width: int = 512
3028
height: int = 512
3129
acceleration: Literal["none", "xformers", "tensorrt"] = "xformers"
@@ -54,12 +52,11 @@ def send_image(self, client_socket):
5452
# image = get_random_image(nb_circles=3, noise_background=False)
5553
image = np.array(self.stream())
5654

57-
5855
# NOTE: decrease JPEG_ENCODE_QUALITY_PERCENT to increase performance
5956
_, image_data = cv.imencode(
6057
".jpg", image, [int(cv.IMWRITE_JPEG_QUALITY), JPEG_ENCODE_QUALITY_PERCENT]
6158
)
62-
59+
6360
image_size = struct.pack("!I", len(image_data))
6461
client_socket.send(image_size)
6562
client_socket.send(image_data.tobytes())
@@ -78,7 +75,7 @@ def run(self):
7875
prompt=prompt,
7976
num_inference_steps=50,
8077
)
81-
78+
8279
# Send image to client
8380
self.send_image(client_socket)
8481

0 commit comments

Comments
 (0)