Skip to content

Commit

Permalink
add image extraction logic
Browse files Browse the repository at this point in the history
  • Loading branch information
TNTwise committed May 15, 2024
1 parent 8683b42 commit 2087cd2
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 10 deletions.
15 changes: 12 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,16 @@ def setEnsembleMode(self):
):
self.ui.EnsembleCheckBox.show()
self.ui.ensembleHelpButton.show()

def TurnOffCustomFPSMultiplierIfImageExtraction(self):
if self.ui.ImageExtractionCheckBox.isChecked():
self.ui.FPSTo.show()
self.ui.FPSFrom.show()
self.ui.FPSToSign.show()

else:
self.ui.FPSTo.hide()
self.ui.FPSFrom.hide()
self.ui.FPSToSign.hide()
def greyOutRifeTimes(self):
if (
"v4" in self.ui.Rife_Model.currentText()
Expand All @@ -691,8 +700,7 @@ def greyOutRifeTimes(self):
self.ui.Rife_Times.setEnabled(True)

self.setEnsembleMode()
self.ui.FPSFrom.show()
self.ui.FPSTo.show()
self.TurnOffCustomFPSMultiplierIfImageExtraction()

else:
self.ui.FPSFrom.hide()
Expand Down Expand Up @@ -939,6 +947,7 @@ def setDisableEnable(self, mode):
self.ui.InstallModelsFrame.setDisabled(mode)
self.ui.SettingsMenus.setDisabled(mode)
self.ui.modeCombo.setDisabled(mode)
self.ui.ImageExtractionCheckBox.setDisabled(mode)

def endRife(
self,
Expand Down
9 changes: 8 additions & 1 deletion mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="ImageExtractionCheckBox">
<property name="text">
<string>Image Extraction</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="denoiseLevelLabel">
<property name="text">
Expand Down Expand Up @@ -885,7 +892,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>479</width>
<width>126</width>
<height>192</height>
</rect>
</property>
Expand Down
1 change: 1 addition & 0 deletions modules/CUGAN.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def modelOptions(self):
self.ui.Rife_Times.currentIndexChanged.connect(self.cuganDenoiseLevel)
self.ui.denoiseLevelSpinBox.valueChanged.connect(self.incrementcuganDenoiseLevel)
self.ui.EnsembleCheckBox.hide()
self.ui.ImageExtractionCheckBox.hide()
self.ui.Rife_Times.addItem("2X")
self.ui.Rife_Times.addItem("3X")
self.ui.Rife_Times.addItem("4X")
Expand Down
1 change: 1 addition & 0 deletions modules/CustomModelsCUDA.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def modelOptions(self):
self.ui.Rife_Model.addItems(os.listdir(f"{thisdir}/models/custom-models-cuda"))
self.ui.Rife_Times.setEnabled(True)
self.ui.EnsembleCheckBox.hide()
self.ui.ImageExtractionCheckBox.hide()

try:
self.ui.Rife_Model.currentIndexChanged.disconnect()
Expand Down
2 changes: 1 addition & 1 deletion modules/CustomModelsNCNN.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def modelOptions(self):
self.ui.Rife_Model.addItem(i.replace(".bin", ""))

self.ui.EnsembleCheckBox.hide()

self.ui.ImageExtractionCheckBox.hide()
try:
self.ui.Rife_Model.currentIndexChanged.disconnect()
except:
Expand Down
1 change: 1 addition & 0 deletions modules/ESRGAN.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def modelOptions(self):
self.ui.FPSPreview.setText("RES:")
self.ui.Rife_Model.addItem("Animation")
self.ui.EnsembleCheckBox.hide()
self.ui.ImageExtractionCheckBox.hide()
self.ui.ensembleHelpButton.hide()

self.ui.Rife_Model.setCurrentIndex(0)
Expand Down
1 change: 1 addition & 0 deletions modules/GMFSSCUDA.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def modelOptions(self):
self.ui.Rife_Times.clear()
self.ui.FPSPreview.setText("FPS:")
self.ui.ensembleHelpButton.hide()
self.ui.ImageExtractionCheckBox.hide()
self.ui.Rife_Times.addItem("2X")

model_list = ["gmfss-fortuna"]
Expand Down
1 change: 1 addition & 0 deletions modules/IFRNET.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def modelOptions(self):
self.ui.ensembleHelpButton.hide()
self.ui.Rife_Times.addItem("2X")
self.ui.EnsembleCheckBox.hide()
self.ui.ImageExtractionCheckBox.hide()

try:
self.ui.Rife_Model.currentIndexChanged.disconnect()
Expand Down
2 changes: 1 addition & 1 deletion modules/RealESRGANCUDA.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def modelOptions(self):
self.ui.Rife_Times.setCurrentIndex(0)
self.ui.denoiseLevelLabel.hide()
self.ui.denoiseLevelSpinBox.hide()

self.ui.ImageExtractionCheckBox.hide()
try:
self.ui.RifeStart.clicked.disconnect()
except:
Expand Down
4 changes: 4 additions & 0 deletions modules/Rife.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ def modelOptions(self):
if "ensemble" not in i:
models.append(i)
models.sort()

# Custom options
self.ui.EnsembleCheckBox.show()
self.ui.ensembleHelpButton.show()
self.ui.ImageExtractionCheckBox.show()
if len(self.get_models_from_dir("rife")) > 0:
self.ui.Rife_Model.addItems(models)
model_list = []
Expand Down
1 change: 1 addition & 0 deletions modules/RifeCUDA.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def modelOptions(self, trt=False):
self.ui.Rife_Model.addItems(model_list)
self.ui.Rife_Times.setEnabled(True)
self.ui.EnsembleCheckBox.show()
self.ui.ImageExtractionCheckBox.hide()
if self.output_folder == "":
outputpath = settings.OutputDir
else:
Expand Down
1 change: 1 addition & 0 deletions modules/SPANNCNN.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def modelOptions(self):
self.ui.Rife_Model.addItem("ClearReality4x")
self.ui.EnsembleCheckBox.hide()
self.ui.EnsembleCheckBox.hide()
self.ui.ImageExtractionCheckBox.hide()
self.ui.FPSFrom.hide()
self.ui.FPSToSign.hide()
self.ui.FPSTo.hide()
Expand Down
1 change: 1 addition & 0 deletions modules/Waifu2X.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def modelOptions(self):

self.greyOutRealSRTimes()
self.ui.EnsembleCheckBox.hide()
self.ui.ImageExtractionCheckBox.hide()
self.ui.RifeStart.clicked.connect(
lambda: upscale.start_upscale(self, "waifu2x-ncnn-vulkan")
)
Expand Down
11 changes: 9 additions & 2 deletions modules/interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,18 @@ def initializeInterpolation(
log(f"ERROR: {e} {traceback_info}")
self.showDialogBox(e)


def changeRifeToFrameExtraction(self,AI):
frameExtraction = self.ui.ImageExtractionCheckBox.isChecked()
if AI == "rife-ncnn-python" and frameExtraction:
AI = "rife-ncnn-vulkan"
return AI
def start_interpolation(
self, AI
): # command directly connected to the rife start button

AI = changeRifeToFrameExtraction(self,AI)
try:

if self.input_file != "":
self.render = "rife"
has_enough_space, predicted_space, total_space = (
Expand All @@ -98,7 +105,7 @@ def start_interpolation(
self.input_file, self.render, self.times
)
)
if "cuda" not in AI:
if "cuda" not in AI or "ncnn-python" not in AI:
if has_enough_space or not_enough_storage(
self, predicted_space, total_space
):
Expand Down
3 changes: 2 additions & 1 deletion modules/realsr.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def modelOptions(self):
self.ui.FPSToSign.hide()
self.ui.FPSTo.hide()
self.ui.ensembleHelpButton.hide()
self.ui.ImageExtractionCheckBox.hide()
self.ui.Rife_Model.setCurrentIndex(0)
try:
self.ui.Rife_Model.currentIndexChanged.disconnect()
Expand All @@ -54,6 +55,6 @@ def modelOptions(self):
self.ui.Rife_Times.clear()
self.ui.denoiseLevelLabel.hide()
self.ui.denoiseLevelSpinBox.hide()

self.ui.Rife_Times.addItem("4X")
self.ui.Rife_Times.setCurrentIndex(0)
1 change: 1 addition & 0 deletions src/misc/onProgramStart.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def bindButtons(self):
self.ui.gpuThreadingHelpButton.clicked.connect(lambda: vram_help(self))
self.ui.logButton.clicked.connect(lambda: viewLogs(self))
self.ui.RifeResume.clicked.connect(self.resume_render)
self.ui.ImageExtractionCheckBox.clicked.connect(self.TurnOffCustomFPSMultiplierIfImageExtraction)
self.ui.sceneChangeSensativityButton.clicked.connect(
lambda: show_scene_change_help(self)
)
Expand Down
3 changes: 2 additions & 1 deletion src/runAI/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def finishRenderSetup(self): # 3rd and final call, called from interpolate.py

# run transition detection start
if self.main.AI == "rife-ncnn-vulkan":
if "v4" in self.model:
if "v4" in self.model and self.main.ui.ImageExtractionCheckBox.isChecked():
self.main.times = (
self.main.ui.FPSTo.value() / self.main.ui.FPSFrom.value()
)
Expand All @@ -551,6 +551,7 @@ def Render(self, model, times, videopath, outputpath):
self.log.emit(f"Model: {self.main.ui.Rife_Model.currentText()}")
vram = int(calculateVRAM(self))
if "-ncnn-vulkan" in self.main.AI:
self.main.start_time = time.time()
self.input_frames = len(
os.listdir(
f"{settings.RenderDir}/{self.main.videoName}_temp/input_frames/"
Expand Down

0 comments on commit 2087cd2

Please sign in to comment.