Skip to content

Commit

Permalink
Merge branch 'main' into snyk-fix-b3ef5f2429466bca97071c582d14409c
Browse files Browse the repository at this point in the history
  • Loading branch information
jhogsett committed May 24, 2024
2 parents f0a1f8f + 2df0abc commit 4ecc227
Show file tree
Hide file tree
Showing 33 changed files with 5,538 additions and 3,201 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,5 @@ ui.bat
config-local.yaml
my_video_blender_projects.csv
session.yaml
EMA-VFI/
Real-ESRGAN/
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[![Pylint](https://github.com/jhogsett/EMA-VFI-WebUI/actions/workflows/pylint.yml/badge.svg)](https://github.com/jhogsett/EMA-VFI-WebUI/actions/workflows/pylint.yml)
![pybadge](https://img.shields.io/badge/Python-3.10.9-4380b0)
![ptbadge](https://img.shields.io/badge/Torch-1.13.1-ee4b28)
![nvbadge](https://img.shields.io/badge/Cuda-11.7-76b900)
![ptbadge](https://img.shields.io/badge/Torch-2.2.0-ee4b28)
![nvbadge](https://img.shields.io/badge/Cuda-12.4-76b900)
![grbadge](https://img.shields.io/badge/Gradio-3.36.1-f67500)

# EMA-VFI-WebUI - AI-Based Movie Restoration

![frame-interpolation](https://github.com/jhogsett/EMA-VFI-WebUI/assets/825994/2370458c-6414-421f-8aa2-33a0db84c2cf)

🎬 [Windows 11 example install steps 11/03/2023](https://github.com/jhogsett/EMA-VFI-WebUI/wiki/Example-Windows-11-Install-Steps-November-3,-2023)
🎬 [Windows 11 example install steps 4/20/2024](https://github.com/jhogsett/EMA-VFI-WebUI/wiki/Example-Windows-11-Install-Steps-April-20,-2024)

_**💥 See more samples in the**_ [Samples Showcase](https://github.com/jhogsett/EMA-VFI-WebUI/wiki/Samples-Showcase)

Expand Down
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ realesrgan_settings:
tile_pad: 10
tiling: 256
remixer_settings:
audio_format: wav
backup_split_scenes: True
custom_ffmpeg_video: -c:v libx264 -crf 23
custom_ffmpeg_audio: -c:a aac -shortest
Expand Down Expand Up @@ -130,6 +129,7 @@ remixer_settings:
maximum_crf: 28
min_frames_per_scene: 10
minimum_crf: 17
raise_on_error: False
scale_type_up: "lanczos"
scale_type_down: "area"
source_audio_crf: 28
Expand Down
1 change: 1 addition & 0 deletions deduplicate_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def main():
args.max_dupes,
args.depth,
log.log,
type=args.type,
tune_min=args.tune_min,
tune_max=args.tune_max,
tune_step=args.tune_step).invoke(args.disposition)
Expand Down
15 changes: 9 additions & 6 deletions guide/autofill_duplicates.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
**Auto-Fill Duplicate Frames** - Detect duplicate frames and fill with interpolated replacements

## How It Works
1. Set _Input PNG Files Path_ to a path on this server for the PNG files being deduplicated
1. Set _Output PNG Files Path_ to a path on this server to store the deduplicated PNG files
- Output PNG File Path can be left blank to use the default folder
- _Tip: The default folder is set by the_ `config.directories.output_deduplication` _setting_
1. Set _Detect Threshold_ to specify the sensitivity to frame differences
- A lower value finds fewer duplicates; a higher value finds more
- This value requires experimentation. See _More Details_ below.
Expand All @@ -18,9 +14,16 @@
1. Set _Search Precision_ to the depth of search needed for accuracy
- High precision yields precise frame timing, but takes a long time
- Less precision is faster, with possible imprecise frame timing
1. Click _Deduplicate Frames_
1. The _Details_ box shows the result of the operation, or any errors encountered
1. Choose _Individual Path_ or _Batch Processing_
- If **Individual Path**
1. Set _Input PNG Files Path_ to a path on this server for the PNG files being deduplicated
1. Set _Output PNG Files Path_ to a path on this server to store the deduplicated PNG files
- If **Batch Processing**
1. Set _Input PNG Files Path_ to a directory on this servery containing the frame groups to be deduplicated
1. Set _Output PNG Files Path_ to a directory on this server for the deduplicated frame groups
1. Click _Deduplicate Frames_ or _Deduplicate Batch_
1. On completion, a report .txt file is written to the output path with details of the auto-filling
- Progress can be tracked in the console

## Important
- This process could be slow, perhaps many hours long!
Expand Down
70 changes: 58 additions & 12 deletions guide/video_remixer_choose.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,29 +34,32 @@ _Choose Scene Range_

## Properties Accordion
_Scene Label_
- Enter a scene label and click _Set_ to save it with the scene
- Enter a scene label and press _Enter_ or click _Set_ to save it with the scene
- _Tip:_ Use the < and > buttons to navigate to labeled scenes

### About Scene Labels
- Labels can be used to add a scene title
- The entered scene title will appear in the video when using the _Labeled Remix_ feature
- The entered title will also be used as the based for the scene remix clip, making it easier to reuse individual clips
- The entered title will also be used as the basis for the scene remix clip, making it easier to find and reuse individual scene clips
- Labels can be used to rearrange scene order in the remix video
- When a label starts with a value inside parentheses, the value will be used to arrange the clips in sorted order
- _Tip:_ use the _Auto Label Scenes_ button to automatically add a sorting mark to each scene
- Labels can be used to mark a scene for 2X or 4X audio slow motion
- **NOTE** the main video must use 2X Inflation for this feature to work
- Use the _Add 2X Audio Slo Mo_ or _Add 4X Audio Slo Mo_ buttons to add a _processing hint_ to the scene label
- _Tip:_ use the _+ Sort Keys_ button to automatically add a sorting mark to each scene
- Labels can be used to add _Processing Hints_
- Use the _+ 2X Slo Mo_, _+ 4X Slo Mo_ or _+ 8X Slo Mo_ buttons to add a _Processing Hint_ to the scene label that adds audio pitch-adjusted slow motion

_Auto Label Scenes_
_Tip: See below for more details on_ Processing Hints

_+ Sort Keys_
- Automatically adds a sorting mark to each scene

_Reset Scene Labels_
_+ Title_
- Automatically adds a default title to each scene

_Reset_
- Clears the contents of all scene labels

_Add 2X Audio Slo Mo_ and _Add 4X Audio Slo Mo_
- Add a _processing hint_ to the scene label to enabled 2X or 4X audio slow motion processing
- **NOTE** the main video must use 2X Inflation for this feature to work
_+ 2X Slo Mo_, _+ 4X Slo Mo_ and _+ 8X Slo Mo_
- Add a _processing hint_ to the scene label to enable 2X, 4X or 8X audio slow motion with pitch adjustment processing

The _Keep All Scenes_ and _Drop All Scenes_ buttons (inside the _Danger Zone_ accordion)
- **Destructively** _Keep_ or _Drop_ all scenes (there is no undo)
Expand All @@ -68,7 +71,7 @@ The _Split Scene_ and _Drop Processed Scene_ buttons (inside the _Danger Zone_ a
## Danger Zone Accordion

_Keep All Scenes_ and _Drop All Scenes_
- Sets all sets to _Keep_ or _Drop_
- Sets **_all_** scenes to _Keep_ or _Drop_

_Invert Scene Choices_
- Changes all scene keep/drop statues to the opposite state
Expand All @@ -79,5 +82,48 @@ _Invert Scene Choices_
_Drop Processed Scene_
- Opens the _Drop Processed Scenes_ tab to drop a scene, including its processed content, to save the remix video without that the dropped scene, avoiding reprocessing the whole video

_Mark Scene_
- Remembers the current scene ID to make it easier to use features that require entering a scene ID range
- This can be used with the _Merge Scene Range_ and _Choose Scene Range_ features
1. Go to the first scene of the range and click _Mark Scene_
1. Go to the last scene of the range, then click either of these shortcut buttons
- Merge Scenes
- Choose Scene Range

_Merge Scenes_
- Shortcut that takes you to the Remix Extra _Merge Scenes_ tab

## Processing Hints

Resize:
- `{R:x/y}` zoom into quadrant `x` of `y` sized grid
- Example:
- `{R:1/4}` zoom into upper left quadrant of 2x2 grid
- `{R:5/9}` zoom into center quadrant of 3x3 grid (like a telephone keypad)
- `{R:z%}` zoom in the center at `z` percent
- Example:
- `{R:200%}` zoom in at 200%

Resynthesize:
- `{Y:type}` enable resynthesis of `type`
- Types:
- `C` clean (first past only of two pass resynth)
- `S` scrub (two pass resynth)
- `R` replace (one pass resynth)
- `N` no resynthesis

Inflation:
- `{I:nt}` inflate amount `n` with type `y`
- Amounts: `1`, `2`, `4`, `8`, `16`
- `1` means don't inflate
- Types:
- `A` slow motion with audio pitch adjust
- `S` slow motion with silent audio
- `N` no slow motion (can be omitted)

Upscale:
- `{U:_}` upscale at 1X for clean-up
- `_` reserved for future use

## Important
- `ffmpeg.exe` must be available on the system path
40 changes: 11 additions & 29 deletions guide/video_remixer_processing.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,28 @@
- Clean frames by completely replacing with interpolations from adjacent frames
- Deepest cleaning method, but does not handle fast-moving content well
1. Check _Inflate New Frames_ to insert AI-interpolated frames between all real frames
- Choose whether to inflate by _2X_, _4X_ or _8X_
- The choices will insert 1, 3 or 7 new frames between existing frames
- Choose whether to inflate by _2X_, _4X_, _8X_ or _16X_
- The choices will insert 1, 3, 7 or 15 new frames between existing frames
- Choose whether to produce a slow-motion video
- **_No_** Create a real-time video
- Adjust the output FPS to compensate for the inserted frames
- **_Audio_** Create a slow-motion video with audio
- Adjust the output FPS and audio pitch to compensate for the new frames
- **_Tip:_** See below for more information about slow-motion videos
- **_Silent_** Create a slow-motion video without audio
- Keep the original FPS to reveal the most motion slowdown
- Use silence instead of pitch-compensated audio
1. Check _Upscale Frames_ to use AI to clean and enlarge frames
- Choose whether to upscale by _1X_, _2X_ or _4X_
- Choose whether to upscale by _1X_, _2X_, _3X_ or _4X_
- Upscaling at 1X will cleanse the frames without enlarging
- Upscaling at 2X - 4X will cleanse the frames and double or quadruple the frame size
- Upscaling at 2X - 4X will cleanse the frames and double, triple or quadruple the frame size
1. Click _Process Remix_ to kick off the processing
- Progress can be tracked in the console

## Advanced Options Accordion
- Check _Automatically save default MP4 video_ to:
- Save the Remix Video using default MP4 settings as seen on the _Save MP4 Remix_ tab
- Check _Delete processed content after saving_ to:
- Automatically purged all generated project content after saving the Remix Video

## Note
- Content may be _purged_ (soft-deleted) when clicking _Process Remix_
- Previous process content not currently needed is set aside
Expand All @@ -41,26 +46,3 @@
- The browser window does NOT need to be left open
- The project can be reopened later to resume where you left off
- `ffmpeg.exe` must be available on the system path

## More About Slow-Motion Videos

### _Real-Time_ and _Slow-Motion_ Video Compatibility
If creating slow-motion videos to combine with real-time videos, note the following chart showing the effect of Inflation options on Remix Video FPS:

| Inflate By | Slo Mo 'NO' | Slo Mo 'AUDIO' | Slo Mo 'SILENT'
| :-: | :-: | :-: | :-: |
| 2X | FPS x 2 | FPS x 1, Audio Pitch x .50 | FPS x 1 |
| 4X | FPS x 4 | FPS x 2, Audio Pitch x .50 | FPS x 1 |
| 8X | FPS x 8 | FPS x 2, Audio Pitch x .25 | FPS x 1 |

### Examples

_Tip:_ Use the _Video Assembler_ tab under _Tools_, _File Conversion_ to assemble video clips sharing like characteristics

- Make a video combining real-time footage and 8X silent slow motion
- Create the real-time remix video **_without_** using Inflation
- Create the slow-motion remix video with the "8X" and "Silent" Inflation options

- Make a smoothed video combining real-time footage with 2X and 4X slow motion
- Create the real-time remix video with the "2X" and "No" Inflation options
- Create the slow-motion remix video with the "2X" and "4X", and "Audio" Inflation options
4 changes: 3 additions & 1 deletion guide/video_remixer_settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@

## More Options Accordion
1. Click _More Options_ to access additional project setup options
- Click _Reuse Last-Used Settings_, to load the settings from the last created project
- Click _Reuse Last-Used Settings_ to load the settings from the last created project
- Useful when processing a series of similar content such as TV programs
- Click _Use Memorized Setting_ to load the settings that were previously _remembered_
- Click _Remember These Settings_ to save the settings for later use
- Set _Crop X Offset_ and _Crop Y Offset_, useful for:
- Removing letter/pillar boxes
- Fixing incorrectly centered content
Expand Down
17 changes: 4 additions & 13 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
ffmpy==0.3.0
gradio==3.36.1
gradio_client==0.7.1
imageio==2.34.0
matplotlib==3.6.3
numpy==1.23.5
opencv_python==4.8.1.78
Pillow==10.2.0
opencv-python==4.9.0.80
Pillow==10.3.0
PyYAML==6.0
scikit_image==0.19.3
scipy==1.10.1
scikit-image==0.19.3
tensorboardX==2.6
timm==0.6.12
torch==1.13.1
torchvision==0.14.1
tqdm==4.64.1
setuptools>=65.5.1 # not directly required, pinned by Snyk to avoid a vulnerability
wheel>=0.38.0 # not directly required, pinned by Snyk to avoid a vulnerability
torch==2.2.0
4 changes: 0 additions & 4 deletions resequence_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ def resequence_groups(self, group_names : list, contiguous=True, ignore_name_cla
def resequence_batch(self, contiguous=True, ignore_name_clash=True):
"""Resequence groups of files. Returns a string with any errors."""
group_names = sorted(get_directories(self.input_path), reverse=self.reverse)
self.log(f"Found {len(group_names)} file groups")
return self.resequence_groups(group_names,
contiguous=contiguous,
ignore_name_clash=ignore_name_clash)
Expand All @@ -158,7 +157,6 @@ def resequence(self, ignore_name_clash=True) -> None:
files = sorted(glob.glob(os.path.join(self.input_path, "*." + self.file_type)),
reverse=self.reverse)
num_files = len(files)
self.log(f"Found {num_files} files")

if not ignore_name_clash:
check_for_name_clash(files, self.new_base_filename, self.file_type)
Expand All @@ -181,11 +179,9 @@ def resequence(self, ignore_name_clash=True) -> None:
if self.rename:
new_filepath = os.path.join(self.input_path, new_filename)
os.replace(old_filepath, new_filepath)
self.log(f"File {file} renamed to {new_filepath}")
else:
new_filepath = os.path.join(self.output_path, new_filename)
shutil.copy(old_filepath, new_filepath)
self.log(f"File {file} copied to {new_filepath}")

running_index += self.index_step
Mtqdm().update_bar(bar)
Expand Down
Loading

0 comments on commit 4ecc227

Please sign in to comment.