This repository has been archived by the owner on Nov 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Program.cs
47 lines (44 loc) · 2.03 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Diagnostics;
using System.IO;
using CamXucMLML.Model;
/* Designed and developed by Nguyen Trung Nhan
* Contact: [email protected]
* Based on ML.NET sample at https://github.com/dotnet/machinelearning-samples/blob/master/README.md
* My git: https://github.com/nhannt201
*/
namespace CamXucML
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Machine Learning - My picture!");
Console.WriteLine("Import photos from folder...");
string[] fileArray = Directory.GetFiles(@"C:\Users\lenovo\Desktop\Scan\");
for (int i = 0; i < fileArray.Length; i++)
{
string filename = null;
// using the method
filename = Path.GetFileName(fileArray[i]);
// Add input data
// Console.ForegroundColor = ConsoleColor.Yellow;
var input = new ModelInput();
input.ImageSource = fileArray[i];
// Load model and predict output of sample data
ModelOutput result = ConsumeModel.Predict(input);
string datac = String.Join(",", result.Score) ;
string[] words = datac.Split(',');
Console.WriteLine($"-------------- {result.Prediction} - {filename} Diem: " + datac);
string destinationFile = @"C:\Users\lenovo\Desktop\Result\" + result.Prediction + @"\" + filename;
// To move a file or folder to a new location:
System.IO.File.Copy(fileArray[i], destinationFile);
Console.WriteLine("--------------------- Copy a image to " + result.Prediction + @" - C:\Users\lenovo\Desktop\Result\" + result.Prediction);
// Console.WriteLine(@"C:\Users\lenovo\Desktop\Result\" + result.Prediction);
Console.WriteLine("------>Next Scan<------------------");
}
Console.WriteLine("Scanned!");
Console.ReadKey();
}
}
}