Skip to content

Commit

Permalink
path fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
the-database committed Jul 25, 2024
1 parent 18ca2cd commit 8b416c3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion VideoJaNai/Services/PythonService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public PythonService(IUpdateManagerService? updateManagerService = null)
public string BackendDirectory => (_updateManagerService?.IsInstalled ?? false) ? Path.Join(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"VideoJaNai") : Path.GetFullPath(@".\backend");
public string PythonDirectory => Path.Join(BackendDirectory, "python");
public string FfmpegDirectory => Path.Join(BackendDirectory, "ffmpeg");
public string AnimeJaNaiDirectory => Path.Join(BackendDirectory, "animejanai");
public string AnimeJaNaiDirectory => Path.GetFullPath("./backend/animejanai");
public string PythonPath => Path.GetFullPath(Path.Join(PythonDirectory, PYTHON_DOWNLOADS["win32"].Path));
public string VapourSynthPluginsPath => Path.Combine(PythonDirectory, "vs-plugins");
public string FfmpegPath => Path.GetFullPath(Path.Join(FfmpegDirectory, "ffmpeg.exe"));
Expand Down
7 changes: 4 additions & 3 deletions VideoJaNai/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ public void SetupAnimeJaNaiConfSlot1()
var configText = new StringBuilder($@"[global]
logging=yes
backend={backend}
backend_path={_pythonService.BackendDirectory}
[slot_1]
profile_name=encode
");
Expand Down Expand Up @@ -522,14 +523,14 @@ public void CancelUpscale()

public async Task RunUpscaleSingle(string inputFilePath, string outputFilePath)
{
var cmd = $@"{_pythonService.VspipePath} -c y4m --arg ""slot=1"" --arg ""video_path={inputFilePath}"" ./animejanai_encode.vpy - | {_pythonService.FfmpegPath} {_overwriteCommand} -i pipe: -i ""{inputFilePath}"" -map 0:v -c:v {CurrentWorkflow.FfmpegVideoSettings} -max_interleave_delta 0 -map 1:t? -map 1:a? -map 1:s? -c:t copy -c:a copy -c:s copy ""{outputFilePath}""";
var cmd = $@"{Path.GetRelativePath(_pythonService.BackendDirectory, _pythonService.VspipePath)} -c y4m --arg ""slot=1"" --arg ""video_path={inputFilePath}"" ""{Path.GetFullPath("./backend/animejanai/core/animejanai_encode.vpy")}"" - | {_pythonService.FfmpegPath} {_overwriteCommand} -i pipe: -i ""{inputFilePath}"" -map 0:v -c:v {CurrentWorkflow.FfmpegVideoSettings} -max_interleave_delta 0 -map 1:t? -map 1:a? -map 1:s? -c:t copy -c:a copy -c:s copy ""{outputFilePath}""";
ConsoleQueueEnqueue($"Upscaling with command: {cmd}");
await RunCommand($@" /C {cmd}");
}

public async Task GenerateEngine(string inputFilePath)
{
var cmd = $@"{_pythonService.VspipePath} -c y4m --arg ""slot=1"" --arg ""video_path={inputFilePath}"" --start 0 --end 1 ./animejanai_encode.vpy -p .";
var cmd = $@"{Path.GetRelativePath(_pythonService.BackendDirectory, _pythonService.VspipePath)} -c y4m --arg ""slot=1"" --arg ""video_path={inputFilePath}"" --start 0 --end 1 ""{Path.GetFullPath("./backend/animejanai/core/animejanai_encode.vpy")}"" -p .";
ConsoleQueueEnqueue($"Generating TensorRT engine with command: {cmd}");
await RunCommand($@" /C {cmd}");
}
Expand All @@ -546,7 +547,7 @@ public async Task RunCommand(string command)
process.StartInfo.RedirectStandardError = true;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WorkingDirectory = Path.Combine(_pythonService.AnimeJaNaiDirectory, "core");
process.StartInfo.WorkingDirectory = _pythonService.BackendDirectory;

// Create a StreamWriter to write the output to a log file
using (var outputFile = new StreamWriter("error.log", append: true))
Expand Down
10 changes: 5 additions & 5 deletions VideoJaNai/backend/animejanai/core/animejanai_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
core = vs.core
core.num_threads = 4 # can influence ram usage

plugin_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
r"..\..\python\vs-plugins\vsmlrt-cuda")


plugin_path = None
model_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
r"..\onnx")

Expand Down Expand Up @@ -270,11 +267,14 @@ def run_animejanai_with_keybinding(clip, container_fps, keybinding):


def init():
global config, current_logger_info, current_logger_steps
global config, current_logger_info, current_logger_steps, plugin_path
current_logger_info = []
current_logger_steps = []
write_current_log_empty()
config = animejanai_config.read_config()
backend_path = config["global"]["backend_path"]
plugin_path = os.path.join(backend_path, "python/vs-plugins/vsmlrt-cuda")

if config['global']['logging']:
init_logger()

Expand Down

0 comments on commit 8b416c3

Please sign in to comment.