Improve Batch Generation

This commit is contained in:
bmgjet 2024-12-23 19:49:33 +13:00
parent a11465ec09
commit 64585d6ae2
9 changed files with 235 additions and 182 deletions

Binary file not shown.

View File

@ -72,8 +72,10 @@
this.RunJobs = new System.Windows.Forms.Button();
this.timer2 = new System.Windows.Forms.Timer(this.components);
this.Batch = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// pictureBox1
@ -140,7 +142,7 @@
//
// SelectImg1
//
this.SelectImg1.Location = new System.Drawing.Point(6, 298);
this.SelectImg1.Location = new System.Drawing.Point(6, 300);
this.SelectImg1.Margin = new System.Windows.Forms.Padding(2);
this.SelectImg1.Name = "SelectImg1";
this.SelectImg1.Size = new System.Drawing.Size(257, 22);
@ -151,7 +153,7 @@
//
// SelectImg2
//
this.SelectImg2.Location = new System.Drawing.Point(276, 298);
this.SelectImg2.Location = new System.Drawing.Point(276, 300);
this.SelectImg2.Margin = new System.Windows.Forms.Padding(2);
this.SelectImg2.Name = "SelectImg2";
this.SelectImg2.Size = new System.Drawing.Size(257, 22);
@ -257,7 +259,9 @@
this.AspectRatio.FormattingEnabled = true;
this.AspectRatio.Items.AddRange(new object[] {
"16:9",
"9:16"});
"9:16",
"4:3",
"1:1"});
this.AspectRatio.Location = new System.Drawing.Point(93, 372);
this.AspectRatio.Margin = new System.Windows.Forms.Padding(2);
this.AspectRatio.Name = "AspectRatio";
@ -400,7 +404,7 @@
this.Seed.Name = "Seed";
this.Seed.Size = new System.Drawing.Size(95, 20);
this.Seed.TabIndex = 31;
this.Seed.Text = "17";
this.Seed.Text = "42";
//
// Seedlbl
//
@ -440,10 +444,10 @@
//
// GenerateButton
//
this.GenerateButton.Location = new System.Drawing.Point(6, 495);
this.GenerateButton.Location = new System.Drawing.Point(6, 508);
this.GenerateButton.Margin = new System.Windows.Forms.Padding(2);
this.GenerateButton.Name = "GenerateButton";
this.GenerateButton.Size = new System.Drawing.Size(527, 30);
this.GenerateButton.Size = new System.Drawing.Size(544, 30);
this.GenerateButton.TabIndex = 34;
this.GenerateButton.Text = "Generate Video";
this.GenerateButton.UseVisualStyleBackColor = true;
@ -452,9 +456,9 @@
// PlayVideo
//
this.PlayVideo.Enabled = false;
this.PlayVideo.Location = new System.Drawing.Point(8, 527);
this.PlayVideo.Location = new System.Drawing.Point(6, 543);
this.PlayVideo.Name = "PlayVideo";
this.PlayVideo.Size = new System.Drawing.Size(524, 24);
this.PlayVideo.Size = new System.Drawing.Size(544, 24);
this.PlayVideo.TabIndex = 35;
this.PlayVideo.Text = "Play Video";
this.PlayVideo.UseVisualStyleBackColor = true;
@ -463,14 +467,14 @@
// timer1
//
this.timer1.Enabled = true;
this.timer1.Interval = 1000;
this.timer1.Interval = 2000;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// AddJob
//
this.AddJob.Location = new System.Drawing.Point(540, 458);
this.AddJob.Location = new System.Drawing.Point(556, 451);
this.AddJob.Name = "AddJob";
this.AddJob.Size = new System.Drawing.Size(101, 24);
this.AddJob.Size = new System.Drawing.Size(101, 31);
this.AddJob.TabIndex = 36;
this.AddJob.Text = "Add As Job";
this.AddJob.UseVisualStyleBackColor = true;
@ -479,17 +483,17 @@
// JobList
//
this.JobList.FormattingEnabled = true;
this.JobList.Location = new System.Drawing.Point(540, 6);
this.JobList.Location = new System.Drawing.Point(556, 12);
this.JobList.Name = "JobList";
this.JobList.Size = new System.Drawing.Size(235, 446);
this.JobList.Size = new System.Drawing.Size(228, 433);
this.JobList.TabIndex = 37;
this.JobList.SelectedIndexChanged += new System.EventHandler(this.JobList_SelectedIndexChanged);
//
// RemoveJob
//
this.RemoveJob.Location = new System.Drawing.Point(674, 458);
this.RemoveJob.Location = new System.Drawing.Point(683, 451);
this.RemoveJob.Name = "RemoveJob";
this.RemoveJob.Size = new System.Drawing.Size(101, 24);
this.RemoveJob.Size = new System.Drawing.Size(101, 31);
this.RemoveJob.TabIndex = 38;
this.RemoveJob.Text = "Remove Job";
this.RemoveJob.UseVisualStyleBackColor = true;
@ -497,9 +501,9 @@
//
// RunJobs
//
this.RunJobs.Location = new System.Drawing.Point(540, 488);
this.RunJobs.Location = new System.Drawing.Point(556, 488);
this.RunJobs.Name = "RunJobs";
this.RunJobs.Size = new System.Drawing.Size(234, 63);
this.RunJobs.Size = new System.Drawing.Size(228, 79);
this.RunJobs.TabIndex = 39;
this.RunJobs.Text = "Run Jobs";
this.RunJobs.UseVisualStyleBackColor = true;
@ -520,51 +524,59 @@
this.Batch.UseVisualStyleBackColor = true;
this.Batch.Click += new System.EventHandler(this.Batch_Click);
//
// panel1
//
this.panel1.Controls.Add(this.Batch);
this.panel1.Controls.Add(this.Schedulerlbl);
this.panel1.Controls.Add(this.Scheduler);
this.panel1.Controls.Add(this.Seed);
this.panel1.Controls.Add(this.Seedlbl);
this.panel1.Controls.Add(this.Cfg);
this.panel1.Controls.Add(this.Cfglbl);
this.panel1.Controls.Add(this.Steps);
this.panel1.Controls.Add(this.Stepslbl);
this.panel1.Controls.Add(this.Samplerlbl);
this.panel1.Controls.Add(this.GPUOffload);
this.panel1.Controls.Add(this.Offloadlbl);
this.panel1.Controls.Add(this.LowMemoryMode);
this.panel1.Controls.Add(this.Directionlbl);
this.panel1.Controls.Add(this.Direction);
this.panel1.Controls.Add(this.Motionlbl);
this.panel1.Controls.Add(this.Motion);
this.panel1.Controls.Add(this.Aspectlbl);
this.panel1.Controls.Add(this.AspectRatio);
this.panel1.Controls.Add(this.Resolutionlbl);
this.panel1.Controls.Add(this.Resolution);
this.panel1.Controls.Add(this.Frameslbl);
this.panel1.Controls.Add(this.FrameRate);
this.panel1.Controls.Add(this.SelectVideoOut);
this.panel1.Controls.Add(this.VideoOut);
this.panel1.Controls.Add(this.Videolbl);
this.panel1.Controls.Add(this.SelectImg2);
this.panel1.Controls.Add(this.SelectImg1);
this.panel1.Controls.Add(this.Img2);
this.panel1.Controls.Add(this.Img1);
this.panel1.Controls.Add(this.Img2lbl);
this.panel1.Controls.Add(this.Img1lbl);
this.panel1.Controls.Add(this.pictureBox2);
this.panel1.Controls.Add(this.pictureBox1);
this.panel1.Location = new System.Drawing.Point(6, 6);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(544, 497);
this.panel1.TabIndex = 41;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(540, 557);
this.Controls.Add(this.Batch);
this.ClientSize = new System.Drawing.Size(555, 572);
this.Controls.Add(this.panel1);
this.Controls.Add(this.RunJobs);
this.Controls.Add(this.RemoveJob);
this.Controls.Add(this.JobList);
this.Controls.Add(this.AddJob);
this.Controls.Add(this.PlayVideo);
this.Controls.Add(this.GenerateButton);
this.Controls.Add(this.Schedulerlbl);
this.Controls.Add(this.Scheduler);
this.Controls.Add(this.Seed);
this.Controls.Add(this.Seedlbl);
this.Controls.Add(this.Cfg);
this.Controls.Add(this.Cfglbl);
this.Controls.Add(this.Steps);
this.Controls.Add(this.Stepslbl);
this.Controls.Add(this.Samplerlbl);
this.Controls.Add(this.GPUOffload);
this.Controls.Add(this.Offloadlbl);
this.Controls.Add(this.LowMemoryMode);
this.Controls.Add(this.Directionlbl);
this.Controls.Add(this.Direction);
this.Controls.Add(this.Motionlbl);
this.Controls.Add(this.Motion);
this.Controls.Add(this.Aspectlbl);
this.Controls.Add(this.AspectRatio);
this.Controls.Add(this.Resolutionlbl);
this.Controls.Add(this.Resolution);
this.Controls.Add(this.Frameslbl);
this.Controls.Add(this.FrameRate);
this.Controls.Add(this.SelectVideoOut);
this.Controls.Add(this.VideoOut);
this.Controls.Add(this.Videolbl);
this.Controls.Add(this.SelectImg2);
this.Controls.Add(this.SelectImg1);
this.Controls.Add(this.Img2);
this.Controls.Add(this.Img1);
this.Controls.Add(this.Img2lbl);
this.Controls.Add(this.Img1lbl);
this.Controls.Add(this.pictureBox2);
this.Controls.Add(this.pictureBox1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Margin = new System.Windows.Forms.Padding(2);
@ -575,8 +587,9 @@
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
@ -624,6 +637,7 @@
private System.Windows.Forms.Button RunJobs;
private System.Windows.Forms.Timer timer2;
private System.Windows.Forms.Button Batch;
private System.Windows.Forms.Panel panel1;
}
}

