Skip to content

Commit

Permalink
Patch 20240708a1
Browse files Browse the repository at this point in the history
Support LSTM Text Generation Model (PyTorch)
Fix result tab:
+ Remove test model (pipeline is not available for this project type)
+ Change model file to result folder
  • Loading branch information
EndermanPC committed Jul 8, 2024
1 parent 8562805 commit 33463cb
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 64 deletions.
33 changes: 29 additions & 4 deletions Create.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,23 @@ private async Task InstallPackageDependencies(string language)
switch (language)
{
case "Python (Tensorflow)":
packageRequirements.Add(CheckForDiscreteGPU() ? "tensorflow" : "tensorflow");
packageRequirements.Add(CheckForDiscreteGPU() ? "tensorflow-gpu" : "tensorflow");

if (comboBox1.Text == "Text generation (RNN)")
{
packageRequirements.Add("numpy");
await DownloadFilesForRNN(textBox1.Text);
await DownloadFilesForTGRNN(textBox1.Text);
}
break;

case "Python (PyTorch)":
packageRequirements.Add("torch");

if (textBox1.Text == "Text generation (LSTM)")
{
packageRequirements.Add("numpy");
await DownloadFilesForTGLSTM(textBox1.Text);
}
break;
}
await UpdateProgressBarAsync(35);
Expand All @@ -143,7 +149,7 @@ private async Task InstallPackageDependencies(string language)
await UpdateProgressBarAsync(50);
}

private async Task DownloadFilesForRNN(string projectPath)
private async Task DownloadFilesForTGRNN(string projectPath)
{
using (var client = new WebClient())
{
Expand All @@ -162,6 +168,25 @@ private async Task DownloadFilesForRNN(string projectPath)
}
}

private async Task DownloadFilesForTGLSTM(string projectPath)
{
using (var client = new WebClient())
{
try
{
var baseUri = "https://raw.githubusercontent.com/Lithicsoft/Lithicsoft-Trainer-Studio/main/lstm_text_generation/";
await client.DownloadFileTaskAsync(new Uri(baseUri + "trainer.py"), $"projects\\{projectPath}\\trainer.py");
await client.DownloadFileTaskAsync(new Uri(baseUri + ".env"), $"projects\\{projectPath}\\.env");
await UpdateProgressBarAsync(20);
}
catch (WebException ex)
{
MessageBox.Show($"Error downloading file: {ex.Message}", "Exception Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(1);
}
}
}

private void textBox1_TextChanged(object sender, EventArgs e)
{
if (textBox1.Text.Length > 0 && comboBox1.Text.Length > 0 && comboBox2.Text.Length > 0)
Expand Down Expand Up @@ -196,7 +221,7 @@ private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
}
else if (comboBox2.Text == "Python (PyTorch)")
{
comboBox1.Items.AddRange(["Text generation"]);
comboBox1.Items.AddRange(["Text generation (LSTM)"]);
}
else if (comboBox2.Text == "Python (Tensorflow)")
{
Expand Down
47 changes: 5 additions & 42 deletions Python.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 3 additions & 16 deletions Python.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ public Python(string name, string language, string type)
projectName = name;
label1.Text = $"{type} with {language}";

if (Directory.Exists($"projects\\{projectName}\\model"))
{
textBox2.Text = $"projects\\{projectName}\\model";
}
textBox2.Text = $"projects\\{projectName}";

trainParameters = DotEnv.Load($"projects\\{projectName}\\.env");
listView1.View = View.Details;
Expand Down Expand Up @@ -160,6 +157,8 @@ await Task.Run(() =>
{
MessageBox.Show($"Error training model: {ex.Message}", "Exception Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}

textBox2.Text = $"projects\\{projectName}";
button3.Enabled = true;
}

Expand Down Expand Up @@ -230,18 +229,6 @@ private void button5_Click(object sender, EventArgs e)
}
}

private void textBox4_TextChanged(object sender, EventArgs e)
{
if (textBox4.Text.Length > 0)
{
button6.Enabled = true;
}
else
{
button6.Enabled = false;
}
}

private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listView1.SelectedItems.Count > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[assembly: System.Reflection.AssemblyCompanyAttribute("Lithicsoft Trainer Studio")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+4b53c44cdd402e0cd2955ebed05599f3988fc34e")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+8562805c7a99d4a44f355d67b61eabb6a223c099")]
[assembly: System.Reflection.AssemblyProductAttribute("Lithicsoft Trainer Studio")]
[assembly: System.Reflection.AssemblyTitleAttribute("Lithicsoft Trainer Studio")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
db032ac3aa1a6f6390f5d57811a8d4160a9a54be789895012f815c01332c81c5
775123c45f918709ae8514842fbdca02b15f0e0657ca360315273dd4fa094d29

0 comments on commit 33463cb

Please sign in to comment.