-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Canming Huang
committed
Jun 23, 2023
1 parent
000b0e2
commit d54e8bf
Showing
29 changed files
with
1,006 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Tensorflow; | ||
//using Xamarin.Forms; | ||
|
||
|
||
namespace Emgu.TF.Maui.Demo | ||
{ | ||
public class AboutPage : ContentPage | ||
{ | ||
/// <summary> | ||
/// Create and run a simple graph that add two numbers and returns the default session devices used. | ||
/// </summary> | ||
/// <returns></returns> | ||
private static Session.Device[] GetSessionDevices() | ||
{ | ||
SessionOptions so = new SessionOptions(); | ||
if (TfInvoke.IsGoogleCudaEnabled) | ||
{ | ||
Tensorflow.ConfigProto config = new Tensorflow.ConfigProto(); | ||
config.GpuOptions = new Tensorflow.GPUOptions(); | ||
config.GpuOptions.AllowGrowth = true; | ||
so.SetConfig(config.ToProtobuf()); | ||
} | ||
int a = 1; | ||
int b = 1; | ||
//Creating tensor from value a | ||
Tensor tensorA = new Tensor(a); | ||
//Creating tensor from value b | ||
Tensor tensorB = new Tensor(b); | ||
//Create a new graph | ||
Graph graph = new Graph(); | ||
//Place holder in the graph for tensorA | ||
Operation opA = graph.Placeholder(DataType.Int32, null, "valA"); | ||
//Place holder in the graph for tensorB | ||
Operation opB = graph.Placeholder(DataType.Int32, null, "valB"); | ||
//Adding the two tensor | ||
Operation sumOp = graph.Add(opA, opB, "sum"); | ||
|
||
//Create a new session | ||
using (Session session = new Session(graph, so)) | ||
{ | ||
//Execute the session and get the sum | ||
Tensor[] results = session.Run(new Output[] { opA, opB }, new Tensor[] { tensorA, tensorB }, | ||
new Output[] { sumOp }); | ||
|
||
Session.Device[] devices = session.ListDevices(null); | ||
return devices; | ||
} | ||
} | ||
|
||
public AboutPage() | ||
{ | ||
using (LogListenerSink logSink = new LogListenerSink(true)) | ||
{ | ||
Session.Device[] devices = GetSessionDevices(); | ||
StringBuilder sb = new StringBuilder(); | ||
foreach (Session.Device d in devices) | ||
{ | ||
sb.Append(String.Format("<H4 style=\"color: blue;\">{1}: {0}</H4>", d.Name, d.Type)); | ||
} | ||
|
||
String tensorflowVer = TfInvoke.Version; | ||
|
||
Title = "About Emgu TF"; | ||
Content = new WebView() | ||
{ | ||
WidthRequest = 400, | ||
HeightRequest = 1000, | ||
Source = new HtmlWebViewSource() | ||
{ | ||
Html = String.Format( | ||
@"<html> | ||
<head> | ||
<style>body {{ background-color: #EEEEEE; }}</style> | ||
<style type=""text/css""> | ||
textarea {{ width: 100%; margin: 0; padding: 0; border - width: 0; }} | ||
</style> | ||
</head> | ||
<body> | ||
<H1> Emgu TF Demos </H1> | ||
<H3> Tensorflow version: {0} </H3> | ||
<H3> OS: {1} </H3> | ||
<H3> Framework: {2} </H3> | ||
<H3> Processor: {3} </H3> | ||
<H3> Default Session Devices: </H3> {4} | ||
<H3> Tensorflow <a href=https://github.com/tensorflow/tensorflow/blob/master/LICENSE > License</a> </H3> | ||
<H3><a href=http://www.emgu.com/wiki/index.php/Emgu_TF >Visit our website</a> <br/><br/><H3> | ||
<H3><a href=mailto:support@emgu.com>Email Support</a> <br/><br/><H3> | ||
<H3> IsGoogleCudaEnabled: {5} </H3> | ||
<H3> IsBuiltWithROCm: {6} </H3> | ||
<H3> IsBuiltWithNvcc: {7} </H3> | ||
<H3> GpuSupportsHalfMatMulAndConv: {8} </H3> | ||
<H3> IsMklEnabled: {9} </H3> | ||
<H4> Log: </H4> | ||
<textarea rows=""30"">{10}</textarea>" | ||
+ @" | ||
</body> | ||
</html>", | ||
tensorflowVer, | ||
System.Runtime.InteropServices.RuntimeInformation.OSDescription, | ||
System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription, | ||
System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture, | ||
sb.ToString(), | ||
TfInvoke.IsGoogleCudaEnabled, | ||
TfInvoke.IsBuiltWithROCm, | ||
TfInvoke.IsBuiltWithNvcc, | ||
TfInvoke.GpuSupportsHalfMatMulAndConv, | ||
TfInvoke.IsMklEnabled, | ||
logSink.GetLog() | ||
) | ||
} | ||
}; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace Maui | ||
namespace Emgu.TF.Maui.Demo | ||
{ | ||
public partial class AppShell : Shell | ||
{ | ||
|
Oops, something went wrong.