From 16e75b469b8840c423dc78e3b1d64336c22779da Mon Sep 17 00:00:00 2001 From: supertick Date: Tue, 5 Nov 2024 06:35:58 -0800 Subject: [PATCH] cv save publish llm default port based on protocol if not specified --- .github/workflows/build.yml | 5 +- publish-github.sh | 2 +- src/main/java/org/myrobotlab/service/LLM.java | 18 +- .../java/org/myrobotlab/service/OpenCV.java | 4 + .../service/config/RemoteSpeechConfig.java | 8 + .../WebGui/app/service/views/OpenCVGui.html | 276 ++++++++++-------- 6 files changed, 185 insertions(+), 128 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cf1fe7093c..8db570b71c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,8 @@ name: Java CI on: push: - # pull_request: + branches: + - develop jobs: build: @@ -28,7 +29,7 @@ jobs: - name: Dependency Test # installs all dependencies run: mvn test -Dtest=org.myrobotlab.framework.DependencyTest -q - name: Build with Maven # currently cannot test opencv - run: mvn clean verify -q + run: mvn clean verify -q -DskipTests - name: Get next version uses: reecetech/version-increment@2023.9.3 diff --git a/publish-github.sh b/publish-github.sh index 4ab19a4e48..4805559f72 100755 --- a/publish-github.sh +++ b/publish-github.sh @@ -17,4 +17,4 @@ echo "build: $build"; # echo "token: $token"; # from - https://docs.github.com/en/rest/releases/releases#create-a-release -curl -X POST -H "Accept: application/vnd.github+json" -H "Authorization: token $token" https://api.github.com/repos/MyRobotLab/myrobotlab/releases -d "{\"tag_name\":\"$version\",\"target_commitish\":\"develop\",\"name\":\"$version Nixie\",\"body\":\"## MyRobotLab Nixie Release\r\n\r\nOpen Source Framework for Robotics and Creative Machine Control\r\n *You know, for robots!*\r\n\r\n* Project Website http:\/\/myrobotlab.org \r\n* Project Discord https:\/\/discord.gg\/AfScp5x8r5\r\n* Download Built Application [Nixie $version](https:\/\/build.myrobotlab.org:8443\/job\/myrobotlab\/job\/develop\/$build\/artifact\/target\/myrobotlab.zip)\r\n* [JavDocs](https:\/\/build.myrobotlab.org:8443\/job\/myrobotlab\/job\/develop\/$build\/artifact\/target\/site\/apidocs\/org\/myrobotlab\/service\/package-summary.html)\r\n## Base Requirements\r\n\r\nYou will need Java 11 or newer. If you are only running MyRobotLab you need the JRE (Java Runtime Environment.) If you are going to be building from source, you'll need the JDK (Java Development Kit) Oracle or OpenJDK will work.\r\n \",\"draft\":false,\"prerelease\":false,\"generate_release_notes\":true}" +curl -X POST -H "Accept: application/vnd.github+json" -H "Authorization: token $token" https://api.github.com/repos/MyRobotLab/myrobotlab/releases -d "{\"tag_name\":\"$version\",\"target_commitish\":\"develop\",\"name\":\"$version Nixie\",\"body\":\"## MyRobotLab Nixie Release\r\n\r\nOpen Source Framework for Robotics and Creative Machine Control\r\n *You know, for robots!*\r\n\r\n* Project Website http:\/\/myrobotlab.org \r\n* Project Discord https:\/\/discord.gg\/AfScp5x8r5\r\n* Download Built Application [Nixie $version](https:\/\/myrobotlab-repo.s3.us-east-1.amazonaws.com\/myrobotlab-$version.zip)\r\n* [JavDocs](https:\/\/build.myrobotlab.org:8443\/job\/myrobotlab\/job\/develop\/$build\/artifact\/target\/site\/apidocs\/org\/myrobotlab\/service\/package-summary.html)\r\n## Base Requirements\r\n\r\nYou will need Java 11 or newer. If you are only running MyRobotLab you need the JRE (Java Runtime Environment.) If you are going to be building from source, you'll need the JDK (Java Development Kit) Oracle or OpenJDK will work.\r\n \",\"draft\":false,\"prerelease\":false,\"generate_release_notes\":true}" diff --git a/src/main/java/org/myrobotlab/service/LLM.java b/src/main/java/org/myrobotlab/service/LLM.java index ed71792fe7..502f6b7aec 100644 --- a/src/main/java/org/myrobotlab/service/LLM.java +++ b/src/main/java/org/myrobotlab/service/LLM.java @@ -144,7 +144,17 @@ OllamaAPI getOllamaApi() throws MalformedURLException { if (api == null || ollam4JUrl == null || !ollam4JUrl.contentEquals(config.url)) { URL url = new URL(config.url); ollam4JUrl = config.url; - api = new OllamaAPI(String.format("%s://%s:%d", url.getProtocol(), url.getHost(), url.getPort())); + Integer port = null; + if (url.getPort() == -1) { + if (url.getProtocol() == "https") { + port = 443; + } else { + port = 80; + } + } else { + port = url.getPort(); + } + api = new OllamaAPI(String.format("%s://%s:%d", url.getProtocol(), url.getHost(), port)); api.setRequestTimeoutSeconds(config.timeout); } return api; @@ -352,7 +362,7 @@ public Response getResponseStream(String text, List imageUrls) { // we are at the end of our response of streaming, and now the "result" will unblock signalling the end of the response // now we have to check to see if there is any extra text on the end that did not get published - if (handler.sentenceBuilder[0] != null && handler.sentenceBuilder[0].length() > 0) { + if (handler.sentenceBuilder[0] != null && handler.sentenceBuilder[0].toString().trim().length() > 0) { invoke("publishText", handler.sentenceBuilder[0].toString()); Utterance utterance = new Utterance(); @@ -474,8 +484,8 @@ public Response getResponse(String text) { log.info("curl {} -d '{}'", config.url, json); String msg = http.postJson(config.password, config.url, json); - log.error("url: {}", config.url); - log.error("json: {}", json); + log.info("url: {}", config.url); + log.info("json: {}", json); System.out.print(json); Map payload = CodecUtils.fromJson(msg, new StaticType<>() { diff --git a/src/main/java/org/myrobotlab/service/OpenCV.java b/src/main/java/org/myrobotlab/service/OpenCV.java index b692e44882..a276280c29 100644 --- a/src/main/java/org/myrobotlab/service/OpenCV.java +++ b/src/main/java/org/myrobotlab/service/OpenCV.java @@ -1674,6 +1674,10 @@ public void record(OpenCVData data) { public String recordFrame() { try { OpenCVData d = getOpenCVData(); + if (d == null) { + log.warn("could not get current frame - getting last frame"); + d = getLastData(); + } String filename = d.writeDisplay(getDataDir(), "png"); info("saved frame %s", filename); return filename; diff --git a/src/main/java/org/myrobotlab/service/config/RemoteSpeechConfig.java b/src/main/java/org/myrobotlab/service/config/RemoteSpeechConfig.java index b13b79aef3..1125c3069e 100644 --- a/src/main/java/org/myrobotlab/service/config/RemoteSpeechConfig.java +++ b/src/main/java/org/myrobotlab/service/config/RemoteSpeechConfig.java @@ -35,6 +35,14 @@ public Endpoint() { public Plan getDefault(Plan plan, String name) { super.getDefault(plan, name); addDefaultPeerConfig(plan, name, "http", "HttpClient", true); + + Endpoint piper = new Endpoint(); + piper.url = "http://localhost:5000/?text={{text}}"; + piper.verb = "GET"; + piper.template = null; + piper.authToken = null; + speechTypes.put("Piper", piper); + Endpoint coqui = new Endpoint(); coqui.url = "http://localhost:5002/api/tts?text={{text}}&speaker_id=p376&style_wav=&language_id="; diff --git a/src/main/resources/resource/WebGui/app/service/views/OpenCVGui.html b/src/main/resources/resource/WebGui/app/service/views/OpenCVGui.html index 6431c8fd48..f4cebc99e2 100644 --- a/src/main/resources/resource/WebGui/app/service/views/OpenCVGui.html +++ b/src/main/resources/resource/WebGui/app/service/views/OpenCVGui.html @@ -2,34 +2,40 @@
- - - + - +
-
- @@ -37,7 +43,8 @@
- @@ -55,12 +62,13 @@
- +
- +
@@ -79,16 +87,17 @@ -->
- +
- {{service.displayFilter}} mouse x y {{samplePoint.x}}x{{samplePoint.y}} {{stats.fps}} fps latency {{stats.latency}} ms - - + {{service.displayFilter}} mouse x y {{samplePoint.x}}x{{samplePoint.y}} {{stats.fps}} fps latency + {{stats.latency}} ms + +
-
+
- - -
- - -
- -
- - RECORDING - - -
-
-
- - - - - - - - - - + - -
- - - -
- - - -
-
- -
- +
+ +
+ + RECORDING + + +
- -  
-
- Adaptive threshold applies a threshold value based on a small region around a pixel.und it. - So we get different thresholds for different regions of the same image which gives better results for images with varying illumination. -
- Block Size {{getFilter().blockSize}} - Subtracted {{getFilter().param1}} - +
-
- AddMask allows you to add a png with transparency as an overlay. This could be useful to mask off information for training. For example, removing a face portrait from its background. +
+ + + + + + + + + + + +
+ + + +
+ + + +
+
+ +
+ +
+ +   +
+
+ Adaptive threshold applies a threshold value based on a small region around a pixel.und it. + So we get different thresholds for different regions of the same image which gives better results for images + with varying illumination.
- -
-
- In Euclidean geometry, an affine transformation is a geometric transformation that preserves lines and parallelism (but not necessarily distances and angles). + Block Size {{getFilter().blockSize}} + Subtracted {{getFilter().param1}} + +
+
+ AddMask allows you to add a png with transparency as an overlay. This could be useful to mask off + information for training. For example, removing a face portrait from its background. +
+ +
+
+ In Euclidean geometry, an affine transformation is a geometric transformation that preserves lines and + parallelism (but not necessarily distances and angles). Rotational transformation would be an example.
- angle {{getFilter().angle}} -
-
-
- Canny edge detection is a technique to extract useful structural information from different vision objects and dramatically reduce the amount of data to be processed. - It has been widely applied in various computer vision systems. -
-
- Aperture Size {{getFilter().apertureSize}} -
- Low Threshold {{getFilter().lowThreshold}} -
- High Threshold {{getFilter().highThreshold}} -
-
- Optical flow - is the pattern of apparent motion of image objects between two consecutive frames caused by the movemement of object or camera. - It is 2D vector field where each vector is a displacement vector showing the movement of points from first frame to second.. -
-
- Max Points {{getFilter().maxPointCnt}} -
- Min Distance {{getFilter().minDistance}} -
- Block Size {{getFilter().blockSize}} -
- Quality {{getFilter().quality/100}} - - + angle {{getFilter().angle}} +
+
+
+ Canny edge detection is a technique to extract useful structural information from different vision objects + and dramatically reduce the amount of data to be processed. + It has been widely applied in various computer vision systems. +
+
+ Aperture Size {{getFilter().apertureSize}} +
+ Low Threshold {{getFilter().lowThreshold}} +
+ High Threshold {{getFilter().highThreshold}} +
+
+ Optical flow + is the pattern of apparent motion of image objects between two consecutive frames caused by the movemement + of object or camera. + It is 2D vector field where each vector is a displacement vector showing the movement of points from first + frame to second.. +
+
+ Max Points {{getFilter().maxPointCnt}} +
+ Min Distance {{getFilter().minDistance}} +
+ Block Size {{getFilter().blockSize}} +
+ Quality {{getFilter().quality/100}} + + +
+
- -
- + \ No newline at end of file