p1atdev commited on
Commit
fdc356b
1 Parent(s): 1dcf326
.gitignore ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Created by https://www.toptal.com/developers/gitignore/api/macos,windows,linux,python
2
+ # Edit at https://www.toptal.com/developers/gitignore?templates=macos,windows,linux,python
3
+
4
+ ### Linux ###
5
+ *~
6
+
7
+ # temporary files which can be created if a process still has a handle open of a deleted file
8
+ .fuse_hidden*
9
+
10
+ # KDE directory preferences
11
+ .directory
12
+
13
+ # Linux trash folder which might appear on any partition or disk
14
+ .Trash-*
15
+
16
+ # .nfs files are created when an open file is removed but is still being accessed
17
+ .nfs*
18
+
19
+ ### macOS ###
20
+ # General
21
+ .DS_Store
22
+ .AppleDouble
23
+ .LSOverride
24
+
25
+ # Icon must end with two \r
26
+ Icon
27
+
28
+ # Thumbnails
29
+ ._*
30
+
31
+ # Files that might appear in the root of a volume
32
+ .DocumentRevisions-V100
33
+ .fseventsd
34
+ .Spotlight-V100
35
+ .TemporaryItems
36
+ .Trashes
37
+ .VolumeIcon.icns
38
+ .com.apple.timemachine.donotpresent
39
+
40
+ # Directories potentially created on remote AFP share
41
+ .AppleDB
42
+ .AppleDesktop
43
+ Network Trash Folder
44
+ Temporary Items
45
+ .apdisk
46
+
47
+ ### macOS Patch ###
48
+ # iCloud generated files
49
+ *.icloud
50
+
51
+ ### Python ###
52
+ # Byte-compiled / optimized / DLL files
53
+ __pycache__/
54
+ *.py[cod]
55
+ *$py.class
56
+
57
+ # C extensions
58
+ *.so
59
+
60
+ # Distribution / packaging
61
+ .Python
62
+ build/
63
+ develop-eggs/
64
+ dist/
65
+ downloads/
66
+ eggs/
67
+ .eggs/
68
+ lib/
69
+ lib64/
70
+ parts/
71
+ sdist/
72
+ var/
73
+ wheels/
74
+ share/python-wheels/
75
+ *.egg-info/
76
+ .installed.cfg
77
+ *.egg
78
+ MANIFEST
79
+
80
+ # PyInstaller
81
+ # Usually these files are written by a python script from a template
82
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
83
+ *.manifest
84
+ *.spec
85
+
86
+ # Installer logs
87
+ pip-log.txt
88
+ pip-delete-this-directory.txt
89
+
90
+ # Unit test / coverage reports
91
+ htmlcov/
92
+ .tox/
93
+ .nox/
94
+ .coverage
95
+ .coverage.*
96
+ .cache
97
+ nosetests.xml
98
+ coverage.xml
99
+ *.cover
100
+ *.py,cover
101
+ .hypothesis/
102
+ .pytest_cache/
103
+ cover/
104
+
105
+ # Translations
106
+ *.mo
107
+ *.pot
108
+
109
+ # Django stuff:
110
+ *.log
111
+ local_settings.py
112
+ db.sqlite3
113
+ db.sqlite3-journal
114
+
115
+ # Flask stuff:
116
+ instance/
117
+ .webassets-cache
118
+
119
+ # Scrapy stuff:
120
+ .scrapy
121
+
122
+ # Sphinx documentation
123
+ docs/_build/
124
+
125
+ # PyBuilder
126
+ .pybuilder/
127
+ target/
128
+
129
+ # Jupyter Notebook
130
+ .ipynb_checkpoints
131
+
132
+ # IPython
133
+ profile_default/
134
+ ipython_config.py
135
+
136
+ # pyenv
137
+ # For a library or package, you might want to ignore these files since the code is
138
+ # intended to run in multiple environments; otherwise, check them in:
139
+ # .python-version
140
+
141
+ # pipenv
142
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
143
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
144
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
145
+ # install all needed dependencies.
146
+ #Pipfile.lock
147
+
148
+ # poetry
149
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
150
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
151
+ # commonly ignored for libraries.
152
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
153
+ #poetry.lock
154
+
155
+ # pdm
156
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
157
+ #pdm.lock
158
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
159
+ # in version control.
160
+ # https://pdm.fming.dev/#use-with-ide
161
+ .pdm.toml
162
+
163
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
164
+ __pypackages__/
165
+
166
+ # Celery stuff
167
+ celerybeat-schedule
168
+ celerybeat.pid
169
+
170
+ # SageMath parsed files
171
+ *.sage.py
172
+
173
+ # Environments
174
+ .env
175
+ .venv
176
+ env/
177
+ venv/
178
+ ENV/
179
+ env.bak/
180
+ venv.bak/
181
+
182
+ # Spyder project settings
183
+ .spyderproject
184
+ .spyproject
185
+
186
+ # Rope project settings
187
+ .ropeproject
188
+
189
+ # mkdocs documentation
190
+ /site
191
+
192
+ # mypy
193
+ .mypy_cache/
194
+ .dmypy.json
195
+ dmypy.json
196
+
197
+ # Pyre type checker
198
+ .pyre/
199
+
200
+ # pytype static type analyzer
201
+ .pytype/
202
+
203
+ # Cython debug symbols
204
+ cython_debug/
205
+
206
+ # PyCharm
207
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
208
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
209
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
210
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
211
+ #.idea/
212
+
213
+ ### Python Patch ###
214
+ # Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
215
+ poetry.toml
216
+
217
+ # ruff
218
+ .ruff_cache/
219
+
220
+ # LSP config files
221
+ pyrightconfig.json
222
+
223
+ ### Windows ###
224
+ # Windows thumbnail cache files
225
+ Thumbs.db
226
+ Thumbs.db:encryptable
227
+ ehthumbs.db
228
+ ehthumbs_vista.db
229
+
230
+ # Dump file
231
+ *.stackdump
232
+
233
+ # Folder config file
234
+ [Dd]esktop.ini
235
+
236
+ # Recycle Bin used on file shares
237
+ $RECYCLE.BIN/
238
+
239
+ # Windows Installer files
240
+ *.cab
241
+ *.msi
242
+ *.msix
243
+ *.msm
244
+ *.msp
245
+
246
+ # Windows shortcuts
247
+ *.lnk
248
+
249
+ # End of https://www.toptal.com/developers/gitignore/api/macos,windows,linux,python
250
+
251
+ gradio_cached_examples
README.md CHANGED
@@ -1,12 +1,12 @@
1
  ---
