darkbit1001 commited on
Commit
8d44598
·
1 Parent(s): 96d104c

wrap up and tidy

Browse files
.gitattributes CHANGED
@@ -51,3 +51,4 @@ model/Assets/lcm_ninja_30_7.5_2092464983.png filter=lfs diff=lfs merge=lfs -text
51
  *.rknn filter=lfs diff=lfs merge=lfs -text
52
  *.onnx_data filter=lfs diff=lfs merge=lfs -text
53
  *.png filter=lfs diff=lfs merge=lfs -text
 
 
51
  *.rknn filter=lfs diff=lfs merge=lfs -text
52
  *.onnx_data filter=lfs diff=lfs merge=lfs -text
53
  *.png filter=lfs diff=lfs merge=lfs -text
54
+ *.so filter=lfs diff=lfs merge=lfs -text
Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM python:3.12-slim
2
 
3
  # System deps (Pillow, RKNN, etc.)
4
  RUN apt-get update && apt-get install -y --no-install-recommends \
@@ -6,10 +6,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
6
  libsm6 \
7
  libxext6 \
8
  libxrender1 \
9
- && rm -rf /var/lib/apt/lists/*
 
10
 
11
  WORKDIR /app
12
 
 
13
  # Python deps
14
  COPY requirements.txt /app/requirements.txt
15
  RUN python -m venv /venv && \
@@ -18,8 +20,9 @@ RUN python -m venv /venv && \
18
 
19
  # 👇 THIS copies *everything except what .dockerignore excludes*
20
  COPY . /app
 
 
21
  COPY librknnrt.so /usr/lib/librknnrt.so
22
- COPY librkllmrt.so /usr/lib/librkllmrt.so
23
  RUN ldconfig
24
 
25
  ENV PATH="/venv/bin:$PATH"
 
1
+ FROM python:3.12-slim-trixie
2
 
3
  # System deps (Pillow, RKNN, etc.)
4
  RUN apt-get update && apt-get install -y --no-install-recommends \
 
6
  libsm6 \
7
  libxext6 \
8
  libxrender1 \
9
+ procps
10
+ # && rm -rf /var/lib/apt/lists/*
11
 
12
  WORKDIR /app
13
 
14
+
15
  # Python deps
16
  COPY requirements.txt /app/requirements.txt
17
  RUN python -m venv /venv && \
 
20
 
21
  # 👇 THIS copies *everything except what .dockerignore excludes*
22
  COPY . /app
23
+
24
+ # Copy RKNN runtime shared library into image
25
  COPY librknnrt.so /usr/lib/librknnrt.so
 
26
  RUN ldconfig
27
 
28
  ENV PATH="/venv/bin:$PATH"
docker-compose.yml CHANGED
@@ -1,5 +1,6 @@
1
  services:
2
  lcn-sd:
 
3
  container_name: rknn-lcm-sd
4
  build:
5
  context: .
 
1
  services:
2
  lcn-sd:
3
+ platform: linux/arm64
4
  container_name: rknn-lcm-sd
5
  build:
6
  context: .
lcm_server.py CHANGED
@@ -104,6 +104,9 @@ class PipelineWorker:
104
  # Deterministic per-request random generator
105
  rng = np.random.RandomState(job.req.seed)
106
 
 
 
 
107
  result = self.pipe(
108
  prompt=job.req.prompt,
109
  height=h,
 
104
  # Deterministic per-request random generator
105
  rng = np.random.RandomState(job.req.seed)
106
 
107
+ print("seed ", job.req.seed)
108
+ print("rng", rng)
109
+
110
  result = self.pipe(
111
  prompt=job.req.prompt,
112
  height=h,
librknnrt.so ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:73993ed4b440460825f21611731564503cc1d5a0c123746477da6cd574f34885
3
+ size 7259064
rknnlcm.py CHANGED
@@ -43,7 +43,7 @@ class RKNN2Model:
43
  *,
44
  core_mask: Optional[Union[str, int]] = None,
45
  multi_context: bool = True,
46
- data_format: str = "nhwc",
47
  verbose_shapes: bool = False,
48
  runtime_kwargs: Optional[dict] = None,
49
  **_ignored: Any,
@@ -679,4 +679,4 @@ def generate_png_bytes(args):
679
  pil_image.save(buf, format="PNG")
680
  buf.seek(0)
681
 
682
- return buf.getvalue()
 
43
  *,
44
  core_mask: Optional[Union[str, int]] = None,
45
  multi_context: bool = True,
46
+ data_format: str = "nchw",
47
  verbose_shapes: bool = False,
48
  runtime_kwargs: Optional[dict] = None,
49
  **_ignored: Any,
 
679
  pil_image.save(buf, format="PNG")
680
  buf.seek(0)
681
 
682
+ return buf.getvalue()
run_rknn-lcm.py CHANGED
@@ -56,6 +56,30 @@ class RKNN2Model:
56
  for res in results:
57
  print(f"output shape: {res.shape}")
58
  return results
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
  class RKNN2LatentConsistencyPipeline(DiffusionPipeline):
61
 
 
56
  for res in results:
57
  print(f"output shape: {res.shape}")
58
  return results
59
+ # def __call__(self, **kwargs) -> List[np.ndarray]:
60
+ # input_list = [value for _, value in kwargs.items()]
61
+
62
+ # fixed = []
63
+ # for x in input_list:
64
+ # if isinstance(x, np.ndarray):
65
+ # # RKNNLite generally expects float32/int32/int8/etc — never float64
66
+ # if x.dtype == np.float64:
67
+ # x = x.astype(np.float32, copy=False)
68
+ # # Also common: float16 -> float32 (safe default unless you KNOW model is fp16)
69
+ # if x.dtype == np.float16:
70
+ # x = x.astype(np.float32, copy=False)
71
+
72
+ # # Make contiguous (RKNN is happier)
73
+ # if not x.flags["C_CONTIGUOUS"]:
74
+ # x = np.ascontiguousarray(x)
75
+
76
+ # elif isinstance(x, (float, np.floating)):
77
+ # x = np.array(x, dtype=np.float32)
78
+
79
+ # fixed.append(x)
80
+
81
+ # results = self.rknnlite.inference(inputs=fixed, data_format='nchw')
82
+ # return results
83
 
84
  class RKNN2LatentConsistencyPipeline(DiffusionPipeline):
85
 
runner.sh CHANGED
File without changes
sample-rest-call.sh CHANGED
@@ -1,4 +1,4 @@
1
- curl -X POST http://127.0.0.1:4200/generate -H "Content-Type: application/json" -o out.png -d '{
2
  "prompt": "a cinematic photograph of a futuristic city at sunset",
3
  "size": "512x512",
4
  "num_inference_steps": 5,
 
1
+ curl -X POST http://node3.lan:4200/generate -H "Content-Type: application/json" -o out.png -d '{
2
  "prompt": "a cinematic photograph of a futuristic city at sunset",
3
  "size": "512x512",
4
  "num_inference_steps": 5,