Skip to content

Commit c0939a5

Browse files
authored
Merge pull request #123 from sdcb/pr-120
merge BaseModel into SegModel
2 parents 984b485 + 66ba64a commit c0939a5

File tree

3 files changed

+25
-31
lines changed

3 files changed

+25
-31
lines changed

src/Sdcb.PaddleSeg/BaseModel.cs

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/Sdcb.PaddleSeg/SegModel.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,32 @@
22

33
namespace Sdcb.PaddleSeg
44
{
5-
public abstract class SegModel : BaseModel
5+
public abstract class SegModel
66
{
7+
/// <summary>
8+
/// Create the paddle config for the model.
9+
/// </summary>
10+
/// <returns>The paddle config for model.</returns>
11+
public abstract PaddleConfig CreateConfig();
12+
13+
/// <summary>
14+
/// Configure the device related config of the <see cref="PaddleConfig"/>.
15+
/// </summary>
16+
/// <param name="configure">The device and configure of the <see cref="PaddleConfig"/>, pass null to using model's <see cref="DefaultDevice"/>.</param>
17+
/// <param name="config">The PaddleConfig to modify.</param>
18+
public virtual void ConfigureDevice(PaddleConfig config, Action<PaddleConfig>? configure = null)
19+
{
20+
config.Apply(configure ?? DefaultDevice);
21+
}
22+
23+
/// <summary>
24+
/// Create a <see cref="SegModel"/> from the directory path.
25+
/// </summary>
726
public static SegModel FromDirectory(string directoryPath) => new FileSegModel(directoryPath);
827

9-
public override Action<PaddleConfig> DefaultDevice => PaddleDevice.Mkldnn();
28+
/// <summary>
29+
/// Default device configuration for the model.
30+
/// </summary>
31+
public virtual Action<PaddleConfig> DefaultDevice => PaddleDevice.Mkldnn();
1032
}
1133
}

tests/Sdcb.PaddleOCR.Tests/TableTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void LocalV3TableTest(string modelName)
2626
[Theory]
2727
[InlineData("en_ppstructure_mobile_v2.0_SLANet", "<table><thead><tr><td>Methods</td>")]
2828
[InlineData("ch_ppstructure_mobile_v2.0_SLANet", "<table><tbody><tr><td>Methods</td>")]
29-
public async void LocalV3TableRebuild(string modelName, string expectedHtmlStart)
29+
public async Task LocalV3TableRebuild(string modelName, string expectedHtmlStart)
3030
{
3131
using Mat src = Cv2.ImRead("samples/table.jpg");
3232
Task<TableDetectionResult> tableResultTask = Task.Run(() =>

0 commit comments

Comments
 (0)