From 284fa7c707d3303e449d49a3d1906e7295c2fecf Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 3 Dec 2024 01:34:08 +0100 Subject: [PATCH] decide better what to print --- .../java/ai/nets/samj/communication/model/EfficientSAM.java | 5 +++-- .../ai/nets/samj/communication/model/EfficientViTSAML0.java | 5 +++-- .../ai/nets/samj/communication/model/EfficientViTSAML1.java | 5 +++-- .../ai/nets/samj/communication/model/EfficientViTSAML2.java | 5 +++-- .../ai/nets/samj/communication/model/EfficientViTSAMXL0.java | 5 +++-- .../ai/nets/samj/communication/model/EfficientViTSAMXL1.java | 5 +++-- .../java/ai/nets/samj/communication/model/SAM2Large.java | 5 +++-- .../java/ai/nets/samj/communication/model/SAM2Small.java | 5 +++-- src/main/java/ai/nets/samj/communication/model/SAM2Tiny.java | 5 +++-- 9 files changed, 27 insertions(+), 18 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 cab309d..0264518 100644 --- a/src/main/java/ai/nets/samj/communication/model/EfficientSAM.java +++ b/src/main/java/ai/nets/samj/communication/model/EfficientSAM.java @@ -119,8 +119,9 @@ 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 || idxProgress != -1) { - String regex = "\"outputs\"\\s*:\\s*\\{.*?\\},"; + if (idxProgress != -1) return; + if (idx > 0) { + String regex = "\"outputs\"\\s*:\\s*\\{.*?\\}(,)?"; Pattern pattern = Pattern.compile(regex, Pattern.DOTALL); Matcher matcher = pattern.matcher(text); text = matcher.replaceAll(""); 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 c86b0a7..b131d75 100644 --- a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML0.java +++ b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML0.java @@ -91,8 +91,9 @@ 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 || idxProgress != -1) { - String regex = "\"outputs\"\\s*:\\s*\\{.*?\\},"; + if (idxProgress != -1) return; + if (idx > 0) { + String regex = "\"outputs\"\\s*:\\s*\\{.*?\\}(,)?"; Pattern pattern = Pattern.compile(regex, Pattern.DOTALL); Matcher matcher = pattern.matcher(text); text = matcher.replaceAll(""); 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 93b8f91..cdd3938 100644 --- a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML1.java +++ b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML1.java @@ -89,8 +89,9 @@ 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 || idxProgress != -1) { - String regex = "\"outputs\"\\s*:\\s*\\{.*?\\},"; + if (idxProgress != -1) return; + if (idx > 0) { + String regex = "\"outputs\"\\s*:\\s*\\{.*?\\}(,)?"; Pattern pattern = Pattern.compile(regex, Pattern.DOTALL); Matcher matcher = pattern.matcher(text); text = matcher.replaceAll(""); 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 d8c7ab9..956b721 100644 --- a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML2.java +++ b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAML2.java @@ -89,8 +89,9 @@ 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 || idxProgress != -1) { - String regex = "\"outputs\"\\s*:\\s*\\{.*?\\},"; + if (idxProgress != -1) return; + if (idx > 0) { + String regex = "\"outputs\"\\s*:\\s*\\{.*?\\}(,)?"; Pattern pattern = Pattern.compile(regex, Pattern.DOTALL); Matcher matcher = pattern.matcher(text); text = matcher.replaceAll(""); 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 01e4034..ac7863b 100644 --- a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAMXL0.java +++ b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAMXL0.java @@ -88,8 +88,9 @@ 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 || idxProgress != -1) { - String regex = "\"outputs\"\\s*:\\s*\\{.*?\\},"; + if (idxProgress != -1) return; + if (idx > 0) { + String regex = "\"outputs\"\\s*:\\s*\\{.*?\\}(,)?"; Pattern pattern = Pattern.compile(regex, Pattern.DOTALL); Matcher matcher = pattern.matcher(text); text = matcher.replaceAll(""); 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 054899c..7a293f2 100644 --- a/src/main/java/ai/nets/samj/communication/model/EfficientViTSAMXL1.java +++ b/src/main/java/ai/nets/samj/communication/model/EfficientViTSAMXL1.java @@ -90,8 +90,9 @@ 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 || idxProgress != -1) { - String regex = "\"outputs\"\\s*:\\s*\\{.*?\\},"; + if (idxProgress != -1) return; + if (idx > 0) { + String regex = "\"outputs\"\\s*:\\s*\\{.*?\\}(,)?"; Pattern pattern = Pattern.compile(regex, Pattern.DOTALL); Matcher matcher = pattern.matcher(text); text = matcher.replaceAll(""); 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 70c0730..fd33b98 100644 --- a/src/main/java/ai/nets/samj/communication/model/SAM2Large.java +++ b/src/main/java/ai/nets/samj/communication/model/SAM2Large.java @@ -87,8 +87,9 @@ 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 || idxProgress != -1) { - String regex = "\"outputs\"\\s*:\\s*\\{.*?\\},"; + if (idxProgress != -1) return; + if (idx > 0) { + String regex = "\"outputs\"\\s*:\\s*\\{.*?\\}(,)?"; Pattern pattern = Pattern.compile(regex, Pattern.DOTALL); Matcher matcher = pattern.matcher(text); text = matcher.replaceAll(""); 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 536eb27..8d6d309 100644 --- a/src/main/java/ai/nets/samj/communication/model/SAM2Small.java +++ b/src/main/java/ai/nets/samj/communication/model/SAM2Small.java @@ -89,8 +89,9 @@ 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 || idxProgress != -1) { - String regex = "\"outputs\"\\s*:\\s*\\{.*?\\},"; + if (idxProgress != -1) return; + if (idx > 0) { + String regex = "\"outputs\"\\s*:\\s*\\{.*?\\}(,)?"; Pattern pattern = Pattern.compile(regex, Pattern.DOTALL); Matcher matcher = pattern.matcher(text); text = matcher.replaceAll(""); 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 f964476..5582b67 100644 --- a/src/main/java/ai/nets/samj/communication/model/SAM2Tiny.java +++ b/src/main/java/ai/nets/samj/communication/model/SAM2Tiny.java @@ -86,8 +86,9 @@ 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 || idxProgress != -1) { - String regex = "\"outputs\"\\s*:\\s*\\{.*?\\},"; + if (idxProgress != -1) return; + if (idx > 0) { + String regex = "\"outputs\"\\s*:\\s*\\{.*?\\}(,)?"; Pattern pattern = Pattern.compile(regex, Pattern.DOTALL); Matcher matcher = pattern.matcher(text); text = matcher.replaceAll("");