Boka73 commited on
Commit
5b6035c
·
verified ·
1 Parent(s): da50507

upload README.md

Browse files
Files changed (1) hide show
  1. README.md +231 -100
README.md CHANGED
@@ -1,100 +1,231 @@
1
- import gradio as gr
2
- import roop.globals
3
- import ui.globals
4
-
5
-
6
- camera_frame = None
7
-
8
-
9
- def livecam_tab():
10
- with gr.Tab("🎥 Live Cam"):
11
- with gr.Row(variant="panel"):
12
- gr.Markdown("""
13
- This feature will allow you to use your physical webcam and apply the selected faces to the stream.
14
- You can also forward the stream to a virtual camera, which can be used in video calls or streaming software.<br />
15
- Supported are: v4l2loopback (linux), OBS Virtual Camera (macOS/Windows) and unitycapture (Windows).<br />
16
- **Please note:** to change the face or any other settings you need to stop and restart a running live cam.
17
- """)
18
-
19
- with gr.Row(variant="panel"):
20
- with gr.Column():
21
- bt_start = gr.Button("▶ Start", variant="primary")
22
- with gr.Column():
23
- bt_stop = gr.Button("⏹ Stop", variant="secondary", interactive=False)
24
- with gr.Column():
25
- camera_num = gr.Slider(
26
- 0, 8, value=0, label="Camera Number", step=1.0, interactive=True
27
- )
28
- cb_obs = gr.Checkbox(
29
- label="Forward stream to virtual camera", interactive=True
30
- )
31
- with gr.Column():
32
- dd_reso = gr.Dropdown(
33
- choices=["640x480", "1280x720", "1920x1080"],
34
- value="1280x720",
35
- label="Fake Camera Resolution",
36
- interactive=True,
37
- )
38
- cb_xseg = gr.Checkbox(
39
- label="Use DFL Xseg masking", interactive=True, value=True
40
- )
41
- cb_mouthrestore = gr.Checkbox(
42
- label="Restore original mouth area", interactive=True, value=False
43
- )
44
-
45
- with gr.Row():
46
- fake_cam_image = gr.Image(
47
- label="Fake Camera Output", interactive=False, format="jpeg"
48
- )
49
-
50
- start_event = bt_start.click(
51
- fn=start_cam,
52
- inputs=[
53
- ui.globals.ui_selected_swap_model,
54
- cb_obs,
55
- cb_xseg,
56
- cb_mouthrestore,
57
- camera_num,
58
- dd_reso,
59
- ui.globals.ui_selected_enhancer,
60
- ui.globals.ui_blend_ratio,
61
- ui.globals.ui_upscale,
62
- ],
63
- outputs=[bt_start, bt_stop, fake_cam_image],
64
- )
65
- bt_stop.click(
66
- fn=stop_swap, cancels=[start_event], outputs=[bt_start, bt_stop], queue=False
67
- )
68
-
69
-
70
- def start_cam(
71
- swap_model,
72
- stream_to_obs,
73
- use_xseg,
74
- use_mouthrestore,
75
- cam,
76
- reso,
77
- enhancer,
78
- blend_ratio,
79
- upscale,
80
- ):
81
- from roop.virtualcam import start_virtual_cam
82
- from roop.utilities import convert_to_gradio
83
-
84
- roop.globals.selected_enhancer = enhancer
85
- roop.globals.blend_ratio = blend_ratio
86
- roop.globals.subsample_size = int(upscale[:3])
87
- start_virtual_cam(swap_model, stream_to_obs, use_xseg, use_mouthrestore, cam, reso)
88
- while True:
89
- yield (
90
- gr.Button(interactive=False),
91
- gr.Button(interactive=True),
92
- convert_to_gradio(ui.globals.ui_camera_frame),
93
- )
94
-
95
-
96
- def stop_swap():
97
- from roop.virtualcam import stop_virtual_cam
98
-
99
- stop_virtual_cam()
100
- return gr.Button(interactive=True), gr.Button(interactive=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # roop-unleashed
2
+
3
+ This is **unofficial** mirror of repository
4
+
5
+ Models: <https://codeberg.org/roop-unleashed/models>
6
+
7
+ [Changelog](#changelog) • [Usage](#usage)
8
+
9
+ Uncensored Deepfakes for images and videos without training and an easy-to-use GUI.
10
+
11
+ ### Features
12
+
13
+ - Platform-independant Browser GUI
14
+ - Selection of multiple input/output faces in one go
15
+ - Many different swapping modes, first detected, face selections, by gender
16
+ - Batch processing of images/videos
17
+ - Masking of face occluders using text prompts or automatically
18
+ - Optional Face Upscaler/Restoration using different enhancers
19
+ - Preview swapping from different video frames
20
+ - Live Fake Cam using your webcam
21
+ - Extras Tab for cutting videos etc.
22
+ - Settings - storing configuration for next session
23
+ - Theme Support
24
+
25
+ and lots more...
26
+
27
+ ## Disclaimer
28
+
29
+ This project is for technical and academic use only.
30
+ Users of this software are expected to use this software responsibly while abiding the local law. If a face of a real person is being used, users are suggested to get consent from the concerned person and clearly mention that it is a deepfake when posting content online. Developers of this software will not be responsible for actions of end-users.
31
+ **Please do not apply it to illegal and unethical scenarios.**
32
+
33
+ In the event of violation of the legal and ethical requirements of the user's country or region, this code repository is exempt from liability
34
+
35
+ ### Installation
36
+
37
+ Please refer to the [wiki](https://github.com/C0untFloyd/roop-unleashed/wiki).
38
+
39
+ #### macOS Installation
40
+
41
+ Simply run the following command. It will check and install all dependencies if necessary.
42
+
43
+ `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/PJF16/roop-unleashed/master/installer/macOSinstaller.sh)"`
44
+
45
+ ### Usage
46
+
47
+ - Windows: run the `windows_run.bat` from the Installer.
48
+ - Linux: `python run.py`
49
+ - macOS: `sh runMacOS.sh`
50
+ - Dockerfile:
51
+
52
+ ```shell
53
+ docker build -t roop-unleashed . && docker run -t \
54
+ -p 7860:7860 \
55
+ -v ./config.yaml:/app/config.yaml \
56
+ -v ./models:/app/models \
57
+ -v ./temp:/app/temp \
58
+ -v ./output:/app/output \
59
+ roop-unleashed
60
+ ```
61
+
62
+ Additional commandline arguments are currently unsupported and settings should be done via the UI.
63
+
64
+ > Note: When you run this program for the first time, it will download some models roughly ~2Gb in size.
65
+
66
+ ### Changelog
67
+
68
+ **03.01.2025** v4.4.1
69
+
70
+ Bugfix: Extras Tab
71
+ Bugfix: Preview Mask
72
+ Bugfix: DMDNet working on Cuda only
73
+ Updated Colab Script to also install CUDNN
74
+
75
+ **31.12.2024** v4.4.0 Hotfix
76
+
77
+ Bugfix: Updated Colab to use present Cuda Drivers
78
+ Bugfix: Live-Cam not working because of new face swapper
79
+ Set default swapping model back to Insightface
80
+
81
+ Happy New Year!
82
+
83
+ **30.12.2024** v4.4.0
84
+
85
+ - Added random face selection mode
86
+ - Added alternative face swapping model with 128px & 256 px output ([ReSwapper](https://github.com/somanchiu/ReSwapper/tree/main))
87
+ - Video repair added to Extras Tab
88
+ - Updated most packages to newer versions. CUDA >= 12.4 now required!
89
+ - Several minor bugfixes and QoL Changes
90
+
91
+ **28.9.2024** v4.3.1
92
+
93
+ - Bugfix: Several possible memory leaks
94
+ - Added different output modes, e.g. to virtual cam stream
95
+ - New swapping mode "All input faces"
96
+ - Average total fps displayed and setting for autorun
97
+
98
+ **16.9.2024** v4.2.8
99
+
100
+ - Bugfix: Starting roop-unleashed without NVIDIA gpu but cuda option enabled
101
+ - Bugfix: Target Faces couldn't be moved left/right
102
+ - Bugfix: Enhancement and upscaling working again in virtual cam
103
+ - Corrupt videos caught when adding to target files, displaying warning msg
104
+ - Source Files Component cleared after face detection to release temp files
105
+ - Added masking and mouth restore options to virtual cam
106
+
107
+ **9.9.2024** v4.2.3
108
+
109
+ - Hotfix for gradio pydantic issue with fastapi
110
+ - Upgraded to Gradio 4.43 hoping it will fix remaining issues
111
+ - Added new action when no face detected -> use last swapped
112
+ - Specified image format for image controls - opening new tabs on preview images possible again!
113
+ - Hardcoded image output format for livecam to jpeg - might be faster than previous webp
114
+ - Chain events to be only executed if previous was a success
115
+
116
+ **5.9.2024** v4.2.0
117
+
118
+ - Added ability to move input & target faces order
119
+ - New CLI Arguments override settings
120
+ - Small UI changes to faceswapping tab
121
+ - Added mask option and code for restoration of original mouth area
122
+ - Updated gradio to v4.42.0
123
+ - Added CLI Arguments --server_share and --cuda_device_id
124
+ - Added webp image support
125
+
126
+ **15.07.2024** v4.1.1
127
+
128
+ - Bugfix: Post-processing after swapping
129
+
130
+ **14.07.2024** v4.1.0
131
+
132
+ - Added subsample upscaling to increase swap resolution
133
+ - Upgraded gradio
134
+
135
+ **12.05.2024** v4.0.0
136
+
137
+ - Bugfix: Unnecessary init every frame in live-cam
138
+ - Bugfix: Installer downloading insightface package each run
139
+ - Added xseg masking to live-cam
140
+ - Added realesrganx2 to frame processors
141
+ - Upgraded some requirements
142
+ - Added subtypes and different model support to frame processors
143
+ - Allow frame processors to change resolutions of videos
144
+ - Different OpenCV Cap for MacOS Virtual Cam
145
+ - Added complete frame processing to extras tab
146
+ - Colorize, upscale and misc filters added
147
+
148
+ **22.04.2024** v3.9.0
149
+
150
+ - Bugfix: Face detection bounding box corrupt values at weird angles
151
+ - Rewrote mask previewing to work with every model
152
+ - Switching mask engines toggles text interactivity
153
+ - Clearing target files, resets face selection dropdown
154
+ - Massive rewrite of swapping architecture, needed for xseg implementation
155
+ - Added DFL Xseg Support for partial face occlusion
156
+ - Face masking only runs when there is a face detected
157
+ - Removed unnecessary toggle checkbox for text masking
158
+
159
+ **22.03.2024** v3.6.5
160
+
161
+ - Bugfix: Installer pulling latest update on first installation
162
+ - Bugfix: Regression issue, blurring/erosion missing from face swap
163
+ - Exposed erosion and blur amounts to UI
164
+ - Using same values for manual masking too
165
+
166
+ **20.03.2024** v3.6.3
167
+
168
+ - Bugfix: Workaround for Gradio Slider Change Bug
169
+ - Bugfix: CSS Styling to fix Gradio Image Height Bug
170
+ - Made face swapping mask offsets resolution independant
171
+ - Show offset mask as overlay
172
+ - Changed layout for masking
173
+
174
+ **18.03.2024** v3.6.0
175
+
176
+ - Updated to Gradio 4.21.0 - requiring many changes under the hood
177
+ - New manual masking (draw the mask yourself)
178
+ - Extras Tab, streamlined cutting/joining videos
179
+ - Re-added face selection by gender (on-demand loading, default turned off)
180
+ - Removed unnecessary activate live-cam option
181
+ - Added time info to preview frame and changed frame slider event to allow faster changes
182
+
183
+ **10.03.2024** v3.5.5
184
+
185
+ - Bugfix: Installer Path Env
186
+ - Bugfix: file attributes
187
+ - Video processing checks for presence of ffmpeg and displays warning if not found
188
+ - Removed gender + age detection to speed up processing. Option removed from UI
189
+ - Replaced restoreformer with restoreformer++
190
+ - Live Cam recoded to run separate from virtual cam and without blocking controls
191
+ - Swapping with only 1 target face allows selecting from several input faces
192
+
193
+ **08.01.2024** v3.5.0
194
+
195
+ - Bugfix: wrong access options when creating folders
196
+ - New auto rotation of horizontal faces, fixing bad landmark positions (expanded on PR 364)
197
+ - Simple VR Option for stereo Images/Movies, best used in selected face mode
198
+ - Added RestoreFormer Enhancer - https://github.com/wzhouxiff/RestoreFormer
199
+ - Bumped up package versions for onnx/Torch etc.
200
+
201
+ **16.10.2023** v3.3.4
202
+
203
+ **11.8.2023** v2.7.0
204
+
205
+ Initial Gradio Version - old TkInter Version now deprecated
206
+
207
+ - Re-added unified padding to face enhancers
208
+ - Fixed DMDNet for all resolutions
209
+ - Selecting target face now automatically switches swapping mode to selected
210
+ - GPU providers are correctly set using the GUI (needs restart currently)
211
+ - Local output folder can be opened from page
212
+ - Unfinished extras functions disabled for now
213
+ - Installer checks out specific commit, allowing to go back to first install
214
+ - Updated readme for new gradio version
215
+ - Updated Colab
216
+
217
+ # Acknowledgements
218
+
219
+ Lots of ideas, code or pre-trained models borrowed from the following projects:
220
+
221
+ https://github.com/deepinsight/insightface<br/>
222
+ https://github.com/s0md3v/roop<br/>
223
+ https://github.com/AUTOMATIC1111/stable-diffusion-webui<br/>
224
+ https://github.com/Hillobar/Rope<br/>
225
+ https://github.com/TencentARC/GFPGAN<br/>
226
+ https://github.com/kadirnar/codeformer-pip<br/>
227
+ https://github.com/csxmli2016/DMDNet<br/>
228
+ https://github.com/glucauze/sd-webui-faceswaplab<br/>
229
+ https://github.com/ykk648/face_power<br/>
230
+
231
+ Thanks to all developers!