2
  title: AdverseCleaner
3
- emoji: 🐢
4
  colorFrom: pink
5
  colorTo: yellow
6
  sdk: gradio
7
- sdk_version: 3.21.0
8
- app_file: app.py
9
- pinned: false
10
  license: apache-2.0
11
  ---
12
 
 
1
  ---
2
  title: AdverseCleaner
3
+ emoji: 🧹
4
  colorFrom: pink
5
  colorTo: yellow
6
  sdk: gradio
7
+ sdk_version: 3.20.1
8
+ app_file: main.py
9
+ pinned: true
10
  license: apache-2.0
11
  ---
12
 
examples/sample1.jpg ADDED
examples/sample2.jpg ADDED
examples/sample3.jpg ADDED
main.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import cv2
3
+ from PIL import Image
4
+ from cv2.ximgproc import guidedFilter
5
+ import gradio as gr
6
+
7
+
8
+ def clean_image(input_image: Image) -> Image:
9
+ img = np.array(input_image).astype(np.float32)
10
+ y = img.copy()
11
+
12
+ for _ in range(64):
13
+ y = cv2.bilateralFilter(y, 5, 8, 8)
14
+
15
+ for _ in range(4):
16
+ y = guidedFilter(img, y, 4, 16)
17
+
18
+ output_image = Image.fromarray(y.clip(0, 255).astype(np.uint8))
19
+ return output_image
20
+
21
+
22
+ def example(_image):
23
+ pass
24
+
25
+
26
+ def ui():
27
+ with gr.Blocks() as app:
28
+ with gr.Row():
29
+ with gr.Column():
30
+ input_image = gr.Image(type="pil", label="Input Image")
31
+ start_btn = gr.Button(value="Start", variant="primary")
32
+
33
+ gr.Examples(
34
+ examples=[
35
+ ["./examples/sample1.jpg"],
36
+ ["./examples/sample2.jpg"],
37
+ ["./examples/sample3.jpg"],
38
+ ],
39
+ inputs=[input_image],
40
+ outputs=[],
41
+ fn=example,
42
+ cache_examples=True,
43
+ )
44
+
45
+ with gr.Column():
46
+ output_image = gr.Image(type="pil", label="Output Image")
47
+
48
+ start_btn.click(fn=clean_image, inputs=[input_image], outputs=[output_image])
49
+
50
+ app.launch()
51
+
52
+
53
+ if __name__ == "__main__":
54
+ ui()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio==3.20.1
2
+ numpy
3
+ opencv-python
4
+ opencv-contrib-python