From ffaa2273b9f47eef1edd953559668bed43c5bfee Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Mon, 2 Dec 2024 20:07:55 +0100 Subject: [PATCH] improve logger --- .../java/ai/nets/samj/communication/model/EfficientSAM.java | 4 +--- .../ai/nets/samj/communication/model/EfficientViTSAML0.java | 4 +--- .../ai/nets/samj/communication/model/EfficientViTSAML1.java | 4 +--- .../ai/nets/samj/communication/model/EfficientViTSAML2.java | 4 +--- .../ai/nets/samj/communication/model/EfficientViTSAMXL0.java | 4 +--- .../ai/nets/samj/communication/model/EfficientViTSAMXL1.java | 4 +--- src/main/java/ai/nets/samj/communication/model/SAM2Large.java | 4 +--- src/main/java/ai/nets/samj/communication/model/SAM2Small.java | 4 +--- src/main/java/ai/nets/samj/communication/model/SAM2Tiny.java | 4 +--- 9 files changed, 9 insertions(+), 27 deletions(-) diff --git a/src/main/java/ai/nets/samj/communication/model/EfficientSAM.java b/src/main/java/ai/nets/samj/communication/model/EfficientSAM.java index c6e8691..cab309d 100644 --- a/src/main/java/ai/nets/samj/communication/model/EfficientSAM.java +++ b/src/main/java/ai/nets/samj/communication/model/EfficientSAM.java @@ -119,9 +119,7 @@ public & NativeType> void setImage(final RandomAccessi AbstractSamJ.DebugTextPrinter filteringLogger = text -> { int idx = text.indexOf("\"responseType\": \"COMPLETION\""); int idxProgress = text.indexOf(AbstractSamJ.getProgressString()); - if (idx > 0) - text = text.substring(0,idx) + "\"responseType\": \"COMPLETION\"}"; - if (idxProgress != -1) { + if (idx > 0 || idxProgress != -1) { String regex = "\"outputs\"\\s*:\\s*\\{.*?\\},"; Pattern pattern = Pattern.compile(regex, Pattern.DOTALL); Matcher matcher = pattern.matcher(text); diff --git a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML0.java b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML0.java index 5ab4aad..c86b0a7 100644 --- a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML0.java +++ b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML0.java @@ -91,9 +91,7 @@ public & NativeType> void setImage(final RandomAccessi AbstractSamJ.DebugTextPrinter filteringLogger = text -> { int idx = text.indexOf("\"responseType\": \"COMPLETION\""); int idxProgress = text.indexOf(AbstractSamJ.getProgressString()); - if (idx > 0) - text = text.substring(0,idx) + "\"responseType\": \"COMPLETION\"}"; - if (idxProgress != -1) { + if (idx > 0 || idxProgress != -1) { String regex = "\"outputs\"\\s*:\\s*\\{.*?\\},"; Pattern pattern = Pattern.compile(regex, Pattern.DOTALL); Matcher matcher = pattern.matcher(text); diff --git a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML1.java b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML1.java index 49305aa..93b8f91 100644 --- a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML1.java +++ b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML1.java @@ -89,9 +89,7 @@ public & NativeType> void setImage(final RandomAccessi AbstractSamJ.DebugTextPrinter filteringLogger = text -> { int idx = text.indexOf("\"responseType\": \"COMPLETION\""); int idxProgress = text.indexOf(AbstractSamJ.getProgressString()); - if (idx > 0) - text = text.substring(0,idx) + "\"responseType\": \"COMPLETION\"}"; - if (idxProgress != -1) { + if (idx > 0 || idxProgress != -1) { String regex = "\"outputs\"\\s*:\\s*\\{.*?\\},"; Pattern pattern = Pattern.compile(regex, Pattern.DOTALL); Matcher matcher = pattern.matcher(text); diff --git a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML2.java b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML2.java index 6ea7fe1..d8c7ab9 100644 --- a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML2.java +++ b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML2.java @@ -89,9 +89,7 @@ public & NativeType> void setImage(final RandomAccessi AbstractSamJ.DebugTextPrinter filteringLogger = text -> { int idx = text.indexOf("\"responseType\": \"COMPLETION\""); int idxProgress = text.indexOf(AbstractSamJ.getProgressString()); - if (idx > 0) - text = text.substring(0,idx) + "\"responseType\": \"COMPLETION\"}"; - if (idxProgress != -1) { + if (idx > 0 || idxProgress != -1) { String regex = "\"outputs\"\\s*:\\s*\\{.*?\\},"; Pattern pattern = Pattern.compile(regex, Pattern.DOTALL); Matcher matcher = pattern.matcher(text); diff --git a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAMXL0.java b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAMXL0.java index 1f332ac..01e4034 100644 --- a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAMXL0.java +++ b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAMXL0.java @@ -88,9 +88,7 @@ public & NativeType> void setImage(final RandomAccessi AbstractSamJ.DebugTextPrinter filteringLogger = text -> { int idx = text.indexOf("\"responseType\": \"COMPLETION\""); int idxProgress = text.indexOf(AbstractSamJ.getProgressString()); - if (idx > 0) - text = text.substring(0,idx) + "\"responseType\": \"COMPLETION\"}"; - if (idxProgress != -1) { + if (idx > 0 || idxProgress != -1) { String regex = "\"outputs\"\\s*:\\s*\\{.*?\\},"; Pattern pattern = Pattern.compile(regex, Pattern.DOTALL); Matcher matcher = pattern.matcher(text); diff --git a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAMXL1.java b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAMXL1.java index a2009f6..054899c 100644 --- a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAMXL1.java +++ b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAMXL1.java @@ -90,9 +90,7 @@ public & NativeType> void setImage(final RandomAccessi AbstractSamJ.DebugTextPrinter filteringLogger = text -> { int idx = text.indexOf("\"responseType\": \"COMPLETION\""); int idxProgress = text.indexOf(AbstractSamJ.getProgressString()); - if (idx > 0) - text = text.substring(0,idx) + "\"responseType\": \"COMPLETION\"}"; - if (idxProgress != -1) { + if (idx > 0 || idxProgress != -1) { String regex = "\"outputs\"\\s*:\\s*\\{.*?\\},"; Pattern pattern = Pattern.compile(regex, Pattern.DOTALL); Matcher matcher = pattern.matcher(text); diff --git a/src/main/java/ai/nets/samj/communication/model/SAM2Large.java b/src/main/java/ai/nets/samj/communication/model/SAM2Large.java index 5d3cd82..70c0730 100644 --- a/src/main/java/ai/nets/samj/communication/model/SAM2Large.java +++ b/src/main/java/ai/nets/samj/communication/model/SAM2Large.java @@ -87,9 +87,7 @@ public & NativeType> void setImage(final RandomAccessi AbstractSamJ.DebugTextPrinter filteringLogger = text -> { int idx = text.indexOf("\"responseType\": \"COMPLETION\""); int idxProgress = text.indexOf(AbstractSamJ.getProgressString()); - if (idx > 0) - text = text.substring(0,idx) + "\"responseType\": \"COMPLETION\"}"; - if (idxProgress != -1) { + if (idx > 0 || idxProgress != -1) { String regex = "\"outputs\"\\s*:\\s*\\{.*?\\},"; Pattern pattern = Pattern.compile(regex, Pattern.DOTALL); Matcher matcher = pattern.matcher(text); diff --git a/src/main/java/ai/nets/samj/communication/model/SAM2Small.java b/src/main/java/ai/nets/samj/communication/model/SAM2Small.java index fe6e2e8..536eb27 100644 --- a/src/main/java/ai/nets/samj/communication/model/SAM2Small.java +++ b/src/main/java/ai/nets/samj/communication/model/SAM2Small.java @@ -89,9 +89,7 @@ public & NativeType> void setImage(final RandomAccessi AbstractSamJ.DebugTextPrinter filteringLogger = text -> { int idx = text.indexOf("\"responseType\": \"COMPLETION\""); int idxProgress = text.indexOf(AbstractSamJ.getProgressString()); - if (idx > 0) - text = text.substring(0,idx) + "\"responseType\": \"COMPLETION\"}"; - if (idxProgress != -1) { + if (idx > 0 || idxProgress != -1) { String regex = "\"outputs\"\\s*:\\s*\\{.*?\\},"; Pattern pattern = Pattern.compile(regex, Pattern.DOTALL); Matcher matcher = pattern.matcher(text); diff --git a/src/main/java/ai/nets/samj/communication/model/SAM2Tiny.java b/src/main/java/ai/nets/samj/communication/model/SAM2Tiny.java index 60dd89d..f964476 100644 --- a/src/main/java/ai/nets/samj/communication/model/SAM2Tiny.java +++ b/src/main/java/ai/nets/samj/communication/model/SAM2Tiny.java @@ -86,9 +86,7 @@ public & NativeType> void setImage(final RandomAccessi AbstractSamJ.DebugTextPrinter filteringLogger = text -> { int idx = text.indexOf("\"responseType\": \"COMPLETION\""); int idxProgress = text.indexOf(AbstractSamJ.getProgressString()); - if (idx > 0) - text = text.substring(0,idx) + "\"responseType\": \"COMPLETION\"}"; - if (idxProgress != -1) { + if (idx > 0 || idxProgress != -1) { String regex = "\"outputs\"\\s*:\\s*\\{.*?\\},"; Pattern pattern = Pattern.compile(regex, Pattern.DOTALL); Matcher matcher = pattern.matcher(text);