KumaPower commited on
Commit
2ad4160
·
verified ·
1 Parent(s): 34c53c1

Publish MEDFE model card, architecture and inference examples

Browse files
Files changed (11) hide show
  1. .gitattributes +2 -0
  2. LICENSE.md +177 -0
  3. README.md +177 -1
  4. SHA256SUMS +10 -0
  5. expected.png +0 -0
  6. mask.png +0 -0
  7. masked.png +0 -0
  8. medfe-architecture.png +3 -0
  9. medfe-preview.png +3 -0
  10. release.json +66 -0
  11. training-config.yaml +57 -0
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* 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
 
 
 
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
36
+ medfe-architecture.png filter=lfs diff=lfs merge=lfs -text
37
+ medfe-preview.png filter=lfs diff=lfs merge=lfs -text
LICENSE.md ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## creative commons
2
+
3
+ # Attribution-NonCommercial-ShareAlike 4.0 International
4
+
5
+ Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible.
6
+
7
+ ### Using Creative Commons Public Licenses
8
+
9
+ Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses.
10
+
11
+ * __Considerations for licensors:__ Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. [More considerations for licensors](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensors).
12
+
13
+ * __Considerations for the public:__ By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. [More considerations for the public](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensees).
14
+
15
+ ## Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License
16
+
17
+ By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions.
18
+
19
+ ### Section 1 – Definitions.
20
+
21
+ a. __Adapted Material__ means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.
22
+
23
+ b. __Adapter's License__ means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.
24
+
25
+ c. __BY-NC-SA Compatible License__ means a license listed at [creativecommons.org/compatiblelicenses](http://creativecommons.org/compatiblelicenses), approved by Creative Commons as essentially the equivalent of this Public License.
26
+
27
+ d. __Copyright and Similar Rights__ means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.
28
+
29
+ e. __Effective Technological Measures__ means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements.
30
+
31
+ f. __Exceptions and Limitations__ means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material.
32
+
33
+ g. __License Elements__ means the license attributes listed in the name of a Creative Commons Public License. The License Elements of this Public License are Attribution, NonCommercial, and ShareAlike.
34
+
35
+ h. __Licensed Material__ means the artistic or literary work, database, or other material to which the Licensor applied this Public License.
36
+
37
+ i. __Licensed Rights__ means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license.
38
+
39
+ h. __Licensor__ means the individual(s) or entity(ies) granting rights under this Public License.
40
+
41
+ i. __NonCommercial__ means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange.
42
+
43
+ j. __Share__ means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them.
44
+
45
+ k. __Sui Generis Database Rights__ means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world.
46
+
47
+ l. __You__ means the individual or entity exercising the Licensed Rights under this Public License. Your has a corresponding meaning.
48
+
49
+ ### Section 2 – Scope.
50
+
51
+ a. ___License grant.___
52
+
53
+ 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to:
54
+
55
+ A. reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and
56
+
57
+ B. produce, reproduce, and Share Adapted Material for NonCommercial purposes only.
58
+
59
+ 2. __Exceptions and Limitations.__ For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions.
60
+
61
+ 3. __Term.__ The term of this Public License is specified in Section 6(a).
62
+
63
+ 4. __Media and formats; technical modifications allowed.__ The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material.
64
+
65
+ 5. __Downstream recipients.__
66
+
67
+ A. __Offer from the Licensor – Licensed Material.__ Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License.
68
+
69
+ B. __Additional offer from the Licensor – Adapted Material.__ Every recipient of Adapted Material from You automatically receives an offer from the Licensor to exercise the Licensed Rights in the Adapted Material under the conditions of the Adapter’s License You apply.
70
+
71
+ C. __No downstream restrictions.__ You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material.
72
+
73
+ 6. __No endorsement.__ Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i).
74
+
75
+ b. ___Other rights.___
76
+
77
+ 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise.
78
+
79
+ 2. Patent and trademark rights are not licensed under this Public License.
80
+
81
+ 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes.
82
+
83
+ ### Section 3 – License Conditions.
84
+
85
+ Your exercise of the Licensed Rights is expressly made subject to the following conditions.
86
+
87
+ a. ___Attribution.___
88
+
89
+ 1. If You Share the Licensed Material (including in modified form), You must:
90
+
91
+ A. retain the following if it is supplied by the Licensor with the Licensed Material:
92
+
93
+ i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated);
94
+
95
+ ii. a copyright notice;
96
+
97
+ iii. a notice that refers to this Public License;
98
+
99
+ iv. a notice that refers to the disclaimer of warranties;
100
+
101
+ v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable;
102
+
103
+ B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and
104
+
105
+ C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License.
106
+
107
+ 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information.
108
+
109
+ 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable.
110
+
111
+ b. ___ShareAlike.___
112
+
113
+ In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.
114
+
115
+ 1. The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-NC-SA Compatible License.
116
+
117
+ 2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
118
+
119
+ 3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.
120
+
121
+ ### Section 4 – Sui Generis Database Rights.
122
+
123
+ Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material:
124
+
125
+ a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only;
126
+
127
+ b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material, including for purposes of Section 3(b); and
128
+
129
+ c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database.
130
+
131
+ For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights.
132
+
133
+ ### Section 5 – Disclaimer of Warranties and Limitation of Liability.
134
+
135
+ a. __Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.__
136
+
137
+ b. __To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.__
138
+
139
+ c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability.
140
+
141
+ ### Section 6 – Term and Termination.
142
+
143
+ a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically.
144
+
145
+ b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates:
146
+
147
+ 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
148
+
149
+ 2. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or
150
+
151
+ For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License.
152
+
153
+ c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License.
154
+
155
+ d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License.
156
+
157
+ ### Section 7 – Other Terms and Conditions.
158
+
159
+ a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed.
160
+
161
+ b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License.
162
+
163
+ ### Section 8 – Interpretation.
164
+
165
+ a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License.
166
+
167
+ b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
168
+
169
+ c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
170
+
171
+ d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
172
+
173
+ ```
174
+ Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at [creativecommons.org/policies](http://creativecommons.org/policies), Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses.
175
+
176
+ Creative Commons may be contacted at [creativecommons.org](http://creativecommons.org/).
177
+ ```
README.md CHANGED
@@ -1,3 +1,179 @@
1
  ---
