Alptekinege Loewolf commited on
Commit
3490db8
·
0 Parent(s):

Duplicate from AllGPTORG/PiSA-Lite

Browse files

Co-authored-by: Arnold <Loewolf@users.noreply.huggingface.co>

.gitattributes ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,331 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: other
5
+ pipeline_tag: image-to-image
6
+ tags:
7
+ - super-resolution
8
+ - image-upscaling
9
+ - image-restoration
10
+ - qnn
11
+ - onnx
12
+ - snapdragon
13
+ - qualcomm
14
+ - mobile
15
+ - npu
16
+ - android
17
+ - generative-ai
18
+ library_name: custom
19
+ ---
20
+
21
+ # PiSA-Lite
22
+
23
+ **PiSA-Lite is a lightweight, mobile-optimized version of PiSA-SR for Snapdragon-powered smartphones. It is designed to preserve high-quality textures and semantic image details while running through Qualcomm's NPU.**
24
+
25
+ > PiSA-Lite is an unofficial optimization based on PiSA-SR. It is not affiliated with or endorsed by the original PiSA-SR authors.
26
+
27
+ ## Overview
28
+
29
+ PiSA-Lite keeps the original PiSA-SR architecture and its semantic image-restoration behavior while preparing the model for mobile deployment.
30
+
31
+ Unlike small super-resolution models that mainly sharpen edges, PiSA-Lite aims to preserve PiSA-SR's ability to reconstruct material-aware details such as:
32
+
33
+ - wood grain
34
+ - grass and vegetation
35
+ - metal reflections
36
+ - fabric textures
37
+ - hair and fine surface details
38
+ - building and object structure
39
+
40
+ The current release includes:
41
+
42
+ - precompiled Qualcomm QNN Context Binaries for Snapdragon 8 Gen 3
43
+ - ONNX source models for compiling separate builds for other supported Snapdragon chips
44
+ - a fixed 4× super-resolution pipeline
45
+ - an FP16/W8A16 quality configuration
46
+
47
+ ## Model Details
48
+
49
+ | Property | Value |
50
+ |---|---|
51
+ | Base project | PiSA-SR |
52
+ | Task | Generative image super-resolution |
53
+ | Input | 128 × 128 RGB image |
54
+ | Output | 512 × 512 RGB image |
55
+ | Upscale factor | 4× |
56
+ | Latent shape | `1 × 4 × 64 × 64` |
57
+ | Target runtime | Qualcomm QNN / HTP NPU |
58
+ | Current target SoC | Snapdragon 8 Gen 3 / SM8650 |
59
+ | Current target device family | Samsung Galaxy S24 Family |
60
+ | Deployment format | QNN Context Binary |
61
+ | Source export format | ONNX |
62
+
63
+ ## Files
64
+
65
+ ### Snapdragon 8 Gen 3 QNN Models
66
+
67
+ The included QNN binaries were compiled specifically for Snapdragon 8 Gen 3 / SM8650:
68
+
69
+ ```text
70
+ pisa_encoder_quality.bin
71
+ pisa_denoiser_quality.bin
72
+ pisa_decoder_quality.bin
73
+ ```
74
+
75
+ | File | Purpose | Precision | Approximate size |
76
+ |---|---|---:|---:|
77
+ | `pisa_encoder_quality.bin` | Converts the image into latent space | FP16 | 74 MiB |
78
+ | `pisa_denoiser_quality.bin` | Restores PiSA textures and semantic details | W8A16 | 791 MiB |
79
+ | `pisa_decoder_quality.bin` | Converts the restored latent into an image | FP16 | 104 MiB |
80
+
81
+ Total package size is approximately **970 MiB**.
82
+
83
+ ### ONNX Models
84
+
85
+ The ONNX files are source models for creating separate QNN builds for other supported Snapdragon chips:
86
+
87
+ ```text
88
+ encoder.onnx
89
+ denoiser.onnx
90
+ decoder.onnx
91
+ ```
92
+
93
+ The ONNX files are **not** pre-optimized universal mobile models. They must be compiled for the intended Snapdragon target using Qualcomm AI Hub, QAIRT, or another compatible Qualcomm QNN toolchain.
94
+
95
+ ## Hardware Compatibility
96
+
97
+ The supplied `.bin` files are compiled for:
98
+
99
+ ```text
100
+ Qualcomm Snapdragon 8 Gen 3
101
+ SoC: SM8650
102
+ Samsung Galaxy S24 Family
103
+ Android 14
104
+ ```
105
+
106
+ QNN Context Binaries are hardware-specific.
107
+
108
+ Do not assume that the supplied Snapdragon 8 Gen 3 binaries will work on:
109
+
110
+ - Snapdragon 8 Gen 2
111
+ - Snapdragon 8 Elite
112
+ - Snapdragon 7-series devices
113
+ - Exynos devices
114
+ - MediaTek devices
115
+ - desktop CPUs or GPUs
116
+
117
+ For another supported Snapdragon chip, use the ONNX models to compile a separate QNN package for that target.
118
+
119
+ ## Pipeline
120
+
121
+ ```text
122
+ 128 × 128 input image
123
+
124
+ Resize to 512 × 512
125
+
126
+ PiSA VAE Encoder
127
+
128
+ Latent sampling
129
+
130
+ PiSA Denoiser
131
+
132
+ PiSA VAE Decoder
133
+
134
+ Color correction
135
+
136
+ 512 × 512 output image
137
+ ```
138
+
139
+ All three model components must be executed in order.
140
+
141
+ ## Precision Configuration
142
+
143
+ The current quality release uses:
144
+
145
+ ```text
146
+ Encoder: FP16
147
+ Denoiser: W8A16
148
+ Decoder: FP16
149
+ ```
150
+
151
+ This reduces the size of the largest PiSA component while keeping the texture-sensitive VAE encoder and decoder in FP16.
152
+
153
+ ## Android Integration
154
+
155
+ The QNN files are not standalone applications and cannot be opened directly.
156
+
157
+ An Android application must load them through Qualcomm QAIRT/QNN, typically through a native C++ layer:
158
+
159
+ ```text
160
+ Kotlin / Java UI
161
+
162
+ JNI
163
+
164
+ C++ QNN runner
165
+
166
+ QNN HTP backend
167
+
168
+ Encoder → Denoiser → Decoder
169
+ ```
170
+
171
+ Recommended private storage layout:
172
+
173
+ ```text
174
+ /data/user/0/<application-id>/files/models/pisa_sm8650/
175
+ ├── pisa_encoder_quality.bin
176
+ ├── pisa_denoiser_quality.bin
177
+ └── pisa_decoder_quality.bin
178
+ ```
179
+
180
+ Because the complete model package is large, downloading the files after installation is generally preferable to embedding them directly inside the APK.
181
+
182
+ ## Compiling for Another Snapdragon Chip
183
+
184
+ Use the ONNX models as source graphs and compile each component for the selected target device:
185
+
186
+ ```text
187
+ encoder.onnx
188
+ denoiser.onnx
189
+ decoder.onnx
190
+
191
+ Qualcomm AI Hub / QAIRT / QNN compiler
192
+
193
+ target-specific QNN Context Binaries
194
+ ```
195
+
196
+ A separate set of binaries should be generated for each supported Snapdragon family.
197
+
198
+ The application should detect the device SoC before downloading or loading a model package.
199
+
200
+ ```text
201
+ SM8650 / Snapdragon 8 Gen 3
202
+ → Load the included SM8650 package
203
+
204
+ Another supported Snapdragon chip
205
+ → Download a separately compiled package
206
+
207
+ Unsupported hardware
208
+ → Use a smaller GPU or CPU fallback model
209
+ ```
210
+
211
+ ## Intended Use
212
+
213
+ PiSA-Lite is intended for:
214
+
215
+ - low-resolution photo restoration
216
+ - experimental mobile photography
217
+ - restoring vegetation and environmental details
218
+ - improving material textures
219
+ - enhancing compressed images
220
+ - improving game screenshots
221
+ - research into mobile generative super-resolution
222
+
223
+ ## Out-of-Scope Use
224
+
225
+ PiSA-Lite is not recommended for:
226
+
227
+ - forensic image analysis
228
+ - identity verification
229
+ - medical imaging
230
+ - document or evidence recovery
231
+ - exact text reconstruction
232
+ - license-plate recovery
233
+ - recovering factual details that are not visible in the source image
234
+
235
+ ## Limitations
236
+
237
+ PiSA-Lite is a generative super-resolution model and may create visually plausible details that were not present in the original low-resolution input.
238
+
239
+ Possible failure cases include:
240
+
241
+ - invented textures
242
+ - incorrect small text
243
+ - altered faces
244
+ - changed logos or symbols
245
+ - inaccurate fine patterns
246
+ - unstable results on heavily degraded inputs
247
+ - high memory use compared with small CNN upscalers
248
+ - slower inference than models such as SPAN
249
+ - hardware-specific deployment requirements
250
+
251
+ Generated output should not be treated as factual evidence.
252
+
253
+ ## Current Status
254
+
255
+ - [x] PiSA-SR quality preserved in local testing
256
+ - [x] Weight-optimized PiSA-Lite package created
257
+ - [x] ONNX models exported
258
+ - [x] QNN Context Binaries compiled
259
+ - [x] Snapdragon 8 Gen 3 NPU inference completed
260
+ - [ ] Public Android runtime example
261
+ - [ ] On-device speed and memory benchmarks
262
+ - [ ] Additional Snapdragon targets
263
+ - [ ] Larger calibration dataset
264
+ - [ ] Hugging Face demo Space
265
+
266
+ ## Comparison
267
+
268
+ | Model | Sharpness | Semantic texture reconstruction | Mobile suitability |
269
+ |---|---:|---:|---:|
270
+ | SPAN | Good | Limited | High |
271
+ | TinySR | Very good | Medium | Medium |
272
+ | PiSA-SR | Very good | Very high | Low |
273
+ | PiSA-Lite | Very good | Very high in current tests | Targeted at Snapdragon NPU |
274
+
275
+ The PiSA-Lite quality claim is based on local visual testing and should be validated on a larger public benchmark set.
276
+
277
+ ## Credits
278
+
279
+ PiSA-Lite is based on the original **PiSA-SR** project and research.
280
+
281
+ All credit for the original architecture, training method, pretrained model, and research belongs to the original PiSA-SR authors.
282
+
283
+ PiSA-Lite focuses on:
284
+
285
+ - mobile deployment
286
+ - weight optimization
287
+ - fixed-shape inference
288
+ - ONNX export
289
+ - Qualcomm QNN compilation
290
+ - Snapdragon NPU execution
291
+
292
+ ## License and Redistribution
293
+
294
+ The metadata uses `license: other` because redistribution rights may depend on multiple upstream components.
295
+
296
+ Before redistributing model weights or binaries, review and comply with:
297
+
298
+ - the original PiSA-SR license
299
+ - the Stable Diffusion 2.1 base-model license
300
+ - all pretrained-model licenses
301
+ - Qualcomm AI Hub and QNN terms
302
+ - any checkpoint or dataset restrictions
303
+
304
+ Uploading this repository does not automatically grant rights beyond the relevant upstream licenses.
305
+
306
+ ## Disclaimer
307
+
308
+ This project is experimental and provided without warranty.
309
+
310
+ The maintainers are not responsible for:
311
+
312
+ - hallucinated or inaccurate reconstructed details
313
+ - unsupported-device crashes
314
+ - excessive memory usage
315
+ - incorrect Android integration
316
+ - redistribution outside upstream license terms
317
+ - damage or data loss caused by use of the model
318
+
319
+ Use PiSA-Lite at your own risk.
320
+
321
+ ## Repository
322
+
323
+ GitHub:
324
+
325
+ ```text
326
+ https://github.com/LoewolfERSTELLER/PiSA-Lite
327
+ ```
328
+
329
+ ## Short Description
330
+
331
+ > PiSA-Lite is an unofficial, mobile-optimized PiSA-SR upscaler for Snapdragon smartphones, designed to preserve high-quality textures and semantic image details through Qualcomm's NPU.
deployment_manifest.json ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "status": "SNAPDRAGON-NPU-MODELL FERTIG",
3
+ "target_device": "Samsung Galaxy S24 (Family)",
4
+ "mode": "quality",
5
+ "source_model": "C:\\Users\\aarno\\Documents\\Projekte\\irgendwas\\pisa_lite_w8\\pisa_lite_quality_w8_fp16.pt",
6
+ "input": "C:\\Users\\aarno\\Documents\\Projekte\\irgendwas\\bild_128x128.png",
7
+ "npu_test_output": "C:\\Users\\aarno\\Documents\\Projekte\\irgendwas\\bild_pisa_snapdragon_npu_512x512.png",
8
+ "local_test_output": "C:\\Users\\aarno\\Documents\\Projekte\\irgendwas\\pisa_snapdragon_npu\\local_test\\pisa_lite_local_reference.png",
9
+ "fixed_shapes": {
10
+ "encoder_input": [
11
+ 1,
12
+ 3,
13
+ 512,
14
+ 512
15
+ ],
16
+ "encoder_outputs": [
17
+ [
18
+ 1,
19
+ 4,
20
+ 64,
21
+ 64
22
+ ],
23
+ [
24
+ 1,
25
+ 4,
26
+ 64,
27
+ 64
28
+ ]
29
+ ],
30
+ "denoiser_input_output": [
31
+ 1,
32
+ 4,
33
+ 64,
34
+ 64
35
+ ],
36
+ "decoder_output": [
37
+ 1,
38
+ 3,
39
+ 512,
40
+ 512
41
+ ]
42
+ },
43
+ "components": {
44
+ "encoder": {
45
+ "onnx_folder": "C:\\Users\\aarno\\Documents\\Projekte\\irgendwas\\pisa_snapdragon_npu\\onnx\\encoder.onnx",
46
+ "onnx_size_bytes": 68428607,
47
+ "qnn_context_binary": "C:\\Users\\aarno\\Documents\\Projekte\\irgendwas\\pisa_snapdragon_npu\\qnn\\pisa_encoder_quality.bin",
48
+ "qnn_size_bytes": 77496320,
49
+ "compile_options": "--target_runtime qnn_context_binary --qnn_options default_graph_htp_precision=FLOAT16",
50
+ "compile_job_url": "https://workbench.aihub.qualcomm.com/jobs/jgl11dmj5/"
51
+ },
52
+ "denoiser": {
53
+ "onnx_folder": "C:\\Users\\aarno\\Documents\\Projekte\\irgendwas\\pisa_snapdragon_npu\\onnx\\denoiser.onnx",
54
+ "onnx_size_bytes": 1732703600,
55
+ "qnn_context_binary": "C:\\Users\\aarno\\Documents\\Projekte\\irgendwas\\pisa_snapdragon_npu\\qnn\\pisa_denoiser_quality.bin",
56
+ "qnn_size_bytes": 829493248,
57
+ "compile_options": "--target_runtime qnn_context_binary --quantize_full_type w8a16",
58
+ "compile_job_url": "https://workbench.aihub.qualcomm.com/jobs/jgl11dvj5/"
59
+ },
60
+ "decoder": {
61
+ "onnx_folder": "C:\\Users\\aarno\\Documents\\Projekte\\irgendwas\\pisa_snapdragon_npu\\onnx\\decoder.onnx",
62
+ "onnx_size_bytes": 99084465,
63
+ "qnn_context_binary": "C:\\Users\\aarno\\Documents\\Projekte\\irgendwas\\pisa_snapdragon_npu\\qnn\\pisa_decoder_quality.bin",
64
+ "qnn_size_bytes": 108863488,
65
+ "compile_options": "--target_runtime qnn_context_binary --qnn_options default_graph_htp_precision=FLOAT16",
66
+ "compile_job_url": "https://workbench.aihub.qualcomm.com/jobs/jgdzzkoz5/"
67
+ }
68
+ },
69
+ "npu_inference_job_urls": {
70
+ "encoder": "https://workbench.aihub.qualcomm.com/jobs/jgl11dmj5/",
71
+ "denoiser": "https://workbench.aihub.qualcomm.com/jobs/jgl11dvj5/",
72
+ "decoder": "https://workbench.aihub.qualcomm.com/jobs/jgdzzkoz5/"
73
+ },
74
+ "metrics_npu_vs_local": {
75
+ "mse": 9.212180157192051e-05,
76
+ "mae": 0.0046744453720748425,
77
+ "psnr_db": 40.3563757738287
78
+ },
79
+ "created_at": "2026-07-12 18:17:10"
80
+ }
onnx/decoder.onnx/decoder.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a6746bd6393309743723b319be38a427e588ab07c5cb4962d4574c45f5495ba7
3
+ size 99084465
onnx/denoiser.onnx/denoiser.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9523f6f45799ae401c028c55f57f4e067e50486f68f250804e0694d94ffae8a0
3
+ size 1732703600
onnx/encoder.onnx/encoder.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:287c3493e28a2097ee0128ea18a31aa2a14b71bc213c952f97e3d18b2d035fc3
3
+ size 68428607
qnn/pisa_decoder_quality.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d48fd9d7b29b1087098a38665a5711479edbb6a1ea7881f91a1a382805a620f4
3
+ size 108863488
qnn/pisa_denoiser_quality.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c793d4b63bf07c7465c88266db17e84d042b5385b3026a6a78ef2eb074265b69
3
+ size 829493248
qnn/pisa_encoder_quality.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0c891813cedbb9c63364b42f13493325aede1e070b2799d8c6617ae7c70a3a06
3
+ size 77496320