Upload folder using huggingface_hub
Browse files- .gitattributes +3 -0
- README.md +59 -0
- image.jpg +0 -0
- lama.onnx +3 -0
- lama_fp32.onnx +3 -0
- mask.png +0 -0
- output_onnx.png +3 -0
- output_onnx_fp32.png +3 -0
- output_orig.png +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,6 @@ 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 |
+
output_onnx.png filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
output_onnx_fp32.png filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
output_orig.png filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
pipeline_tag: image-to-image
|
| 6 |
+
tags:
|
| 7 |
+
- art
|
| 8 |
+
- lama
|
| 9 |
+
- inpainting
|
| 10 |
+
---
|
| 11 |
+
# LaMa Inpainting Model
|
| 12 |
+
|
| 13 |
+
This ONNX model is a port of the original PyTorch big-lama model.
|
| 14 |
+
|
| 15 |
+
> HG Space: https://huggingface.co/spaces/Carve/LaMa-Demo-ONNX
|
| 16 |
+
## Description
|
| 17 |
+
|
| 18 |
+
There are two versions of the model:
|
| 19 |
+
|
| 20 |
+
### 1. `lama_fp32.onnx` (RECOMMENDED)
|
| 21 |
+
|
| 22 |
+
This version was exported using the old torch to ONNX converter (`torch.onnx.export`).
|
| 23 |
+
|
| 24 |
+
**Notes:**
|
| 25 |
+
1. **Custom FourierUnitJIT**: A custom [FourierUnitJIT](https://github.com/Carve-Photos/lama/blob/main/saicinpainting/training/modules/ffc.py) implementation is used since the original cannot be directly ported to ONNX without overhead. The result is identical to the original model.
|
| 26 |
+
2. **Fixed Input Shape**: The input shape is fixed at 512x512 pixels. Although dynamic input shapes are possible, they would require resolving issues with dynamic padding in the `irfft` and `rfftn` functions in `ffc.py`.
|
| 27 |
+
3. **Opset Version 17**: This model uses opset version 17.
|
| 28 |
+
4. **Exportable to TensorRT**: The model can be successfully used in TensorRT, etc.
|
| 29 |
+
> if you need other resolution - export it using our [jupyter notebook](https://colab.research.google.com/github/Carve-Photos/lama/blob/main/export_LaMa_to_onnx.ipynb)
|
| 30 |
+
|
| 31 |
+
### 2. `lama.onnx` (NOT RECOMMENDED)
|
| 32 |
+
|
| 33 |
+
This version was exported using the new torch to ONNX converter (`torch.onnx.dynamo_export`).
|
| 34 |
+
|
| 35 |
+
**Notes:**
|
| 36 |
+
1. **Custom DFT irfftn Logic**: Uses a custom irfftn ONNX logic (patched `onnxscript`).
|
| 37 |
+
2. **Fixed Input Shape**: The input shape is fixed at 512x512 pixels.
|
| 38 |
+
3. **Opset Version 18**: This model uses opset version 18.
|
| 39 |
+
4. **Performance**: The model works slowly due to issues with `torch.onnx.dynamo_export` and optimization of the ONNX model.
|
| 40 |
+
|
| 41 |
+
## Resources
|
| 42 |
+
|
| 43 |
+
- Original repository: [advimman/lama](https://github.com/advimman/lama)
|
| 44 |
+
- Repository with custom implementation of exportable LaMa: [Carve-Photos/lama](https://github.com/Carve-Photos/lama)
|
| 45 |
+
|
| 46 |
+
## Example
|
| 47 |
+
|
| 48 |
+
**Original image:**
|
| 49 |
+

|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
**lama_fp32.onnx - output:**
|
| 53 |
+

|
| 54 |
+
|
| 55 |
+
**lama.onnx - output:**
|
| 56 |
+

|
| 57 |
+
|
| 58 |
+
**Original model output:**
|
| 59 |
+

|
image.jpg
ADDED
|
lama.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:351e481e287f345b7fbfd026068cfb9ec0c7f24b440e6501458ebe54a833d1a1
|
| 3 |
+
size 207479252
|
lama_fp32.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1faef5301d78db7dda502fe59966957ec4b79dd64e16f03ed96913c7a4eb68d6
|
| 3 |
+
size 208044816
|
mask.png
ADDED
|
output_onnx.png
ADDED
|
Git LFS Details
|
output_onnx_fp32.png
ADDED
|
Git LFS Details
|
output_orig.png
ADDED
|
Git LFS Details
|