schirrmacher commited on
Commit
87f3694
1 Parent(s): d53ce08

Upload ./README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +94 -9
README.md CHANGED
@@ -1,13 +1,98 @@
1
  ---
2
- title: Open Remove Background Model (ormbg)
3
- emoji: 💻
4
- colorFrom: red
5
- colorTo: red
6
- sdk: gradio
7
- sdk_version: 4.29.0
8
- app_file: app.py
9
- pinned: false
10
  license: apache-2.0
 
 
 
 
 
 
 
 
 
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
 
 
 
 
 
 
 
 
2
  license: apache-2.0
3
+ tags:
4
+ - segmentation
5
+ - remove background
6
+ - background
7
+ - background-removal
8
+ - Pytorch
9
+ pretty_name: Open Remove Background Model
10
+ datasets:
11
+ - schirrmacher/humans
12
  ---
13
 
14
+ # Open Remove Background Model (ormbg)
15
+
16
+ [>>> DEMO <<<](https://huggingface.co/spaces/schirrmacher/ormbg)
17
+
18
+ ![](examples.jpg)
19
+
20
+ This model is a **fully open-source background remover** optimized for images with humans. It is based on [Highly Accurate Dichotomous Image Segmentation research](https://github.com/xuebinqin/DIS).
21
+
22
+ This model is similar to [RMBG-1.4](https://huggingface.co/briaai/RMBG-1.4), but with open training data/process and commercially free to use.
23
+
24
+ ## Inference
25
+
26
+ ```
27
+ python utils/inference.py
28
+ ```
29
+
30
+ ## Training
31
+
32
+ The model was trained with the [Human Segmentation Dataset](https://huggingface.co/datasets/schirrmacher/humans).
33
+
34
+ After 10.000 iterations with a single NVIDIA GeForce RTX 4090 the following achievements were made:
35
+
36
+ - Training Time: 8 hours
37
+ - Training Loss: 0.1179
38
+ - Validation Loss: 0.1284
39
+ - Maximum F1 Score: 0.9928
40
+ - Mean Absolute Error: 0.005
41
+
42
+ Output model: `/models/ormbg.pth`.
43
+
44
+ ## Want to train your own model?
45
+
46
+ Checkout _Highly Accurate Dichotomous Image Segmentation_ code:
47
+
48
+ ```
49
+ git clone https://github.com/xuebinqin/DIS.git
50
+ cd DIS
51
+ ```
52
+
53
+ Follow the installation instructions on https://github.com/xuebinqin/DIS?tab=readme-ov-file#1-clone-this-repo.
54
+ Download or create some data ([like this](https://huggingface.co/datasets/schirrmacher/humans)) and place it into the DIS project folder.
55
+
56
+ I am using the folder structure:
57
+
58
+ - training/im (images)
59
+ - training/gt (ground truth)
60
+ - validation/im (images)
61
+ - validation/gt (ground truth)
62
+
63
+ Apply this git patch for setting the right paths and remove normalization of images:
64
+
65
+ ```
66
+ git apply dis-repo.patch
67
+ ```
68
+
69
+ Start training:
70
+
71
+ ```
72
+ cd IS-Net
73
+ python train_valid_inference_main.py
74
+ ```
75
+
76
+ Export to ONNX (modify paths if needed):
77
+
78
+ ```
79
+ python utils/pth_to_onnx.py
80
+ ```
81
+
82
+ # Research
83
+
84
+ Synthetic datasets have limitations for achieving great segmentation results. This is because artificial lighting, occlusion, scale or backgrounds create a gap between synthetic and real images. A "model trained solely on synthetic data generated with naïve domain randomization struggles to generalize on the real domain", see [PEOPLESANSPEOPLE: A Synthetic Data Generator for Human-Centric Computer Vision (2022)](https://arxiv.org/pdf/2112.09290). However, hybrid training approaches seem to be promising and can even improve segmentation results.
85
+
86
+ Currently I am doing research how to close this gap with the resources I have. There are approaches like considering the pose of humans for improving segmentation results, see [Cross-Domain Complementary Learning Using Pose for Multi-Person Part Segmentation (2019)](https://arxiv.org/pdf/1907.05193).
87
+
88
+ ## Support
89
+
90
+ This is the first iteration of the model, so there will be improvements!
91
+
92
+ If you identify cases were the model fails, <a href='https://huggingface.co/schirrmacher/ormbg/discussions' target='_blank'>upload your examples</a>!
93
+
94
+ Known issues (work in progress):
95
+
96
+ - close-ups: from above, from below, profile, from side
97
+ - minor issues with hair segmentation when hair creates loops
98
+ - more various backgrounds needed