View File

@ -1,9 +1,11 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.IO.Compression;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@ -13,29 +15,117 @@ namespace Ruyi_GUI
{
public partial class Form1 : Form
{
public string PythonCode = Encoding.UTF8.GetString(Convert.FromBase64String(Decompress(Convert.FromBase64String("xRprb+M28nuA/AeeroClrqrdpO0eEEAf0tjZGhdvgiS3/ZAzBMaibG5kUadHNmng/34zJCVRD9vpXoAL0CbivIfD4cxw+ToVWUFEfnjA1Z+FyBarw4MoE2tyNb0genm6pkuml0MeRWXOsrwC2pMyZtmY54uMFexmsWIhLrhErp8mC5YXGY37COOr2Y2IH1k2K+OC5wVLDeKrz+OZ8TkeT5tPR6si1mxJFyKJKlUuceEMFjQCyE3ySGRrQ92zi+mVtOcqE6BaLoA7rn3hORfJTIQs/oMXK4B+ZYsCljSvnEagfQL4uSfdVDGMBQ2DiMeM0Fx9GKiaeFUulzxZRnTBglV5X5HmCU3zlSiCUHxLkFSjZ+Uz90JaUO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lZr2+KROdncf5p6yA7oCODN1uls6aFrMIXqk/QMZcelIUiWzmjzjiktac2iQ15tN2x2d3J7SEi33t3lUH4eKWhJh+sWUhC4++uiAi48+Nl41NZy3orDLpNneTubwevEZRDFddoPZKFW8FQ9DqNAWFEqTKhR6U8nhM7GPzQetXWdYirOt8dXs3btquJUIONqBWTfueHbpFXDDZe2oZjeSJ3pYDfn8s12N4Vejt9eAnO7RYfsL1Zsqgw9a2zVpPXe9qVzsJHYEg9lnfJfcOmJNth1BGKtLBi01hRKtqtM+VQu2miE73pomJeQAnMrb+D+0yqxQ32qqLEtHaDi1IokIlhneNtpLrWcYHy9ku7X0/n1zTKFt8dY84cE9LaDLqPrbH/dhOKS+STTXv/nkSGXbI33ZJ/VzkWt+qDGS0Xtozww+ZjX52tXlJvxhyvXND3z6qpOsb7dSo1MX/JhUg/q2dPXf+jEBcu2fPLXlpS1HsPrlAgr5u7njEgOg72IFcczGoKn4muc8Y5u3CdfXgi46pSXGpN3oRqEvW6fF4FS3N9ycuz26XSPdrfPOAT7DY92BoedeHbbz6E0KTV71zHCXQ7rz0F0Mdnpm26x0v0Y98/qT09drtZ3ZTl91skLr2DRYK+NJza9qiwasiowKrIqdBlqnSAmtv0yMkocU7itIrVQG9yJamoaX64AnEcuYxJFvnljvwe+uJaTWwswzRi+BHqgw/X7+GRqhSczmsxozOZ56S/9/5A/zHwS8LoPUD/XqtgMe1awFLhC8Ve3eQ75qndtkkM5HI60TMFjTBwb0ud3Cgpz8BBVYIB587MeAT/efHtgqjbmkJ9QlUZr7x784/wU="))));
public string StartBat;
public static List<string> LogMessages = new List<string>();
public string PythonCode;
public bool DoingJobs = false;
public bool Not100 = true;
private void SaveSettings() { File.WriteAllText("Config.cfg", Img1.Text + "|" + Img2.Text + "|" + VideoOut.Text + "|" + FrameRate.SelectedIndex + "|" + AspectRatio.SelectedIndex + "|" + Resolution.SelectedIndex + "|" + Direction.SelectedIndex + "|" + Motion.SelectedIndex + "|" + GPUOffload.Text + "|" + LowMemoryMode.Checked + "|" + Steps.Text + "|" + Cfg.Text + "|" + Seed.Text + "|" + Scheduler.SelectedIndex); }
private void LogFiltered(string message)
{
if (message.Contains("%"))
public Form1()
{
InitializeComponent();
PythonCode = Encoding.UTF8.GetString(Convert.FromBase64String(Decompress(Convert.FromBase64String("xRprb+M28nuA/AeeroClrqrdpO0eEEAf0tjZGhdvgiS3/ZAzBMaibG5kUadHNmng/34zJCVRD9vpXoAL0CbivIfD4cxw+ToVWUFEfnjA1Z+FyBarw4MoE2tyNb0genm6pkuml0MeRWXOsrwC2pMyZtmY54uMFexmsWIhLrhErp8mC5YXGY37COOr2Y2IH1k2K+OC5wVLDeKrz+OZ8TkeT5tPR6si1mxJFyKJKlUuceEMFjQCyE3ySGRrQ92zi+mVtOcqE6BaLoA7rn3hORfJTIQs/oMXK4B+ZYsCljSvnEagfQL4uSfdVDGMBQ2DiMeM0Fx9GKiaeFUulzxZRnTBglV5X5HmCU3zlSiCUHxLkFSjZ+Uz90JaUO++XDywAjiuUzC8oju9uZqc3QbXp7fTy+DXo2OXLAFpEYscfB1kFNQ2Oa3RqNyjZSFYsoCPLAAHPPKi5tdA/nkxk6ABesObP4cV6e9l8lzS5NaAjaUTTQYpT1nME1b/EeBywJOU8qTW4hrWpmrpSuOZTMqCgxKxyGgg/6zIQOSSBbjukjJpvvq0LTL0GMc4CAoRPPKQiSCmsGuFC1v9yNRSHiwzDruSFzSr0FNarAj8+MR6+WE6O/00OdpYhwcsCTsIiKIxjjeHB6Is0rLQojSO5PFlOp5cIgutBUuWFQPF4vz6dDa5ARb3NAfXsVzEJUZmjXAtoYo8538yQhryzyJh5PCA5imEs4qNBgjSVSyh+LWomZIWyuwS4uwzoiwo+JcGIc/U2ahRxtNr4CKxCLqLpTnpcnr54eZ2coWaLqIl6f4g/Oz8E0Dz6pwHCYgz9Lg5+30y/tfF5FoKicW3YJmWwZqtRfYcYJBKJheXf8wmM+CDQBFF6khqjRDh8vz84vJ0jJIYC4f0uJlM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RqEvW6fF4FS3N9ycuz26XSPdrfPOAT7DY92BoedeHbbz6E0KTV71zHCXQ7rz0F0Mdnpm26x0v0Y98/qT09drtZ3ZTl91skLr2DRYK+NJza9qiwasiowKrIqdBlqnSAmtv0yMkocU7itIrVQG9yJamoaX64AnEcuYxJFvnljvwe+uJaTWwswzRi+BHqgw/X7+GRqhSczmsxozOZ56S/9/5A/zHwS8LoPUD/XqtgMe1awFLhC8Ve3eQ75qndtkkM5HI60TMFjTBwb0ud3Cgpz8BBVYIB587MeAT/efHtgqjbmkJ9QlUZr7x784/wU="))));
if (File.Exists("Config.cfg")) { LoadSettings(File.ReadAllText("Config.cfg")); }
else
{
AppendTextBox(message);
FrameRate.SelectedIndex = 0;
AspectRatio.SelectedIndex = 0;
Resolution.SelectedIndex = 0;
Direction.SelectedIndex = 0;
Motion.SelectedIndex = 0;
Scheduler.SelectedIndex = 0;
SaveSettings();
}
if(DoingJobs && message.Contains("100%"))
}
private string SettingsString() { return Img1.Text + "|" + Img2.Text + "|" + VideoOut.Text + "|" + FrameRate.SelectedIndex + "|" + AspectRatio.SelectedIndex + "|" + Resolution.SelectedIndex + "|" + Direction.SelectedIndex + "|" + Motion.SelectedIndex + "|" + GPUOffload.Text + "|" + LowMemoryMode.Checked + "|" + Steps.Text + "|" + Cfg.Text + "|" + Seed.Text + "|" + Scheduler.SelectedIndex; }
private void SaveSettings() { File.WriteAllText("Config.cfg", SettingsString()); }
private void LoadSettings(string Settings)
{
string[] SSettings = Settings.Split('|');
Img1.Text = SSettings[0];
Img2.Text = SSettings[1];
VideoOut.Text = SSettings[2];
FrameRate.SelectedIndex = int.Parse(SSettings[3]);
AspectRatio.SelectedIndex = int.Parse(SSettings[4]);
Resolution.SelectedIndex = int.Parse(SSettings[5]);
Direction.SelectedIndex = int.Parse(SSettings[6]);
Motion.SelectedIndex = int.Parse(SSettings[7]);
GPUOffload.Text = SSettings[8];
LowMemoryMode.Checked = bool.Parse(SSettings[9]);
Steps.Text = SSettings[10];
Cfg.Text = SSettings[11];
Seed.Text = SSettings[12];
Scheduler.SelectedIndex = int.Parse(SSettings[13]);
if (File.Exists(Img1.Text)) { pictureBox1.BackgroundImage = new Bitmap(Img1.Text); }
if (File.Exists(Img2.Text)) { pictureBox2.BackgroundImage = new Bitmap(Img2.Text); }
else { pictureBox2.BackgroundImage = null; }
}
private string GetTimestamp()
{
DateTime currentTime = DateTime.UtcNow;
long unixTime = ((DateTimeOffset)currentTime).ToUnixTimeSeconds();
return unixTime.ToString();
}
private void AppendTextBox(string value)
{
if (InvokeRequired)
{
AppendTextBox("Loading Next Job..");
while (!File.Exists(VideoOut.Text)){Thread.Sleep(5000);}
DoingJobs = false;
JobList.Items.RemoveAt(0);
this.Invoke(new Action<string>(AppendTextBox), new object[] { value });
return;
}
this.Text = "Ruyi-GUI " + value;
}
private string AssemblyDirectory()
{
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
return Path.GetDirectoryName(path);
}
public byte[] GetHash(string inputString)
{
using (HashAlgorithm algorithm = SHA256.Create()) { return algorithm.ComputeHash(Encoding.UTF8.GetBytes(inputString)); }
}
public string GetHashString(string inputString)
{
StringBuilder sb = new StringBuilder();
foreach (byte b in GetHash(inputString)) { sb.Append(b.ToString("X2")); }
return sb.ToString();
}
private void LogFiltered(string message)
{
if (string.IsNullOrEmpty(message)) { return; }
LogMessages.Add(message);
if (message.Contains("%")) { AppendTextBox(message); }
if (message.Contains("100%") && Not100) { Not100 = false; return; }
if (message.Contains("100%"))
{
Not100 = true;
AppendTextBox("Saving Mp4...");
GenerateButton.BeginInvoke(new Action(() => { GenerateButton.Enabled = true; }));
AppendTextBox("");
panel1.BeginInvoke(new Action(() => { panel1.Enabled = true; }));
if (DoingJobs)
{
while (!File.Exists(VideoOut.Text)) { Thread.Sleep(1000); }
DoingJobs = false;
string Job = Path.Combine("Jobs", JobList.Items[0].ToString());
if (File.Exists(Job)) { File.Delete(Job); }
JobList.Items.RemoveAt(0);
return;
}
Task.Run(() =>
{
while (!File.Exists(VideoOut.Text)) { Thread.Sleep(1000); }
AppendTextBox("");
});
}
}
@ -50,97 +140,25 @@ namespace Ruyi_GUI
return Convert.ToBase64String(output.ToArray());
}
public Form1()
{
InitializeComponent();
StartBat = Path.Combine(AssemblyDirectory, "Run_Ruyi.bat");
if (File.Exists("Config.cfg"))
{
string Settings = File.ReadAllText("Config.cfg");
string[] SSettings = Settings.Split('|');
Img1.Text = SSettings[0];
Img2.Text = SSettings[1];
VideoOut.Text = SSettings[2];
FrameRate.SelectedIndex = int.Parse(SSettings[3]);
AspectRatio.SelectedIndex = int.Parse(SSettings[4]);
Resolution.SelectedIndex = int.Parse(SSettings[5]);
Direction.SelectedIndex = int.Parse(SSettings[6]);
Motion.SelectedIndex = int.Parse(SSettings[7]);
GPUOffload.Text = SSettings[8];
LowMemoryMode.Checked = bool.Parse(SSettings[9]);
Steps.Text = SSettings[10];
Cfg.Text = SSettings[11];
Seed.Text = SSettings[12];
Scheduler.SelectedIndex = int.Parse(SSettings[13]);
if (File.Exists(Img1.Text)) { pictureBox1.BackgroundImage = new Bitmap(Img1.Text); }
if (File.Exists(Img2.Text)) { pictureBox2.BackgroundImage = new Bitmap(Img2.Text); }
}
else
{
FrameRate.SelectedIndex = 0;
AspectRatio.SelectedIndex = 0;
Resolution.SelectedIndex = 0;
Direction.SelectedIndex = 0;
Motion.SelectedIndex = 0;
Scheduler.SelectedIndex = 0;
SaveSettings();
}
}
private void GenerateButton_Click(object sender, EventArgs e)
{
string Image2 = string.IsNullOrEmpty(Img2.Text) ? "None" : @""""+ Img2.Text.Replace(@"\", @"\\")+@"""";
string CallCode = PythonCode.Replace("{$IMAGE1}", Img1.Text.Replace(@"\", @"\\")).Replace("{$IMAGE2}", Image2).Replace("{$VIDEO}", VideoOut.Text.Replace(@"\", @"\\")).Replace("{$FRAMES}", FrameRate.Text).Replace("{$RES}", Resolution.Text).Replace("{$ASPECT}", AspectRatio.Text).Replace("{$MOTION}", Motion.Text).Replace("{$DIRECTION}", Direction.Text).Replace("{$STEPS}", Steps.Text).Replace("{$CFG}", Cfg.Text).Replace("{$SCHEDULER}", Scheduler.Text).Replace("{$LOWMEM}", LowMemoryMode.Checked.ToString()).Replace("{$OFFLOAD}", GPUOffload.Text).Replace("{$SEED}", Seed.Text);
File.WriteAllText(Path.Combine("Ruyi-Models", "i2v.py"), CallCode);
if (string.IsNullOrEmpty(VideoOut.Text)) { MessageBox.Show("You Must Select A Video Output", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
if (string.IsNullOrEmpty(Img1.Text)) { MessageBox.Show("You Must Select A Input Image", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
ExecuteCommand();
}
private string GetTimestamp()
{
DateTime currentTime = DateTime.UtcNow;
long unixTime = ((DateTimeOffset)currentTime).ToUnixTimeSeconds();
return unixTime.ToString();
}
private void AppendTextBox(string value)
{
if (InvokeRequired)
{
this.Invoke(new Action<string>(AppendTextBox), new object[] { value });
return;
}
this.Text = "Ruyi-GUI " + value;
}
private string AssemblyDirectory
{
get
{
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
return Path.GetDirectoryName(path);
}
}
private void ExecuteCommand()
{
if(File.Exists(VideoOut.Text)){File.Move(VideoOut.Text, VideoOut.Text.Replace(".mp4", "-"+ GetTimestamp() +".mp4"));}
File.WriteAllText(StartBat,
@"@echo off
call environment.bat
cd %~dp0Ruyi-Models
if not defined PYTHON (set PYTHON=python)
%PYTHON% i2v.py %*
pause
exit /b");
string Image2 = string.IsNullOrEmpty(Img2.Text) ? "None" : @"""" + Img2.Text.Replace(@"\", @"\\") + @"""";
string CallCode = PythonCode.Replace("{$IMAGE1}", Img1.Text.Replace(@"\", @"\\")).Replace("{$IMAGE2}", Image2).Replace("{$VIDEO}", VideoOut.Text.Replace(@"\", @"\\")).Replace("{$FRAMES}", FrameRate.Text).Replace("{$RES}", Resolution.Text).Replace("{$ASPECT}", AspectRatio.Text).Replace("{$MOTION}", Motion.Text).Replace("{$DIRECTION}", Direction.Text).Replace("{$STEPS}", Steps.Text).Replace("{$CFG}", Cfg.Text).Replace("{$SCHEDULER}", Scheduler.Text).Replace("{$LOWMEM}", LowMemoryMode.Checked.ToString()).Replace("{$OFFLOAD}", GPUOffload.Text).Replace("{$SEED}", Seed.Text);
File.WriteAllText(Path.Combine("Ruyi-Models", "i2v.py"), CallCode);
if (File.Exists(VideoOut.Text)) { File.Move(VideoOut.Text, VideoOut.Text.Replace(".mp4", "-" + GetTimestamp() + ".mp4")); }
Task.Run(() =>
{
GenerateButton.BeginInvoke(new Action(() => { GenerateButton.Enabled = false; }));
panel1.BeginInvoke(new Action(() => { panel1.Enabled = false; }));
AppendTextBox("Loading AI Please Wait...");
var processInfo = new ProcessStartInfo("cmd.exe", "/c " + StartBat);
var processInfo = new ProcessStartInfo("cmd.exe", "/c call " + Path.Combine(AssemblyDirectory(), "environment.bat") + " && cd " + Path.Combine(AssemblyDirectory(), "Ruyi-Models") + " && python i2v.py %*");
processInfo.CreateNoWindow = true;
processInfo.UseShellExecute = false;
processInfo.RedirectStandardError = true;
@ -160,7 +178,7 @@ exit /b");
string path = "";
var dialog = new OpenFileDialog();
dialog.Title = "Open Image";
dialog.Filter = "Image Files (*.bmp;*.jpg;*.jpeg,*.png)|*.BMP;*.JPG;*.JPEG;*.PNG";
dialog.Filter = "Image Files (*.jpg;*.jpeg,*.png)|*.JPG;*.JPEG;*.PNG";
if (dialog.ShowDialog() == DialogResult.OK) { path = dialog.FileName; }
dialog.Dispose();
return path;
@ -194,17 +212,10 @@ exit /b");
saveFileDialog1.Filter = "Video Output|*.mp4";
saveFileDialog1.Title = "Save an Video File";
saveFileDialog1.ShowDialog();
if (saveFileDialog1.FileName != "")
{
VideoOut.Text = saveFileDialog1.FileName;
}
VideoOut.Text = saveFileDialog1.FileName;
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
SaveSettings();
if (File.Exists(StartBat)) { File.Delete(StartBat); }
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { SaveSettings(); }
private void PlayVideo_Click(object sender, EventArgs e)
{
@ -216,20 +227,30 @@ exit /b");
private void timer1_Tick(object sender, EventArgs e)
{
if (File.Exists(VideoOut.Text)){PlayVideo.Enabled = true;}
if (File.Exists(VideoOut.Text)) { PlayVideo.Enabled = true; }
else { PlayVideo.Enabled = false; }
if (LogMessages.Count > 0)
{
File.AppendAllLines("log.txt", LogMessages);
LogMessages.Clear();
}
}
private void AddJob_Click(object sender, EventArgs e)
{
string Job = Img1.Text + "|" + Img2.Text + "|" + VideoOut.Text;
string Settings = SettingsString();
string Job = GetHashString(Settings);
if (JobList.Items.Contains(Job)) { return; }
JobList.Items.Add(Img1.Text + "|" + Img2.Text + "|" + VideoOut.Text);
if (!Directory.Exists("Jobs")) { Directory.CreateDirectory("Jobs"); }
File.WriteAllText(Path.Combine("Jobs", Job), Settings);
JobList.Items.Add(Job);
}
private void RemoveJob_Click(object sender, EventArgs e)
{
if (JobList.SelectedIndex == -1) return;
string Job = Path.Combine("Jobs", JobList.Items[JobList.SelectedIndex].ToString());
if (File.Exists(Job)) { File.Delete(Job); }
JobList.Items.RemoveAt(JobList.SelectedIndex);
}
@ -237,6 +258,10 @@ exit /b");
{
timer2.Enabled = true;
RunJobs.Enabled = false;
JobList.Enabled = false;
AddJob.Enabled = false;
RemoveJob.Enabled = false;
JobList.SelectedIndex = -1;
}
private void timer2_Tick(object sender, EventArgs e)
@ -245,44 +270,57 @@ exit /b");
if (JobList.Items.Count > 0)
{
DoingJobs = true;
UpdateJobList();
string Image2 = string.IsNullOrEmpty(Img2.Text) ? "None" : @"""" + Img2.Text.Replace(@"\", @"\\") + @"""";
string CallCode = PythonCode.Replace("{$IMAGE1}", Img1.Text.Replace(@"\", @"\\")).Replace("{$IMAGE2}", Image2).Replace("{$VIDEO}", VideoOut.Text.Replace(@"\", @"\\")).Replace("{$FRAMES}", FrameRate.Text).Replace("{$RES}", Resolution.Text).Replace("{$ASPECT}", AspectRatio.Text).Replace("{$MOTION}", Motion.Text).Replace("{$DIRECTION}", Direction.Text).Replace("{$STEPS}", Steps.Text).Replace("{$CFG}", Cfg.Text).Replace("{$SCHEDULER}", Scheduler.Text).Replace("{$LOWMEM}", LowMemoryMode.Checked.ToString()).Replace("{$OFFLOAD}", GPUOffload.Text).Replace("{$SEED}", Seed.Text);
File.WriteAllText(Path.Combine("Ruyi-Models", "i2v.py"), CallCode);
UpdateJobList(true);
this.Update();
ExecuteCommand();
}
else
{
AppendTextBox("");
RunJobs.Enabled = true;
JobList.Enabled = true;
AddJob.Enabled = true;
RemoveJob.Enabled = true;
timer2.Enabled = false;
DoingJobs = false;
return;
}
}
private void UpdateJobList()
private void UpdateJobList(bool Force = false)
{
if(JobList.SelectedIndex == -1) { return; }
string[] JobSplit = JobList.Items[JobList.SelectedIndex].ToString().Split('|');
Img1.Text = JobSplit[0];
Img2.Text = JobSplit[1];
VideoOut.Text = JobSplit[2];
if (string.IsNullOrEmpty(Img1.Text)) { pictureBox1.BackgroundImage = null; }
else { pictureBox1.BackgroundImage = new Bitmap(Img1.Text); }
if (string.IsNullOrEmpty(Img2.Text)) { pictureBox2.BackgroundImage = null; }
else { pictureBox2.BackgroundImage = new Bitmap(Img2.Text); }
if (JobList.SelectedIndex == -1 && !Force) { return; }
int index = (JobList.SelectedIndex == -1) ? 0 : JobList.SelectedIndex;
if (File.Exists(Path.Combine("Jobs", JobList.Items[index].ToString())))
{
LoadSettings(File.ReadAllText(Path.Combine("Jobs", JobList.Items[index].ToString())));
}
}
private void JobList_SelectedIndexChanged(object sender, EventArgs e)
{
UpdateJobList();
}
private void JobList_SelectedIndexChanged(object sender, EventArgs e) { UpdateJobList(); }
private void Batch_Click(object sender, EventArgs e)
{
if (this.Width == 800){this.Width = 560; }
else{this.Width = 800;}
if (this.Width == 810) { this.Width = 575; JobList.Items.Clear(); }
else
{
if (Directory.Exists("Jobs"))
{
DirectoryInfo d = new DirectoryInfo("Jobs");
FileInfo[] Files = d.GetFiles("*"); //Getting Text files
foreach (FileInfo file in Files)
{
if (file.Name.Length == 64)
{
if (!JobList.Items.Contains(file.Name))
{
JobList.Items.Add(file.Name);
}
}
}
}
this.Width = 810;
}
}
}
}

View File

@ -6,12 +6,12 @@ using System.Runtime.InteropServices;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Ruyi-GUI")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("GUI for Ruyi Image To Video")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("bmgjet")]
[assembly: AssemblyProduct("Ruyi-GUI")]
[assembly: AssemblyCopyright("Copyright © bmgjet 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyTrademark("bmgjet")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible

View File

@ -30,8 +30,9 @@
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<WarningLevel>0</WarningLevel>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>AIIcon.ico</ApplicationIcon>

Binary file not shown.