rsdiff 0.1.0__tar.gz

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.
@@ -0,0 +1,50 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ /build/
5
+ /dist/
6
+ .venv/
7
+ .venv-*/
8
+ venv/
9
+ .eggs/
10
+
11
+ # Data, weights, logs (repo-root only; never match package modules such as src/rsdiff/datasets)
12
+ /data/
13
+ /datasets/
14
+ /checkpoints/
15
+ /runs/
16
+ /logs/
17
+ /outputs/
18
+ /generated/
19
+ /ddpm/ckpts/
20
+ /ddpm/logs/
21
+ wandb/
22
+ *.pt
23
+ *.safetensors
24
+ *.ckpt
25
+ *.bin
26
+
27
+ # Editor / OS / tool caches
28
+ .idea/
29
+ .vscode/
30
+ .DS_Store
31
+ .ruff_cache/
32
+ .mypy_cache/
33
+ .pytest_cache/
34
+ .serena/
35
+ .ipynb_checkpoints/
36
+
37
+ # Secrets and per-machine state
38
+ .env
39
+ .env.local
40
+ .vast/
41
+ secrets/
42
+ .claude/settings.local.json
43
+ .claude/.memory/
44
+
45
+ # mkdocs build output
46
+ /docs/site/site/
47
+ /docs/site/site_out/
48
+
49
+ # Private notes (drafts, roadmap, lit reviews)
50
+ .notes/
@@ -0,0 +1,26 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ First PyPI release. The package now samples and scores the released `rsdiff1.5` cascade
6
+ instead of raising `NotImplementedError`.
7
+
8
+ - `rsdiff sample --prompt "..."` downloads the released checkpoint
9
+ (`asebaq/rsdiff-sr-cascade-ep650`, pinned revision, SHA-256 verified) and writes 256×256
10
+ PNGs plus `captions.txt`. `--rsicd ROOT` draws RSICD captions instead; with seed 17 and
11
+ the full test split they are the captions of the published bundle. Interrupted runs
12
+ resume. Every PNG carries the prompt and a synthetic-content notice in its text chunks.
13
+ - `rsdiff eval fid` and `rsdiff eval clip` score a bundle with the published protocol.
14
+ On the published 1,093-image bundle they return FID 65.688 (released 65.698) and
15
+ CLIP-score 0.27771 (released 0.27771). FID must be scored against real images built by
16
+ `scripts/build_rsicd_csv.py --split-csv`; the original RSICD JPEGs give 70.15.
17
+ - `rsdiff.cascade`, `rsdiff.config` (packaged `rsdiff1.5` and `rsdiff1` presets),
18
+ `rsdiff.eval` and `rsdiff.datasets` form the Python API.
19
+ - Sampling and FID run on CUDA or CPU. Apple MPS is not used: imagen-pytorch 2.1.0 and
20
+ torchmetrics' FID need float64.
21
+ - Removed the unused `diffusers` scaffold (`rsdiff train`, `rsdiff.models`,
22
+ `rsdiff.pipelines`, `rsdiff.conditioning`, `zeroshot_oa`) and its dependencies.
23
+ Training remains in `ddpm/` until the packaged sampler's metrics match it.
24
+ - Corrected the documented metric protocol: the headline FID uses torchmetrics'
25
+ `FrechetInceptionDistance` (feature 2048), not clean-fid.
26
+ - The commercial monitoring experiments moved to a separate repository.
@@ -0,0 +1,37 @@
1
+ cff-version: 1.2.0
2
+ title: "RSDiff: remote sensing image generation from text"
3
+ version: 0.1.0
4
+ message: >-
5
+ If you use this software or the reproduction results, please cite both the
6
+ published paper (preferred) and this repository.
7
+ type: software
8
+ authors:
9
+ - family-names: Sebaq
10
+ given-names: Ahmad
11
+ email: ahmad.sebaq@gmail.com
12
+ repository-code: "https://github.com/asebaq/rsdiff"
13
+ url: "https://asebaq.github.io/rsdiff"
14
+ license: Apache-2.0
15
+ keywords:
16
+ - diffusion models
17
+ - text-to-image
18
+ - remote sensing
19
+ - satellite imagery
20
+ - RSICD
21
+ - cascaded diffusion
22
+ - generative models
23
+ preferred-citation:
24
+ type: article
25
+ title: "RSDiff: remote sensing image generation from text using diffusion model"
26
+ authors:
27
+ - family-names: Sebaq
28
+ given-names: Ahmad
29
+ - family-names: ElHelw
30
+ given-names: Mohamed
31
+ journal: "Neural Computing and Applications"
32
+ volume: 36
33
+ issue: 36
34
+ start: 23103
35
+ end: 23111
36
+ year: 2024
37
+ doi: "10.1007/s00521-024-10363-3"
rsdiff-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
rsdiff-0.1.0/NOTICE ADDED
@@ -0,0 +1,23 @@
1
+ RSDiff
2
+ Copyright 2026 Ahmad Sebaq
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE). The license
5
+ covers the code in this repository only.
6
+
7
+ Third-party components used at runtime, not distributed with RSDiff:
8
+
9
+ - imagen-pytorch (https://github.com/lucidrains/imagen-pytorch), MIT License. RSDiff's
10
+ cascade is built from its Unet, Imagen and ImagenTrainer classes.
11
+ - T5-base text encoder and tokenizer (https://huggingface.co/google-t5/t5-base),
12
+ Apache License 2.0, downloaded from the Hugging Face Hub on first use.
13
+ - OpenAI CLIP ViT-B/32 (https://huggingface.co/openai/clip-vit-base-patch32), MIT License,
14
+ used only for evaluation.
15
+
16
+ The released checkpoint (https://huggingface.co/asebaq/rsdiff-sr-cascade-ep650) was
17
+ trained on the RSICD dataset (Lu et al., "Exploring Models and Data for Remote Sensing
18
+ Image Caption Generation", IEEE TGRS 2018). No RSICD images or captions are distributed
19
+ with this package. RSICD's terms for commercial use have not been established; see
20
+ docs/LICENSE_AUDIT.md before using the checkpoint or its outputs commercially.
21
+
22
+ Images produced by RSDiff are synthetic. They are not observations or predictions of any
23
+ real location.
rsdiff-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,245 @@
1
+ Metadata-Version: 2.5
2
+ Name: rsdiff
3
+ Version: 0.1.0
4
+ Summary: Text-to-satellite-image diffusion: the RSDiff cascade (NCAA 2024), released weights, and its FID/CLIP evaluation.
5
+ Project-URL: Homepage, https://github.com/asebaq/rsdiff
6
+ Project-URL: Documentation, https://asebaq.github.io/rsdiff
7
+ Project-URL: Issues, https://github.com/asebaq/rsdiff/issues
8
+ Project-URL: Changelog, https://github.com/asebaq/rsdiff/blob/main/CHANGELOG.md
9
+ Project-URL: Paper, https://doi.org/10.1007/s00521-024-10363-3
10
+ Project-URL: Weights, https://huggingface.co/asebaq/rsdiff-sr-cascade-ep650
11
+ Author-email: Ahmad Sebaq <ahmad.sebaq@gmail.com>
12
+ License-Expression: Apache-2.0
13
+ License-File: LICENSE
14
+ License-File: NOTICE
15
+ Keywords: diffusion,imagen,remote-sensing,rsicd,satellite,text-to-image
16
+ Classifier: Development Status :: 3 - Alpha
17
+ Classifier: Intended Audience :: Science/Research
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
25
+ Classifier: Topic :: Scientific/Engineering :: Image Processing
26
+ Requires-Python: >=3.10
27
+ Requires-Dist: huggingface-hub>=0.25
28
+ Requires-Dist: imagen-pytorch==2.1.0
29
+ Requires-Dist: numpy>=1.26
30
+ Requires-Dist: omegaconf>=2.3
31
+ Requires-Dist: pandas>=2.2
32
+ Requires-Dist: pillow>=10.4
33
+ Requires-Dist: torch>=2.4
34
+ Requires-Dist: torchvision>=0.19
35
+ Requires-Dist: tqdm>=4.66
36
+ Requires-Dist: transformers<5,>=4.44
37
+ Provides-Extra: eval
38
+ Requires-Dist: torchmetrics[image]>=1.4; extra == 'eval'
39
+ Description-Content-Type: text/markdown
40
+
41
+ <h1 align="center">
42
+ <a href="https://github.com/asebaq/rsdiff">
43
+ <picture>
44
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/asebaq/rsdiff/main/docs/assets/cover_dark.svg">
45
+ <img alt="rsdiff" src="https://raw.githubusercontent.com/asebaq/rsdiff/main/docs/assets/cover_light.svg" width="640">
46
+ </picture>
47
+ </a>
48
+ </h1>
49
+
50
+ <p align="center">
51
+ <a href="https://pypi.org/project/rsdiff/"><img alt="PyPI" src="https://img.shields.io/pypi/v/rsdiff?color=1D4ED8"></a>
52
+ <a href="https://pypi.org/project/rsdiff/"><img alt="Python" src="https://img.shields.io/python/required-version-toml?tomlFilePath=https%3A%2F%2Fraw.githubusercontent.com%2Fasebaq%2Frsdiff%2Fmain%2Fpyproject.toml"></a>
53
+ <a href="https://github.com/asebaq/rsdiff/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/asebaq/rsdiff/actions/workflows/ci.yml/badge.svg"></a>
54
+ <a href="https://github.com/asebaq/rsdiff/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/github/license/asebaq/rsdiff"></a>
55
+ <a href="https://doi.org/10.1007/s00521-024-10363-3"><img alt="DOI" src="https://img.shields.io/badge/DOI-10.1007%2Fs00521--024--10363--3-blue"></a>
56
+ <a href="https://huggingface.co/asebaq/rsdiff-sr-cascade-ep650"><img alt="Hugging Face model" src="https://img.shields.io/badge/Hugging%20Face-rsdiff--sr--cascade--ep650-yellow"></a>
57
+ </p>
58
+
59
+ <p align="center">
60
+ <a href="#install"><strong>Install</strong></a> &middot;
61
+ <a href="#use"><strong>Use</strong></a> &middot;
62
+ <a href="#results"><strong>Results</strong></a> &middot;
63
+ <a href="#how-it-works"><strong>How it works</strong></a> &middot;
64
+ <a href="#limitations"><strong>Limitations</strong></a> &middot;
65
+ <a href="#training"><strong>Training</strong></a> &middot;
66
+ <a href="#roadmap"><strong>Roadmap</strong></a> &middot;
67
+ <a href="#citation"><strong>Citation</strong></a>
68
+ </p>
69
+
70
+ **Text-to-satellite-image diffusion, packaged.** rsdiff is the reference implementation
71
+ of RSDiff ([Neural Computing and Applications, 2024](https://doi.org/10.1007/s00521-024-10363-3)):
72
+ a T5-conditioned, Imagen-style cascaded diffusion model that turns a caption such as
73
+ "many buildings and green trees are around a playground ." into a 256x256 synthetic
74
+ remote-sensing image. One command downloads the released RSICD-trained checkpoint,
75
+ verifies it, and samples; a second scores the result with the same FID and CLIP-score
76
+ protocol used for the published numbers (FID 65.70, CLIP-score 0.278 on the full
77
+ RSICD test split).
78
+
79
+ Every image rsdiff produces is synthetic. It is not an observation or a prediction of
80
+ any real place, and each PNG says so in its metadata.
81
+
82
+ <p align="center">
83
+ <img src="https://raw.githubusercontent.com/asebaq/rsdiff/main/docs/figures/sample_montage.png" width="780" alt="Synthetic 256x256 samples generated from RSICD test captions">
84
+ </p>
85
+
86
+ ## Install
87
+
88
+ ```bash
89
+ pip install rsdiff # sampling + CLIP-score
90
+ pip install "rsdiff[eval]" # adds torchmetrics for FID
91
+ ```
92
+
93
+ Python 3.10+. Sampling runs on CUDA when available and otherwise on CPU. Apple MPS is
94
+ not supported: imagen-pytorch 2.1.0 and the torchmetrics FID both use float64.
95
+
96
+ ## Use
97
+
98
+ Generate images from your own captions. The first run downloads the released checkpoint
99
+ (1.9 GB, pinned Hugging Face revision) and verifies its SHA-256:
100
+
101
+ ```bash
102
+ rsdiff sample --prompt "many buildings and green trees are around a playground ." -n 4 --out-dir generated
103
+ ```
104
+
105
+ This writes 256x256 PNGs and a `captions.txt` to `generated/`. `--prompt` can be
106
+ repeated. Each PNG carries `Software`, `Description` (a synthetic-content notice), and
107
+ `Prompt` text chunks.
108
+
109
+ Or draw captions from RSICD (first caption, `sent1`, shuffled with `--seed`, default 17):
110
+
111
+ ```bash
112
+ rsdiff sample --rsicd data/RSICD_optimal --split test -n 16 --out-dir generated
113
+ ```
114
+
115
+ Useful options: `--cond-scale` (default 5), `--batch-size` (default 2), `--lr-only`
116
+ (stop at the 128x128 base stage), `--cpu`, `--config rsdiff1.5|rsdiff1|path.yaml`, and
117
+ `--checkpoint PATH` (required for non-default configs). An interrupted run resumes:
118
+ batches whose PNGs already exist are skipped.
119
+
120
+ Score a generated directory against the RSICD test split:
121
+
122
+ ```bash
123
+ rsdiff eval fid generated --rsicd data/RSICD_optimal # --feature 2048 --size 256 by default
124
+ rsdiff eval clip generated # clip_score, clip_score_shuffled, delta
125
+ ```
126
+
127
+ Both print JSON. The same pieces are available from Python:
128
+
129
+ ```python
130
+ from rsdiff.cascade import download_release, generate, load_cascade
131
+ from rsdiff.config import load_preset
132
+ from rsdiff.eval import clip_score
133
+
134
+ cfg = load_preset("rsdiff1.5")
135
+ trainer = load_cascade(cfg, download_release())
136
+ paths = generate(trainer.sample, ["a river runs through the green farmland ."], "generated")
137
+ print(clip_score("generated"))
138
+ ```
139
+
140
+ `rsdiff.datasets.rsicd.sample_captions` reproduces the CLI's RSICD caption draw, and
141
+ `rsdiff.eval.fid` computes FID.
142
+
143
+ ## Results
144
+
145
+ Released checkpoint, full RSICD test split (N=1,093), cascade output at 256x256,
146
+ `cond_scale=5`:
147
+
148
+ | Metric | Value |
149
+ | --- | --- |
150
+ | FID (torchmetrics Inception, feature 2048, both sides at 256) | **65.70** |
151
+ | CLIP-score (OpenAI CLIP ViT-B/32) | **0.278** |
152
+ | CLIP-score, shuffled-caption baseline | 0.232 |
153
+ | Parameters (base UNet 27.2 M + SR UNet 92.7 M) | 119.9 M[^params] |
154
+
155
+ [^params]: 119.9 M counts the two standalone UNets, as in the paper and model card.
156
+ Loaded inside the cascade, the SR UNet gains low-resolution conditioning layers
157
+ (105.0 M), so the cascade holds 132.2 M trainable parameters, plus the frozen T5-base
158
+ text encoder.
159
+
160
+ The CLIP-score sits 0.046 above the shuffled-caption baseline: the images follow their
161
+ captions, not just the RSICD domain.
162
+
163
+ | Curve | Figure |
164
+ | --- | --- |
165
+ | SR FID versus epoch (ep150 to ep1000) | [`docs/figures/sr_fid_curve.png`](docs/figures/sr_fid_curve.png) |
166
+ | CFG `cond_scale` sweep on the selected SR milestone | [`docs/figures/cfg_sweep.png`](docs/figures/cfg_sweep.png) |
167
+ | LR base FID versus epoch | [`docs/figures/lr_fid_curve.png`](docs/figures/lr_fid_curve.png) |
168
+
169
+ The numbers behind every figure are committed in [`results/`](results/). Methodology and
170
+ discussion: [`docs/REPORT.md`](docs/REPORT.md). Model card:
171
+ [`docs/model_card.md`](docs/model_card.md).
172
+
173
+ ## How it works
174
+
175
+ 1. A frozen **T5-base** encoder turns the caption into token embeddings.
176
+ 2. A **128x128 base UNet** denoises from noise over 1,000 DDPM steps, cross-attending to
177
+ the text.
178
+ 3. A **256x256 super-resolution UNet** denoises again, conditioned on the text and the
179
+ upsampled base image.
180
+
181
+ Both stages use classifier-free guidance (trained with 10% caption dropout) with a shared
182
+ `cond_scale`; 5 is the value selected by the CFG sweep and used for every headline
183
+ number. Sampling uses the EMA weights of the merged epoch-650 checkpoint. The presets
184
+ ship inside the package: [`rsdiff1.5`](src/rsdiff/configs/rsdiff1.5.yaml) (released) and
185
+ [`rsdiff1`](src/rsdiff/configs/rsdiff1.yaml) (the 723 M paper configuration; weights not
186
+ released).
187
+
188
+ ## Limitations
189
+
190
+ - **Synthetic only.** Outputs are plausible-looking imagery, not observed or predicted
191
+ geography. Do not use them as evidence about a real location.
192
+ - **RSICD domain.** The model was trained on the 30 RSICD scene types and their short,
193
+ lowercase captions. Prompts unlike those captions have not been evaluated.
194
+ - **256 px.** The cascade stops at 256x256.
195
+ - **No Apple MPS.** float64 operations in imagen-pytorch 2.1.0 and torchmetrics FID are
196
+ not supported on MPS.
197
+ - **CPU sampling is slow.** 2,000 denoising steps per image took about an hour on an
198
+ Apple-silicon CPU; use a CUDA GPU for more than a handful of images.
199
+ - **Weights not commercially cleared.** RSICD's commercial terms are unresolved; see
200
+ [`docs/LICENSE_AUDIT.md`](docs/LICENSE_AUDIT.md).
201
+
202
+ ## Training
203
+
204
+ Training still runs through the frozen reference implementation in [`ddpm/`](ddpm/):
205
+
206
+ ```bash
207
+ bash ddpm/scripts/run_training_local.sh # stage 1: 128x128 base UNet
208
+ bash ddpm/scripts/run_sr.sh # stage 2: 256x256 SR UNet on the frozen base
209
+ ```
210
+
211
+ [`docs/reproducibility.md`](docs/reproducibility.md) is the complete runbook: environment,
212
+ dataset preparation, training, milestone sweeps, sampling the 1,093-image bundle, and
213
+ scoring.
214
+
215
+ ## Roadmap
216
+
217
+ 1. **Reproduce with the package.** Regenerate the 1,093-image bundle with `rsdiff sample`
218
+ and match the published FID and CLIP-score; then delete `ddpm/`.
219
+ 2. **Commercial relevance.** Test whether synthetic augmentation improves a downstream
220
+ model on an untouched real-data test set.
221
+
222
+ Details and acceptance criteria: [`docs/PLAN.md`](docs/PLAN.md).
223
+
224
+ ## Citation
225
+
226
+ ```bibtex
227
+ @article{sebaq2024rsdiff,
228
+ title = {RSDiff: remote sensing image generation from text using diffusion model},
229
+ author = {Sebaq, Ahmad and ElHelw, Mohamed},
230
+ journal = {Neural Computing and Applications},
231
+ volume = {36},
232
+ number = {36},
233
+ pages = {23103--23111},
234
+ year = {2024},
235
+ doi = {10.1007/s00521-024-10363-3}
236
+ }
237
+ ```
238
+
239
+ ## License
240
+
241
+ Code: Apache-2.0, see [`LICENSE`](LICENSE) and [`NOTICE`](NOTICE). The released weights
242
+ were trained on RSICD, whose commercial terms are unresolved; dataset, dependency, and
243
+ derived-weight rights are tracked in [`docs/LICENSE_AUDIT.md`](docs/LICENSE_AUDIT.md).
244
+ Built on [`lucidrains/imagen-pytorch`](https://github.com/lucidrains/imagen-pytorch);
245
+ developed at the Center for Informatics Science, Nile University.