amv-diffusion 2.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- amv_diffusion-2.1.0.dist-info/METADATA +180 -0
- amv_diffusion-2.1.0.dist-info/RECORD +39 -0
- amv_diffusion-2.1.0.dist-info/WHEEL +5 -0
- amv_diffusion-2.1.0.dist-info/entry_points.txt +7 -0
- amv_diffusion-2.1.0.dist-info/licenses/LICENSE +21 -0
- amv_diffusion-2.1.0.dist-info/top_level.txt +1 -0
- termux_diffusion/__init__.py +185 -0
- termux_diffusion/__main__.py +7 -0
- termux_diffusion/_version.py +3 -0
- termux_diffusion/adapter.py +41 -0
- termux_diffusion/canvas.py +364 -0
- termux_diffusion/cli.py +492 -0
- termux_diffusion/cluster.py +340 -0
- termux_diffusion/control/__init__.py +5 -0
- termux_diffusion/control/component.py +309 -0
- termux_diffusion/control/status.py +15 -0
- termux_diffusion/core.py +2936 -0
- termux_diffusion/data/bootstrap-manifest.json +15 -0
- termux_diffusion/data/prompt_cache/108a7149c4e70550.json +10 -0
- termux_diffusion/data/release-public-keys.json +10 -0
- termux_diffusion/data/validated-vulkan-profiles.json +298 -0
- termux_diffusion/detailer.py +283 -0
- termux_diffusion/doctor.py +128 -0
- termux_diffusion/downloader.py +111 -0
- termux_diffusion/engine.py +226 -0
- termux_diffusion/exceptions.py +158 -0
- termux_diffusion/hardware.py +985 -0
- termux_diffusion/hub.py +686 -0
- termux_diffusion/installer.py +499 -0
- termux_diffusion/locking.py +134 -0
- termux_diffusion/manifest.py +128 -0
- termux_diffusion/npu.py +267 -0
- termux_diffusion/platform.py +533 -0
- termux_diffusion/purger.py +145 -0
- termux_diffusion/py.typed +1 -0
- termux_diffusion/safety.py +150 -0
- termux_diffusion/selftest.py +178 -0
- termux_diffusion/web.py +3370 -0
- termux_diffusion/workflow.py +1345 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: amv-diffusion
|
|
3
|
+
Version: 2.1.0
|
|
4
|
+
Summary: AmfyUI (ComfyUI Mobile DAG Studio) & Z-Image Turbo (6.0B DiT) On-Device Diffusion Runtime for Android Termux
|
|
5
|
+
Home-page: https://github.com/uno-km/termux-diffusion
|
|
6
|
+
Author: uno-km (AMEVA Foundation)
|
|
7
|
+
Author-email: "uno-km (AMEVA Foundation)" <zhfldk014745@naver.com>
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
Project-URL: Homepage, https://github.com/uno-km/amv-diffusion
|
|
10
|
+
Project-URL: Documentation, https://uno-km.github.io/amv-diffusion/
|
|
11
|
+
Project-URL: npm Package, https://www.npmjs.com/package/amv-diffusion
|
|
12
|
+
Project-URL: Bug Tracker, https://github.com/uno-km/amv-diffusion/issues
|
|
13
|
+
Project-URL: Source, https://github.com/uno-km/amv-diffusion
|
|
14
|
+
Keywords: stable-diffusion,diffusion,termux,android,samsung-galaxy,edge-ai,on-device-ai,image-generation,text-to-image,gguf,arm64,aarch64,neon,simd,bionic-libc,vae-tiling,galaxy-s25,galaxy-s21
|
|
15
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
19
|
+
Classifier: Operating System :: Android
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
26
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
27
|
+
Classifier: Topic :: Multimedia :: Graphics
|
|
28
|
+
Requires-Python: >=3.8
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
Provides-Extra: gpu
|
|
32
|
+
Requires-Dist: ameva-runtime>=2.0.0; extra == "gpu"
|
|
33
|
+
Provides-Extra: detailer
|
|
34
|
+
Requires-Dist: numpy>=1.20.0; extra == "detailer"
|
|
35
|
+
Requires-Dist: Pillow>=8.0.0; extra == "detailer"
|
|
36
|
+
Dynamic: author
|
|
37
|
+
Dynamic: classifier
|
|
38
|
+
Dynamic: home-page
|
|
39
|
+
Dynamic: license-file
|
|
40
|
+
Dynamic: requires-python
|
|
41
|
+
|
|
42
|
+
# Termux-Diffusion (Python)
|
|
43
|
+
|
|
44
|
+
[](https://pypi.org/project/termux-diffusion/)
|
|
45
|
+
[](https://pypi.org/project/termux-diffusion/)
|
|
46
|
+
[](https://github.com/uno-km/termux-diffusion)
|
|
47
|
+
|
|
48
|
+
> **Official Z-Image Turbo (6.0B DiT) & Pure Native On-Device Diffusion Acceleration for Android Termux & Samsung Galaxy.**
|
|
49
|
+
> *Zero PRoot. Zero Virtualization. 100% Native ARM64 Bionic libc, Khronos Vulkan 1.1+ GPU Shaders & NEON SIMD Vector Engine.*
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## What's New in v2.1.0 — Mobile Canva Studio & SurfaceFlinger Shield
|
|
54
|
+
|
|
55
|
+
- Added Mobile Canva Studio Suite: Magic Eraser (magic_eraser), Magic Grab (magic_grab), Magic Expand (magic_expand), and Magic Layers (decompose_layers).
|
|
56
|
+
- Implemented SurfaceFlinger Crash Shield with GPU duty-cycle throttling and safe-mode protection.
|
|
57
|
+
- Added Safe Memory Purger with automatic OOM safety budget management.
|
|
58
|
+
- Unified GPU acceleration dispatch through ameva-runtime HAL.
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 🚀 Major Breakthrough: 6.0B DiT (Z-Image Turbo) Sovereign Mobile Execution
|
|
63
|
+
|
|
64
|
+
`termux-diffusion v1.8.0` introduces official production support for **Z-Image Turbo**, empowering mobile devices to execute modern **6.0 Billion Parameter Diffusion Transformers (DiT)** natively on-device.
|
|
65
|
+
|
|
66
|
+
### 🌟 Tri-Engine Asymmetric Architecture
|
|
67
|
+
* **Text Encoder (CPU 4-Core)**: 4.0B LLM (`Qwen3-4B-Instruct-2507-Q2_K.gguf`) performs dense context embedding on CPU Big/Prime cores (`clip_on_cpu=True`).
|
|
68
|
+
* **DiT Denoising Backbone (Vulkan GPU)**: 6.0B Diffusion Transformer (`z_image_turbo-Q2_K.gguf`) accelerated via Khronos Vulkan compute shaders with Tiled Flash Attention (`diffusion_fa=True`).
|
|
69
|
+
* **Ultra-Fast VAE Decoder (CPU)**: 10MB Tiny AutoEncoder for FLUX.1 (`taef1.safetensors`) completes latent decoding rapidly without memory spikes (`vae_on_cpu=True`).
|
|
70
|
+
* **Layer Streaming (`stream_layers=True`)**: Breaks through mobile memory limits by streaming layers into Vulkan VRAM sequentially, maintaining a strict **1.0 GB VRAM footprint** (`max_vram="vulkan0=1"`) and completely eliminating Android Low Memory Killer (LMK) aborts.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 📸 Sovereign Physical Verification: Galaxy S21 DiT 8-Step Output
|
|
75
|
+
|
|
76
|
+
* **Verification Image**: [Galaxy S21 Z-Image Turbo 8-Step PNG Artifact](https://raw.githubusercontent.com/uno-km/termux-diffusion/main/docs/research/s21_z_image_turbo_8step.png)
|
|
77
|
+
* **Verification Prompt (Ground Truth)**:
|
|
78
|
+
```text
|
|
79
|
+
"A cinematic photo of a neon cybernetic tiger walking in Seoul street at night"
|
|
80
|
+
```
|
|
81
|
+
* **Verified Input Parameter Engineering**:
|
|
82
|
+
* `steps=8` (Full numerical convergence ODE solver)
|
|
83
|
+
* `cfg_scale=1.0` (Optimal guidance for distilled DiT architecture)
|
|
84
|
+
* `sampler="euler"` (1st-order Ordinary Differential Equation solver)
|
|
85
|
+
* `device="vulkan"` (Physical GPU acceleration)
|
|
86
|
+
* `diffusion_fa=True` (Tiled Flash Attention enabled)
|
|
87
|
+
* `stream_layers=True` (Layer residency streaming over AXI bus)
|
|
88
|
+
* `max_vram="vulkan0=1"` (Strict 1.0 GB VRAM ceiling, Zero-LMK protection)
|
|
89
|
+
* `clip_on_cpu=True` (Offloads LLM prompt embedding to CPU Big/Prime cores)
|
|
90
|
+
* `vae_on_cpu=True` (Prevents GPU VRAM allocation collisions during decoding)
|
|
91
|
+
* `taesd="auto"` (Ultra-fast 10MB FLUX.1 latent decoder)
|
|
92
|
+
* **Optical Realism**: Specular light scattering from neon signboards on wet Seoul asphalt road surfaces, razor-sharp cybernetic armor plates, and micro-texture whiskers cleanly isolated from background noise.
|
|
93
|
+
* **Runtime Stability**: 100% completion achieved with zero Out-of-Memory (LMK) aborts and zero thermal throttling termination.
|
|
94
|
+
|
|
95
|
+
### 🔬 Academic Research & Lab Report Reference
|
|
96
|
+
* **Full Technical Research Report**: [Galaxy S21 Z-Image Turbo Vulkan Research Report](https://github.com/uno-km/termux-diffusion/blob/main/docs/research/s21_z_image_turbo_vulkan_research_report.md)
|
|
97
|
+
* **Academic Research Paper**: [AMEVA Labs | Sovereign On-Device AI Research, Newsletter & Discussion](https://uno-km.vercel.app/labs/index.html?menu=research-papers&post=33)
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## 💻 Python SDK Installation & Practical User Manual
|
|
102
|
+
|
|
103
|
+
### 1. Installation & Provisioning
|
|
104
|
+
```bash
|
|
105
|
+
pkg update && pkg install -y python clang termux-api
|
|
106
|
+
pip install termux-diffusion
|
|
107
|
+
termux-diffusion install
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 2. Python API Practical Code Example
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
import termux_diffusion as td
|
|
114
|
+
|
|
115
|
+
# 1. Official Z-Image Turbo 6.0B DiT Synthesis via Python API
|
|
116
|
+
image_path = td.generate(
|
|
117
|
+
prompt="A cinematic photo of a neon cybernetic tiger walking in Seoul street at night",
|
|
118
|
+
preset="z-image-turbo",
|
|
119
|
+
steps=8,
|
|
120
|
+
cfg_scale=1.0,
|
|
121
|
+
sampler="euler",
|
|
122
|
+
device="vulkan",
|
|
123
|
+
diffusion_fa=True,
|
|
124
|
+
stream_layers=True,
|
|
125
|
+
max_vram="vulkan0=1",
|
|
126
|
+
clip_on_cpu=True,
|
|
127
|
+
vae_on_cpu=True,
|
|
128
|
+
taesd="auto",
|
|
129
|
+
output_path="/sdcard/Pictures/TermuxDiffusion/cyber_tiger_dit.png"
|
|
130
|
+
)
|
|
131
|
+
print(f"Generated via 6.0B DiT Tri-Engine: {image_path}")
|
|
132
|
+
|
|
133
|
+
# 2. Fast UNet Standard Inference (DreamShaper 8 LCM 6-Step)
|
|
134
|
+
lcm_path = td.generate(
|
|
135
|
+
prompt="A cinematic photo of a neon cybernetic tiger walking in Seoul street at night",
|
|
136
|
+
model="anime",
|
|
137
|
+
steps=6,
|
|
138
|
+
cfg_scale=1.5,
|
|
139
|
+
sampler="lcm",
|
|
140
|
+
device="vulkan",
|
|
141
|
+
diffusion_fa=True,
|
|
142
|
+
vae_on_cpu=True,
|
|
143
|
+
output_path="/sdcard/Pictures/TermuxDiffusion/cyber_tiger_lcm.png"
|
|
144
|
+
)
|
|
145
|
+
print(f"Generated via DreamShaper 8 LCM: {lcm_path}")
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## 🎛️ Python API Parameter Reference
|
|
151
|
+
|
|
152
|
+
| Argument | Type | Default | Engineering Purpose |
|
|
153
|
+
| :--- | :---: | :---: | :--- |
|
|
154
|
+
| `prompt` | `str` | *Required* | Text conditioning prompt |
|
|
155
|
+
| `width`, `height` | `int` | `512` | Image dimensions (multiples of 64) |
|
|
156
|
+
| `steps` | `int` | `8` (DiT) / `6` (LCM) | Numerical solver sampling iterations |
|
|
157
|
+
| `cfg_scale` | `float` | `1.0` (DiT) / `1.5` (LCM) | Classifier-Free Guidance scale weight |
|
|
158
|
+
| `sampler` | `str` | `"euler"` | Denoising ODE solver algorithm |
|
|
159
|
+
| `device` | `str` | `"vulkan"` | Accelerator device (`"vulkan"`, `"cpu"`) |
|
|
160
|
+
| `preset` | `str` | `"z-image-turbo"` | Verified configuration bundle |
|
|
161
|
+
| `stream_layers` | `bool` | `True` (DiT) | Enables dynamic layer streaming over AXI bus |
|
|
162
|
+
| `max_vram` | `str` | `"vulkan0=1"` | GPU memory ceiling (1.0 GB) to avert OS LMK aborts |
|
|
163
|
+
| `diffusion_fa` | `bool` | `True` | Flash Attention $O(N)$ memory reduction |
|
|
164
|
+
| `clip_on_cpu` | `bool` | `True` | Keeps LLM text encoder on CPU cores |
|
|
165
|
+
| `vae_on_cpu` | `bool` | `True` | Offloads VAE decode from GPU to host CPU |
|
|
166
|
+
| `taesd` | `str` | `"auto"` | Tiny AutoEncoder for ultra-fast latent decoding |
|
|
167
|
+
| `output_path` | `str` | `None` | Path to save output PNG artifact |
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## 🌐 Official Documentation & Ecosystem Links
|
|
172
|
+
- [Official Architecture & API Reference](https://uno-km.vercel.app/lib/diffusion/)
|
|
173
|
+
- [Advanced Parameters Handbook](https://uno-km.vercel.app/lib/diffusion/advanced-parameters.html)
|
|
174
|
+
- [GitHub Repository](https://github.com/uno-km/termux-diffusion)
|
|
175
|
+
- [AMEVA Open-Source Foundation Portal](https://uno-km.vercel.app/foundation/index.html)
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## 📄 License
|
|
180
|
+
Licensed under the Apache-2.0 License. Copyright (c) 2026 Eunho Kim ([@uno-km](https://github.com/uno-km)).
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
amv_diffusion-2.1.0.dist-info/licenses/LICENSE,sha256=Ek5JuH4HK-oMetVBul6Ovr7D6MVfNkPrSOpWqIwiCXI,1084
|
|
2
|
+
termux_diffusion/__init__.py,sha256=Mi7sU2hWIr5YjU4ShrpDn5rV6ogAsZy1q1YtlWAGLUE,4257
|
|
3
|
+
termux_diffusion/__main__.py,sha256=GFSyexSImJRDii6yUnHJ4DI6LqcxLhIGV4d7Du-1yrM,228
|
|
4
|
+
termux_diffusion/_version.py,sha256=h7xNDxf8Vj0mFraELKc1VxOmhsJwgL9DS3M8Ozdpg0o,152
|
|
5
|
+
termux_diffusion/adapter.py,sha256=xTQU4FKUZq-ETyD5A-QVVwz4NJYmIhI3ywgOeR7LEPQ,1615
|
|
6
|
+
termux_diffusion/canvas.py,sha256=8Ys6H5VFd5bOASEyFQUlTDwpqVuyPQYbw9gZxfrfhQ4,13199
|
|
7
|
+
termux_diffusion/cli.py,sha256=oTP82qYlVEdRmqohvRR3W17cW8xkwOY8Tpw_qPmVjWU,30431
|
|
8
|
+
termux_diffusion/cluster.py,sha256=4_3X4nBGEriWNY6qymTEQufqy_CH7Br5TvbpYPrUONg,13328
|
|
9
|
+
termux_diffusion/core.py,sha256=BBUhuKAGrxe4Ts73n81P5jbPMbdN4Toc56r-MSWMJMI,68219
|
|
10
|
+
termux_diffusion/detailer.py,sha256=iutpwxAS7rwAl9Vmr1LSZpxP0jQRcVWzMPNHawxz_Pw,11512
|
|
11
|
+
termux_diffusion/doctor.py,sha256=lgleva4aOiXgJjZgIgPwPTIeCD_fLkD3kxqfmsdhv9Q,5695
|
|
12
|
+
termux_diffusion/downloader.py,sha256=ek4q0D0BRyfn4wlxEcE9klITZAmFKOwA_daS0W9RGQU,4219
|
|
13
|
+
termux_diffusion/engine.py,sha256=8BwAylT3Ye2pqXnSF8ANhUqmkfpEqTHrbytyLICDNvo,9587
|
|
14
|
+
termux_diffusion/exceptions.py,sha256=H5KWcpVBG64CRpyb7YW-BS1Mir5HB_HgnXYThoYyBBU,5397
|
|
15
|
+
termux_diffusion/hardware.py,sha256=1nm7Z5DuInSE3_8aaOy5mfoP2QmBOScde-YhQE1mkis,39433
|
|
16
|
+
termux_diffusion/hub.py,sha256=nLWidiOpScCsaFPCZG_o0qu8vgwKVYKAXQh05bkFBho,27290
|
|
17
|
+
termux_diffusion/installer.py,sha256=xqy8AQhVkKdR6GJsPFvx-j4BX0VfwZQEIoVufVjVo6g,20969
|
|
18
|
+
termux_diffusion/locking.py,sha256=W4PBMdU8cpR7PIa5LBJ3mQs71vcfOz55POtz4B7mPGs,5549
|
|
19
|
+
termux_diffusion/manifest.py,sha256=pGcgi1eIolqSNfMLNu_zrVBwpIIbzCGA9aTYC57H43A,4025
|
|
20
|
+
termux_diffusion/npu.py,sha256=bAAgJ4mBJHfP3pSVoxgLh8i7MP02Am-ZNUQlyMm4668,10928
|
|
21
|
+
termux_diffusion/platform.py,sha256=-hakFuhtz-JdCOe9E-sEQOUcti9lILylgHes7SL60h8,22544
|
|
22
|
+
termux_diffusion/purger.py,sha256=VY-aAv90PmaR0X8_o8eXIJS3WHeO0zEeCeKL26ooY64,4653
|
|
23
|
+
termux_diffusion/py.typed,sha256=bWew9mHgMy8LqMu7RuqQXFXLBxh2CRx0dUbSx-3wE48,27
|
|
24
|
+
termux_diffusion/safety.py,sha256=1rlDAIMOBbZfBeh8Visoz_0hiSIr58xsqvw60VSS4ds,5512
|
|
25
|
+
termux_diffusion/selftest.py,sha256=ljEfI79w6wBhom8RqZZfWDUSTW-d3Jio2qHfTDnVemU,7228
|
|
26
|
+
termux_diffusion/web.py,sha256=NiWfZEfGgPGH31D4jiLnbmko3XELpkjzZ7cqJdWz8I8,130958
|
|
27
|
+
termux_diffusion/workflow.py,sha256=nnYHxSssVwSlGmhUFMJ8nqK-WgLK8YyxSMGMoZMeOMA,57090
|
|
28
|
+
termux_diffusion/control/__init__.py,sha256=TB0Lt7rhWZ6caZdoRGsdAGeI9IRSHg_gHCrp8xjlFzM,265
|
|
29
|
+
termux_diffusion/control/component.py,sha256=BRgyeH-Qa6yFW5v4Qf9F0925GgeCEluhyswuTRC4BkQ,13708
|
|
30
|
+
termux_diffusion/control/status.py,sha256=U8ClYQW6xYbJ6lH9JXzPAt15GTHrGOOe_7b2H2Y3jt4,575
|
|
31
|
+
termux_diffusion/data/bootstrap-manifest.json,sha256=J3mSo5xXr9r-r4MbN30KnYSO9hDW_-NyCzUmVwgmyV4,333
|
|
32
|
+
termux_diffusion/data/release-public-keys.json,sha256=7gOQmHV31g8RZ8wI53Y4_g5Ir8voygS9s4smrwW6HwM,224
|
|
33
|
+
termux_diffusion/data/validated-vulkan-profiles.json,sha256=N4-pDOZJrf8ByulBxRRnIhQW5HWy7-yXTAxAppwi98E,8316
|
|
34
|
+
termux_diffusion/data/prompt_cache/108a7149c4e70550.json,sha256=RtddBDcEBihHBMzIFDZbSwaUdYM4K7Sb9VKZD-QWi1U,359
|
|
35
|
+
amv_diffusion-2.1.0.dist-info/METADATA,sha256=JnTnPXq2CLxFSVYbmISvFeG-5slvku7cWOQXptdk9aY,9115
|
|
36
|
+
amv_diffusion-2.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
37
|
+
amv_diffusion-2.1.0.dist-info/entry_points.txt,sha256=ZuDSyLzY3-7KMPLddrp72cjvBOeF49Cyx9cYt2Z4N9o,256
|
|
38
|
+
amv_diffusion-2.1.0.dist-info/top_level.txt,sha256=3rMTnjMa0GVaZgixdY5fn-Drj3LkxJ-jQW3KjzkWodA,17
|
|
39
|
+
amv_diffusion-2.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 uno-km (쌩초보코딩단)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
termux_diffusion
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# Copyright (c) 2026 Uno Kim / AMEVA Foundation. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0 OR Commercial-License
|
|
3
|
+
from ._version import __version__
|
|
4
|
+
|
|
5
|
+
from .core import (
|
|
6
|
+
GenerationResult,
|
|
7
|
+
ProgressInfo,
|
|
8
|
+
async_generate,
|
|
9
|
+
generate,
|
|
10
|
+
generate_stream,
|
|
11
|
+
get_default_negative_prompt,
|
|
12
|
+
get_quality_guard_negative_prompt,
|
|
13
|
+
set_default_negative_prompt,
|
|
14
|
+
resolve_vram_and_streaming_policy,
|
|
15
|
+
)
|
|
16
|
+
from .workflow import (
|
|
17
|
+
DAGEngine,
|
|
18
|
+
NODE_REGISTRY,
|
|
19
|
+
WorkflowError,
|
|
20
|
+
WorkflowExecutor,
|
|
21
|
+
WorkflowFormatError,
|
|
22
|
+
WorkflowParser,
|
|
23
|
+
execute_workflow,
|
|
24
|
+
)
|
|
25
|
+
from .web import (
|
|
26
|
+
DiffusionWebServer,
|
|
27
|
+
run_web_server,
|
|
28
|
+
)
|
|
29
|
+
from .exceptions import (
|
|
30
|
+
AmevaTermuxError,
|
|
31
|
+
InferenceTimeoutError,
|
|
32
|
+
ModelDownloadError,
|
|
33
|
+
ModelNotFoundError,
|
|
34
|
+
OOMRiskError,
|
|
35
|
+
PlatformNotSupportedError,
|
|
36
|
+
ProvisioningError,
|
|
37
|
+
TermuxDiffusionError,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
from .hub import (
|
|
41
|
+
DEFAULT_PRESETS,
|
|
42
|
+
clear_cache,
|
|
43
|
+
download_model,
|
|
44
|
+
get_cache_dir,
|
|
45
|
+
get_device_model_catalog,
|
|
46
|
+
is_model_cached,
|
|
47
|
+
list_cached_models,
|
|
48
|
+
list_presets,
|
|
49
|
+
register_model,
|
|
50
|
+
resolve_model_path,
|
|
51
|
+
set_cache_dir,
|
|
52
|
+
)
|
|
53
|
+
from .engine import (
|
|
54
|
+
DiffusionEngine,
|
|
55
|
+
DiffusionRuntime,
|
|
56
|
+
get_binary_path,
|
|
57
|
+
locate_sd_cli,
|
|
58
|
+
load,
|
|
59
|
+
)
|
|
60
|
+
from .doctor import run_doctor
|
|
61
|
+
from .installer import provision_engine
|
|
62
|
+
from .platform import (
|
|
63
|
+
TermuxWakeLock,
|
|
64
|
+
check_memory_safety,
|
|
65
|
+
export_to_android_gallery,
|
|
66
|
+
get_galaxy_gallery_dir,
|
|
67
|
+
get_memory_info,
|
|
68
|
+
get_optimal_thread_count,
|
|
69
|
+
is_android_termux,
|
|
70
|
+
is_arm64,
|
|
71
|
+
)
|
|
72
|
+
from .hardware import (
|
|
73
|
+
ComputeBackend,
|
|
74
|
+
HardwareProfile,
|
|
75
|
+
TermuxExecutionGuard,
|
|
76
|
+
detect_hardware_profile,
|
|
77
|
+
detect_hardware,
|
|
78
|
+
format_hardware_report,
|
|
79
|
+
get_kernel_physical_memory_gb,
|
|
80
|
+
resolve_device_backend,
|
|
81
|
+
resolve_device,
|
|
82
|
+
)
|
|
83
|
+
from .downloader import list_models
|
|
84
|
+
|
|
85
|
+
from .npu import (
|
|
86
|
+
NPUProfile,
|
|
87
|
+
NPUVendor,
|
|
88
|
+
detect_npu_capabilities,
|
|
89
|
+
get_optimal_heterogeneous_pipeline,
|
|
90
|
+
)
|
|
91
|
+
from .purger import purge_idle_processes, PurgeSummary
|
|
92
|
+
from .safety import (
|
|
93
|
+
evaluate_safe_memory_budget,
|
|
94
|
+
SafeMemoryAssessment,
|
|
95
|
+
save_latent_checkpoint,
|
|
96
|
+
load_latent_checkpoint,
|
|
97
|
+
)
|
|
98
|
+
from .canvas import (
|
|
99
|
+
magic_eraser,
|
|
100
|
+
magic_grab,
|
|
101
|
+
magic_expand,
|
|
102
|
+
decompose_layers,
|
|
103
|
+
CanvasProfilingResult,
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
__author__ = "uno-km (AMEVA Foundation)"
|
|
107
|
+
__license__ = "MIT"
|
|
108
|
+
|
|
109
|
+
__all__ = [
|
|
110
|
+
"__version__",
|
|
111
|
+
"generate",
|
|
112
|
+
"generate_stream",
|
|
113
|
+
"async_generate",
|
|
114
|
+
"GenerationResult",
|
|
115
|
+
"ProgressInfo",
|
|
116
|
+
"download_model",
|
|
117
|
+
"resolve_model_path",
|
|
118
|
+
"register_model",
|
|
119
|
+
"set_cache_dir",
|
|
120
|
+
"get_cache_dir",
|
|
121
|
+
"is_model_cached",
|
|
122
|
+
"list_cached_models",
|
|
123
|
+
"get_device_model_catalog",
|
|
124
|
+
"clear_cache",
|
|
125
|
+
"list_presets",
|
|
126
|
+
"DEFAULT_PRESETS",
|
|
127
|
+
"DiffusionEngine",
|
|
128
|
+
"DiffusionRuntime",
|
|
129
|
+
"load",
|
|
130
|
+
"get_binary_path",
|
|
131
|
+
"locate_sd_cli",
|
|
132
|
+
"provision_engine",
|
|
133
|
+
"run_doctor",
|
|
134
|
+
"is_android_termux",
|
|
135
|
+
"is_arm64",
|
|
136
|
+
"check_memory_safety",
|
|
137
|
+
"get_memory_info",
|
|
138
|
+
"get_optimal_thread_count",
|
|
139
|
+
"get_galaxy_gallery_dir",
|
|
140
|
+
"export_to_android_gallery",
|
|
141
|
+
"TermuxWakeLock",
|
|
142
|
+
"TermuxExecutionGuard",
|
|
143
|
+
"get_kernel_physical_memory_gb",
|
|
144
|
+
"resolve_vram_and_streaming_policy",
|
|
145
|
+
"HardwareProfile",
|
|
146
|
+
"detect_hardware",
|
|
147
|
+
"resolve_device",
|
|
148
|
+
"list_models",
|
|
149
|
+
"AmevaTermuxError",
|
|
150
|
+
"TermuxDiffusionError",
|
|
151
|
+
"PlatformNotSupportedError",
|
|
152
|
+
"ModelNotFoundError",
|
|
153
|
+
"ModelDownloadError",
|
|
154
|
+
"ProvisioningError",
|
|
155
|
+
"OOMRiskError",
|
|
156
|
+
"purge_idle_processes",
|
|
157
|
+
"PurgeSummary",
|
|
158
|
+
"evaluate_safe_memory_budget",
|
|
159
|
+
"SafeMemoryAssessment",
|
|
160
|
+
"save_latent_checkpoint",
|
|
161
|
+
"load_latent_checkpoint",
|
|
162
|
+
"magic_eraser",
|
|
163
|
+
"magic_grab",
|
|
164
|
+
"magic_expand",
|
|
165
|
+
"decompose_layers",
|
|
166
|
+
"CanvasProfilingResult",
|
|
167
|
+
"execute_workflow",
|
|
168
|
+
"WorkflowExecutor",
|
|
169
|
+
"WorkflowParser",
|
|
170
|
+
"DAGEngine",
|
|
171
|
+
"NODE_REGISTRY",
|
|
172
|
+
"WorkflowError",
|
|
173
|
+
"WorkflowFormatError",
|
|
174
|
+
]
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
_LAZY_DETAILER = ("detect_faces_on_image", "refine_face_regions")
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def __getattr__(name):
|
|
181
|
+
"""Face refinement needs numpy and Pillow; load it only when it is used (PEP 562)."""
|
|
182
|
+
if name in _LAZY_DETAILER:
|
|
183
|
+
from . import detailer
|
|
184
|
+
return getattr(detailer, name)
|
|
185
|
+
raise AttributeError("module %r has no attribute %r" % (__name__, name))
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Copyright (c) 2026 Uno Kim / AMEVA Foundation. All rights reserved.
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0 OR Commercial-License
|
|
3
|
+
"""
|
|
4
|
+
termux_diffusion.adapter
|
|
5
|
+
=========================
|
|
6
|
+
AMEVA Component Protocol v1 — Orchestrator Adapter (v0.8.1 호환)
|
|
7
|
+
"""
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from typing import Any, AsyncIterator
|
|
11
|
+
|
|
12
|
+
from ameva_component.adapter_base import BaseOrchestratorAdapter
|
|
13
|
+
from ameva_component.exceptions import OperationNotSupported
|
|
14
|
+
from termux_diffusion.control.component import DiffusionControl
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class DiffusionOrchestratorAdapter(BaseOrchestratorAdapter):
|
|
18
|
+
"""Diffusion Orchestrator Adapter.
|
|
19
|
+
|
|
20
|
+
이미지 생성은 sd-cli subprocess를 통해 수행됩니다.
|
|
21
|
+
infer()는 OPERATION_NOT_SUPPORTED — generate() REST endpoint를 사용하십시오.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
COMPONENT_ID = "termux-diffusion"
|
|
25
|
+
|
|
26
|
+
def __init__(self, control: DiffusionControl | None = None) -> None:
|
|
27
|
+
self._control = control or DiffusionControl()
|
|
28
|
+
|
|
29
|
+
async def infer(self, request: dict[str, Any]) -> AsyncIterator[dict[str, Any]]:
|
|
30
|
+
"""Diffusion generation은 REST endpoint /generate 를 통해 수행됩니다.
|
|
31
|
+
Orchestrator 직접 streaming은 미지원 — OperationNotSupported를 발생시킵니다.
|
|
32
|
+
|
|
33
|
+
P0-2: yield 방식은 상위 소비자가 Frame을 정상으로 처리할 위험이 있어 raise로 변경.
|
|
34
|
+
"""
|
|
35
|
+
raise OperationNotSupported(operation="infer", component_id=self.COMPONENT_ID)
|
|
36
|
+
yield # type: ignore[misc]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def create_adapter() -> DiffusionOrchestratorAdapter:
|
|
40
|
+
"""Entry Point Factory."""
|
|
41
|
+
return DiffusionOrchestratorAdapter()
|