JosmMagicWand icon indicating copy to clipboard operation
JosmMagicWand copied to clipboard

Magic Wand SAM action

Open abdullahO2 opened this issue 2 years ago • 3 comments

Hello @yunica I have successfully set up and run the SAMGEO Docker container locally on my machine, using the CPU (I do not have a compatible GPU). The API appears to be working correctly; I can access it via a web browser and receive a valid JSON response from the / endpoint.

However, I am unable to connect to the SAMGEO service from within JOSM using the MagicWand plugin. I have installed the latest version of the MagicWand plugin. When I attempt to use the segmentation features, I receive the following error message:

SAM server not reachable.

Steps I have taken:

  1. Built the Docker image: docker build -t samgeo-service .
  2. Run the Docker container (CPU mode):
    • docker run -d --env-file .env.example -v ./app:/app -p 80:80 samgeo-service
    • I verified the .env file sets BASE_URL=http://localhost/.
  3. Verified API accessibility: I can access http://localhost/ in my web browser and receive a JSON response confirming the service is running on the CPU. The response includes: {"device":"cpu","gpu":{},"cpu":{"cpu_percent":0.4,"cpu_cores":8,"cpu_logical_cores":16},"memory":{"total_memory":"43.68 GB","used_memory":"4.03 GB","free_memory":"39.11 GB","memory_percent":10.5}}.
  4. Installed MagicWand Plugin: I have installed the latest version of the MagicWand plugin in JOSM.
  5. Restarted JOSM and Docker container: Multiple Times.
  6. Checked firewall: No firewall rules are blocking connections to localhost:80

Expected Behavior:

The MagicWand plugin in JOSM should be able to connect to the locally running SAMGEO Docker container and utilize its segmentation capabilities.

Actual Behavior:

The MagicWand plugin displays "SAM server not reachable." and is unable to connect to the SAMGEO service.

Environment:

  • Operating System: [Windows 11]
  • JOSM Version: [19307]
  • MagicWand Plugin Version: [3.0.0]
  • .env variables:
    BASE_URL=http://localhost/
    

Possible Causes / Questions:

  • Are there any specific configuration steps required within JOSM or the MagicWand plugin to point it to the local Docker container (e.g., setting a custom server URL)? I have not found any such settings in the plugin's interface or documentation.
  • Could there be any network-related issues specific to JOSM that might prevent it from accessing localhost services, even if the service is accessible from a web browser?
  • Is it possible the MagicWand plugin specifically requires a GPU-enabled SAMGEO instance, and does not have a fallback mechanism for CPU mode?
  • Could the issue stem from differences between the expected API endpoints/request formats of the plugin, and how the API has been implemented in the samgeo-service Docker setup.
  • Does the plugin try to connect on a port other than 80?

Request:

Could you please provide guidance on how to troubleshoot this issue and successfully connect the MagicWand plugin to the locally running SAMGEO Docker container (on CPU)? Any assistance would be greatly appreciated.

Thank you!

abdullahO2 avatar Oct 16 '23 14:10 abdullahO2

@abdullahO2 👋 , You must compile a new version of the plugin with the SAM_API url, in your case it would be http://localhost; if the api is working correctly you should not have any problems.

yunica avatar Feb 19 '25 20:02 yunica

@yunica Thank you so much for your quick response and helpful suggestion! I appreciate your collaboration on this.

I understand that I need to recompile the MagicWand plugin with the SAM_API URL set to http://localhost. However, I'm not very experienced with Java development or the process of compiling JOSM plugins. I've attempted to follow the build instructions, but I've been unsuccessful so far.

Would it be possible for you to provide a compiled version of the plugin with the SAM_API URL already set to http://localhost? This would be incredibly helpful for users like myself who are running SAMGEO locally on CPU and aren't familiar with Java plugin development.

Alternatively, a more user-friendly and long-term solution would be to allow users to configure the SAM_API URL directly within the JOSM plugin settings. This would eliminate the need for recompilation whenever the API endpoint changes (e.g., switching between a local Docker instance and a remote server, or changing the port). This would greatly improve the plugin's flexibility and ease of use for a wider range of users. Many JOSM plugins offer this type of configuration option.

I believe either of these solutions (a pre-compiled version or a configurable URL) would significantly benefit the community and make the MagicWand plugin more accessible to users running SAMGEO in different environments.

Thanks again for your time and consideration! I look forward to your feedback.

abdullahO2 avatar Feb 20 '25 16:02 abdullahO2

@yunica,

I've attempted to build the plugin, but I'm encountering numerous compilation errors. It seems like several dependencies are missing or not being resolved correctly, specifically related to org.locationtech.jts, org.opencv, com.fasterxml.jackson, and okhttp3.

I've included the full output from running ant below. I'm running this from within the JosmMagicWand directory, I've ensured that I have the JOSM source code in a sibling directory (../core), and that the josm-custom.jar is present in ../core/dist. I have also installed Ant and a JDK (OpenJDK 17). I am not working inside the JOSM core directory itself; I am working on the plugin's separate repository.

Could you possibly provide more specific instructions on the build environment setup? Are there any additional libraries I need to download or configure? Perhaps there are specific versions of these dependencies that are required? Or a specific build.xml configuration I should be using? I suspect I may be missing a step in setting up the build environment, or there may be a difference in the way the dependencies are handled in my environment compared to yours. A build.gradle file (or similar) would be ideal for dependency management if possible.

Here is the full output from the ant command:

log.txt

abdullahO2 avatar Feb 22 '25 14:02 abdullahO2