Skip to content

Commit

Permalink
Update SAM.cs
Browse files Browse the repository at this point in the history
memory optimization
  • Loading branch information
AIDajiangtang committed Sep 8, 2023
1 parent 493a9f6 commit 69256bf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions SAM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,26 @@ public void LoadONNXModel()
if (this.mDecoder != null)
this.mDecoder.Dispose();

var options = new SessionOptions();
options.EnableMemoryPattern = false;
options.EnableCpuMemArena = false;

string exePath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string encode_model_path = exePath + @"\encoder-quant.onnx";
if (!File.Exists(encode_model_path))
{
MessageBox.Show(encode_model_path + " not exist!");
return;
}
this.mEncoder = new InferenceSession(encode_model_path);
this.mEncoder = new InferenceSession(encode_model_path, options);

string decode_model_path = exePath + @"\decoder-quant.onnx";
if (!File.Exists(decode_model_path))
{
MessageBox.Show(decode_model_path + " not exist!");
return;
}
this.mDecoder = new InferenceSession(decode_model_path);
this.mDecoder = new InferenceSession(decode_model_path, options);
}
/// <summary>
/// Segment Anything对图像进行编码
Expand Down

0 comments on commit 69256bf

Please sign in to comment.