2
- license: apache-2.0
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ library_name: pytorch
3
+ pipeline_tag: image-to-image
4
+ license: cc-by-nc-sa-4.0
5
+ language:
6
+ - en
7
+ tags:
8
+ - image-inpainting
9
+ - medfe
10
+ - partial-convolution
11
+ - computer-vision
12
  ---
13
+
14
+ <div align="center">
15
+
16
+ # MEDFE
17
+ ### Mutual Encoder–Decoder with Feature Equalizations
18
+
19
+ **ECCV 2020 · Modern PyTorch implementation**
20
+
21
+ [Paper](https://www.ecva.net/papers/eccv_2020/papers_ECCV/papers/123470715.pdf) · [Weights](https://huggingface.co/KumaPower/MEDFE) · [Quick start](#quick-start) · [Training](#training) · [Datasets](https://github.com/KumapowerLIU/Rethinking-Inpainting-MEDFE/blob/master/docs/data.md) · [Architecture](#architecture)
22
+
23
+ Hongyu Liu · Bin Jiang · Yibing Song · Wei Huang · Chao Yang
24
+
25
+ </div>
26
+
27
+ ![Masked input, MEDFE completion, and ground truth](medfe-preview.png)
28
+
29
+ *MEDFE results. Each row shows masked input → completion → ground truth. [More examples and checkpoint details](https://github.com/KumapowerLIU/Rethinking-Inpainting-MEDFE/blob/master/docs/checkpoint.md).*
30
+
31
+ This repository is a new PyTorch implementation of **MEDFE**, which jointly recovers image structure and texture through a mutual encoder–decoder and feature equalization. It provides batched training, reproducible random masks, explicit configuration, resumable checkpoints, and offline inference.
32
+
33
+ The network combines a **PartialConv residual encoder** with a **GroupNorm/SiLU residual decoder**, using nearest-neighbor upsampling and ordinary convolutions. Structure and texture branches fill missing features through multi-scale partial convolutions, followed by channel equalization and bilateral propagation. A single forward pass produces the completed RGB image.
34
+
35
+ ## Quick start
36
+
37
+ Python **3.10+** is required. The training environment used PyTorch **2.6.0**, torchvision **0.21.0** and CUDA **12.4**. For Linux/NVIDIA:
38
+
39
+ ```bash
40
+ git clone https://github.com/KumapowerLIU/Rethinking-Inpainting-MEDFE.git
41
+ cd Rethinking-Inpainting-MEDFE
42
+ python3 -m venv .venv
43
+ source .venv/bin/activate
44
+ python -m pip install torch==2.6.0 torchvision==0.21.0 \
45
+ --index-url https://download.pytorch.org/whl/cu124
46
+ python -m pip install -e .
47
+ medfe --help
48
+ ```
49
+
50
+ For macOS or CPU, install the matching [PyTorch wheels](https://pytorch.org/get-started/previous-versions/#v260) before installing this package.
51
+
52
+ Download the **step 120,994** generator from [Hugging Face](https://huggingface.co/KumaPower/MEDFE), then run:
53
+
54
+ ```bash
55
+ mkdir -p checkpoints
56
+ curl -L --fail \
57
+ https://huggingface.co/KumaPower/MEDFE/resolve/main/medfe-sd-partial-step120994.pt \
58
+ -o checkpoints/medfe-sd-partial.pt
59
+
60
+ medfe infer --checkpoint checkpoints/medfe-sd-partial.pt \
61
+ --image examples/masked.png --mask examples/mask.png \
62
+ --output outputs/completed.png --device cuda:0
63
+ ```
64
+
65
+ **White mask pixels are holes; black pixels are known.** Image and mask must have matching dimensions. Inference preserves the original size through padding/cropping, copies known pixels exactly, and writes a lossless PNG. `--device cpu` is supported. The download is a **579.6 MB FP32 inference bundle**; [checkpoint details](https://github.com/KumapowerLIU/Rethinking-Inpainting-MEDFE/blob/master/docs/checkpoint.md) include its checksum and export instructions.
66
+
67
+ ## Architecture
68
+
69
+ ![MEDFE architecture: PartialConv encoder, structure and texture filling, feature equalization, refined skips, and residual decoder](medfe-architecture.png)
70
+
71
+ *Architecture overview, with a layout inspired by [Figure 2 of the paper](https://www.ecva.net/papers/eccv_2020/papers_ECCV/papers/123470715.pdf#page=5). Scale labels are spatial side lengths for a 256 × 256 input. The image tiles are schematic; model results are shown above.*
72
+
73
+ The generator is trained jointly. Equalized features are projected to each encoder scale and added to the encoder features; the resulting feature pyramid supplies the decoder input and skip connections. See the [architecture notes](https://github.com/KumapowerLIU/Rethinking-Inpainting-MEDFE/blob/master/docs/sd-partial-backbone.md) for feature scales, mask propagation and normalization.
74
+
75
+ ## Training
76
+
77
+ The current recipe is [`configs/sd-partial-csa-mix-large-batch.yaml`](https://github.com/KumapowerLIU/Rethinking-Inpainting-MEDFE/blob/master/configs/sd-partial-csa-mix-large-batch.yaml).
78
+
79
+ | Setting | Current experiment |
80
+ | --- | --- |
81
+ | GPU | **1 × NVIDIA H100 80 GB HBM3** |
82
+ | Image size / batch | **256 × 256 / 128**, one GPU |
83
+ | Precision | BF16 training; FP32 perceptual computation and validation |
84
+ | Memory | About **33 GiB** process usage observed; **38 GiB** allocator budget |
85
+ | Measured short-test peak | 25.925 GiB allocated / 30.551 GiB reserved; synthetic full D/G test |
86
+ | Optimizer | Adam, lr `0.0002`, betas `(0.5, 0.999)` |
87
+ | Masks | Rectangles, brush strokes, or mixtures; 10%–40% missing area |
88
+ | Stop point | **120,994 steps**, paused with a complete training checkpoint |
89
+
90
+ The 80 GB card capacity is not the measured requirement. Memory varies with inputs, backends and image size; reduce batch size for smaller GPUs. [Training details](https://github.com/KumapowerLIU/Rethinking-Inpainting-MEDFE/blob/master/docs/training.md) include the loss definitions, warmup, resume rules and hardware measurements.
91
+
92
+ ### 1. Prepare your images
93
+
94
+ Use separate training and validation folders. The indexer reads existing files; it does not download or extract a dataset.
95
+
96
+ ```bash
97
+ python scripts/build_image_index.py --images-root /path/to/train \
98
+ --manifest data/train.jsonl
99
+ python scripts/build_image_index.py --images-root /path/to/validation \
100
+ --manifest data/validation.jsonl
101
+ ```
102
+
103
+ The indexed reader resizes RGB to 256², computes a true RTV structure target, and caches it on first use. See [data preparation](https://github.com/KumapowerLIU/Rethinking-Inpainting-MEDFE/blob/master/docs/data.md) for storage requirements, archive formats, face sampling and the alternative paired-data protocol.
104
+
105
+ ### 2. Prepare LPIPS weights
106
+
107
+ ```bash
108
+ export TORCH_HOME="$PWD/weights/torch"
109
+ medfe prepare-weights --lpips-only --output weights
110
+ ```
111
+
112
+ This explicitly fetches missing VGG-LPIPS assets. The current discriminators are randomly initialized PatchGANs and need no pretrained D. Training itself defaults to **no implicit downloads**.
113
+
114
+ ### 3. Train and resume
115
+
116
+ ```bash
117
+ medfe train --config configs/sd-partial-csa-mix-large-batch.yaml \
118
+ --set train.device=cuda:0 --max-steps 20
119
+
120
+ medfe train --config configs/sd-partial-csa-mix-large-batch.yaml \
121
+ --set train.device=cuda:0 \
122
+ --resume runs/medfe-sd-partial-csa-mix-large-batch/latest.pt
123
+ ```
124
+
125
+ The first command is a short startup check; `--max-steps` is an **absolute** step limit. The second continues the same run. Checkpoints contain both discriminators, optimizer states, perceptual weights, RNG state and the data cursor. SIGINT/SIGTERM finish the current update and save a complete checkpoint. Source/config/data checks protect resume compatibility; archived runs use their frozen source for exact continuation.
126
+
127
+ | Generator loss | Weight |
128
+ | --- | ---: |
129
+ | Full-image raw-prediction L1 | 1 |
130
+ | Structure auxiliary L1 | 1 |
131
+ | Texture auxiliary L1 | 1 |
132
+ | VGG-LPIPS on the completed image | 1 |
133
+ | Global + local RaLSGAN | Ramps to **0.002** |
134
+
135
+ GAN is disabled for the first 5,000 updates, then ramps linearly over 10,000 updates. Separate VGG perceptual/style losses are disabled in this recipe.
136
+
137
+ ## Data used for this checkpoint
138
+
139
+ The run uses the same source mix and split as the modern CSA experiment:
140
+
141
+ | Source | Training entries | Obtain the source data |
142
+ | --- | ---: | --- |
143
+ | Unsplash-derived photographs | 296,145 | [Unsplash Dataset](https://unsplash.com/data) · [access/schema](https://github.com/unsplash/datasets) |
144
+ | Places365-Standard | 901,730, half of the training archive | [CSAIL dataset repository](https://github.com/CSAILVision/places365) |
145
+ | HDTF talking-head frames | 299,469 entries from 30,128 unique frames | [HDTF dataset and preprocessing](https://github.com/MRzzm/HDTF) |
146
+
147
+ **1,497,344 sampling entries; 1,228,003 distinct source records.** Face frames repeat 9 or 10 times for approximately 20% sampling weight. Validation uses 2,000 held-out Unsplash records. The training masks are generated online. The local selection/manifests are not a public benchmark split; source access and reproducibility details are in [datasets](https://github.com/KumapowerLIU/Rethinking-Inpainting-MEDFE/blob/master/docs/data.md).
148
+
149
+ ## Repository guide
150
+
151
+ | Location | Purpose |
152
+ | --- | --- |
153
+ | `src/medfe/model.py`, `blocks.py`, `sd_backbone.py` | Generator, feature equalization, PartialConv and decoder |
154
+ | `src/medfe/trainer.py`, `losses.py`, `discriminators.py` | Joint training, loss definitions and PatchGANs |
155
+ | `src/medfe/indexed_data.py`, `rtv.py`, `masks.py` | Data decoding, cached structure targets and random masks |
156
+ | `src/medfe/evaluation.py`, `inference.py` | Image-preserving inference, evaluation and portable export |
157
+ | `configs/` | Training configurations |
158
+ | `legacy/` | Archived source files |
159
+
160
+ ```bash
161
+ python -m pip install -e '.[dev]'
162
+ ruff check src tests scripts
163
+ python -m pytest tests -q
164
+ ```
165
+
166
+ Large holes can still lead to repeated textures, implausible faces and missing body parts. See the [validation records](https://github.com/KumapowerLIU/Rethinking-Inpainting-MEDFE/blob/master/docs/validation.md) for implementation checks and image-quality observations.
167
+
168
+ ## Citation and license
169
+
170
+ ```bibtex
171
+ @inproceedings{liu2020rethinking,
172
+ title={Rethinking Image Inpainting via a Mutual Encoder-Decoder with Feature Equalizations},
173
+ author={Liu, Hongyu and Jiang, Bin and Song, Yibing and Huang, Wei and Yang, Chao},
174
+ booktitle={European Conference on Computer Vision},
175
+ year={2020}
176
+ }
177
+ ```
178
+
179
+ [CC BY-NC-SA 4.0](https://github.com/KumapowerLIU/Rethinking-Inpainting-MEDFE/blob/master/LICENSE.md). Dataset and pretrained-weight terms remain those of their respective providers.
SHA256SUMS ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ ca98198ef4cd9fad732d5709a0f3a5f9f9646743528dacde744bfb95ddb71e50 medfe-sd-partial-step120994.pt
2
+ 051131b5ef3596dad9bf0cffee19c248ff9751596a86b25c70f0cd82d6f6d713 LICENSE.md
3
+ 2114b670b9e00984a7a600987f855a7c13e4ff2d08e0fb54b78aba10ee66b53b README.md
4
+ ce3c4669f6e8f9950d830cf787b398db1b693efa3e3c6141277ff7adf71e067d expected.png
5
+ abbdb5d2f6e7e05833da9be8b914bd739f4f829b66b125e10edaec6382230de5 mask.png
6
+ 1684cf2363563e39db8bf63e94ee46524aa77595244a019e242d636b495997ee masked.png
7
+ 57b24f85f16e861201a00355bf17e2f7c89ae32c808a32bb1f073aa0bfb82f9d medfe-architecture.png
8
+ 1487661ecb423e891441eba88e05b78315b5a8aa4b2b0f816dee67d6cdaa7e0c medfe-preview.png
9
+ 269f94964262d6f2f3df50a92e16d95ff2f1e99b7cf24f51a152bc18486c5e48 release.json
10
+ 29dfc517150714442b1549c7990e079d3e1efbb59a0c026d9f60c5af66cc15ea training-config.yaml
expected.png ADDED
mask.png ADDED
masked.png ADDED
medfe-architecture.png ADDED

Git LFS Details

  • SHA256: 57b24f85f16e861201a00355bf17e2f7c89ae32c808a32bb1f073aa0bfb82f9d
  • Pointer size: 132 Bytes
  • Size of remote file: 1.67 MB
medfe-preview.png ADDED

Git LFS Details

  • SHA256: 1487661ecb423e891441eba88e05b78315b5a8aa4b2b0f816dee67d6cdaa7e0c
  • Pointer size: 131 Bytes
  • Size of remote file: 284 kB
release.json ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "model": "MEDFE sd_partial",
3
+ "step": 120994,
4
+ "status": "paused",
5
+ "date": "2026-11-01",
6
+ "inference": {
7
+ "step": 120994,
8
+ "bytes": 579558450,
9
+ "sha256": "ca98198ef4cd9fad732d5709a0f3a5f9f9646743528dacde744bfb95ddb71e50",
10
+ "generator_sha256": "e1f0c8e34374523d1b1f1e5ef715b5e7722189dec2d4f12bf39d2128c2f2ebc8",
11
+ "source_checkpoint_sha256": "bd2b516ba3d7dd19e444feec35279a483e33835b5148d82b1f9c21fd7d7dc975"
12
+ },
13
+ "training_checkpoint": {
14
+ "filename": "medfe-training-step120994.pt",
15
+ "bytes": 1864094437,
16
+ "sha256": "bd2b516ba3d7dd19e444feec35279a483e33835b5148d82b1f9c21fd7d7dc975"
17
+ },
18
+ "training_hardware": {
19
+ "gpu": "NVIDIA H100 80GB HBM3",
20
+ "gpus": 1,
21
+ "batch": 128,
22
+ "image_size": 256,
23
+ "amp": "bf16",
24
+ "allocator_budget_gib": 38
25
+ },
26
+ "environment": {
27
+ "python": "3.10.14 (main, Mar 21 2024, 16:24:04) [GCC 11.2.0]",
28
+ "torch": "2.6.0+cu124",
29
+ "torchvision": "0.21.0+cu124"
30
+ },
31
+ "verification": {
32
+ "full_vs_export": {
33
+ "cases": 8,
34
+ "bitwise_equal": true,
35
+ "precision": "FP32"
36
+ },
37
+ "model_source_matches_training": {
38
+ "model.py": true,
39
+ "blocks.py": true,
40
+ "sd_backbone.py": true
41
+ },
42
+ "cli": {
43
+ "cli_example_max_byte_difference": 0
44
+ },
45
+ "cpu_tests": {
46
+ "passed": 350,
47
+ "skipped_cuda": 5
48
+ }
49
+ },
50
+ "training_data": {
51
+ "entries": 1497344,
52
+ "distinct_source_records": 1228003,
53
+ "unsplash_entries": 296145,
54
+ "places365_entries": 901730,
55
+ "face_entries": 299469,
56
+ "unique_face_frames": 30128,
57
+ "validation_entries": 2000
58
+ },
59
+ "evaluation": {
60
+ "images": 32,
61
+ "hole_psnr": 18.356236154308785,
62
+ "hole_l1": 0.0759446257571164
63
+ },
64
+ "public_download_url": "https://huggingface.co/KumaPower/MEDFE/resolve/main/medfe-sd-partial-step120994.pt",
65
+ "note": "Final safely saved checkpoint, not validation-best. Fixed32 local validation is not a paper benchmark."
66
+ }
training-config.yaml ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use byte-identical CSA train/validation manifests; retain intentional face repeats.
2
+ model:
3
+ backbone: sd_partial
4
+ blocks_per_scale: 2
5
+ base_channels: 64
6
+ residual_blocks: 4
7
+ pconv_layers: 5
8
+ gaussian_sigma: 1.5
9
+ init_gain: 0.02
10
+ activation_checkpointing: true
11
+ data:
12
+ format: indexed_rtv
13
+ rtv_cache: data/indexed-rtv-cache
14
+ train_manifest: data/train.jsonl
15
+ val_manifest: data/validation.jsonl
16
+ image_size: 256
17
+ batch_size: 128
18
+ workers: 8
19
+ mask_mode: random
20
+ min_fraction: 0.1
21
+ max_fraction: 0.4
22
+ allow_repeated_records: true
23
+ loss:
24
+ reconstruction: 1.0
25
+ structure: 1.0
26
+ texture: 1.0
27
+ lpips: 1.0
28
+ perceptual: 0.0
29
+ style: 0.0
30
+ adversarial: 0.002
31
+ lpips_net: vgg
32
+ lpips_chunk_size: 8
33
+ discriminator:
34
+ global_kind: patch
35
+ global_width: 64
36
+ local_width: 64
37
+ local_crop_size: 64
38
+ chunk_size: 8
39
+ pretrained_path: ''
40
+ train:
41
+ output: runs/medfe-sd-partial-csa-mix-large-batch
42
+ amp: bf16
43
+ seed: 2019
44
+ epochs: 60
45
+ schedule: constant
46
+ lr: 0.0002
47
+ beta1: 0.5
48
+ beta2: 0.999
49
+ adversarial_warmup_steps: 5000
50
+ adversarial_ramp_steps: 10000
51
+ save_every: 100
52
+ evaluate_every: 100
53
+ log_every: 10
54
+ evaluation_images: 32
55
+ evaluation_batch_size: 4
56
+ memory_budget_gib: 38
57
+ allow_weight_download: false