File size: 5,033 Bytes
2ce449d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": [],
      "gpuType": "T4"
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    },
    "accelerator": "GPU"
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# SAII-CLDM Seismic Inversion Demo\n",
        "\n",
        "This notebook demonstrates seismic impedance inversion using SAII-CLDM (Seismic-Amplitude-Guided Iterative Inversion with Cross-Domain Latent Diffusion Model).\n",
        "\n",
        "**Paper:** [arXiv:2506.13529](https://arxiv.org/html/2506.13529v1)\n",
        "\n",
        "**Repository:** https://huggingface.co/mally-2000/saii-cldm-synthetic\n",
        "\n",
        "## Two Methods:\n",
        "1. **SAII-LDDPM** - Latent Diffusion with Denoising Probabilistic Model (1000 steps)\n",
        "2. **SAII-CLDM** - Cross-Domain Latent Diffusion Model (30 steps, faster)\n",
        "\n",
        "Make sure to enable GPU runtime: Runtime → Change runtime type → Hardware accelerator → GPU"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Step 1: Clone the Repository"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "!git clone https://huggingface.co/mally-2000/saii-cldm-synthetic\n",
        "%cd saii-cldm-synthetic"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Step 2: Install Dependencies"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "!pip install -r requirements.txt -q"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Step 3: Run Inference\n",
        "\n",
        "Choose which method to run:\n",
        "- `LDDPM` (default): Higher quality, slower (1000 steps)\n",
        "- `CLDM`: Faster inference (30 steps)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### Option A: SAII-LDDPM (Slower, Higher Quality)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "!python infer.py"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### Option B: SAII-CLDM (Faster)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "!python infer.py CLDM"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Step 4: Visualize Results"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "from IPython.display import Image, display\n",
        "import os\n",
        "\n",
        "# Display comparison image from LDDPM run\n",
        "if os.path.exists(\"outputs/infer_LDDPM/comparison.png\"):\n",
        "    print(\"SAII-LDDPM Results:\")\n",
        "    display(Image(filename=\"outputs/infer_LDDPM/comparison.png\"))\n",
        "\n",
        "# Display comparison image from CLDM run\n",
        "if os.path.exists(\"outputs/infer_CLDM/comparison.png\"):\n",
        "    print(\"\\nSAII-CLDM Results:\")\n",
        "    display(Image(filename=\"outputs/infer_CLDM/comparison.png\"))"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Step 5: Download Results (Optional)\n",
        "\n",
        "Download the output files to your local machine."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "from google.colab import files\n",
        "import glob\n",
        "\n",
        "# Download all output files\n",
        "for f in glob.glob(\"outputs/**/*\", recursive=True):\n",
        "    if os.path.isfile(f):\n",
        "        print(f\"Downloading: {f}\")\n",
        "        files.download(f)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Expected Results on Overthrust Sample\n",
        "\n",
        "| Method | Steps | PSNR | SSIM | PCC | RRE |\n",
        "|---|---:|---:|---:|---:|---:|\n",
        "| SAII-LDDPM | 1000 | 33.44 | 0.955 | 0.996 | 0.032 |\n",
        "| SAII-CLDM | 30 | 33.13 | 0.949 | 0.995 | 0.034 |\n",
        "\n",
        "The comparison image shows (left to right):\n",
        "1. Low-frequency impedance (initial model)\n",
        "2. Seismic record (observed data)\n",
        "3. Target (ground truth impedance)\n",
        "4. Prediction (inverted impedance)"
      ]
    }
  ]
}