Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update? #23

Open
rsignell-usgs opened this issue May 10, 2022 · 5 comments
Open

Update? #23

rsignell-usgs opened this issue May 10, 2022 · 5 comments

Comments

@rsignell-usgs
Copy link

@maximlt can you give us an update on where we are?
The project was supposed to be over by now and we are running into problems with the funds.
Also we could really use the tool!

@maximlt
Copy link
Collaborator

maximlt commented May 10, 2022

Hi @rsignell-usgs! I've worked last week on implementing a way to export the doodles to SVG, I still need to finish this up and push it to the repo. Another work I've started to address and discuss with Philipp is to add fsspec support to Panel's FileSelector widget, so that you could easily access files on S3 or other cloud storage. That will be very useful for this app!

Orthogonal to these tasks is the task to hand over this repo/project to you. One thing to note is the segmentation code that this repo has is pretty much the code that lives in https://github.com/Doodleverse/dash_doodler, I just had to refactor it a little to avoid parts of the dash dashboard features leaking into the segmentation functions. Ideally we wouldn't have this code duplication. How would you like this transition to happen? If the dash and holo doodler apps are both meant to be in use, it'd make sense to have the segmentation code live in its own repo (and eventually published as a package). @jbednar and @dbuscombe-usgs, happy to get your input on this matter!

@dbuscombe-usgs
Copy link

I agree that the doodler "engine" should probably live in its own repo and eventually published as a standalone package. I could work on this. I am familiar with packaging for pip

@dbuscombe-usgs
Copy link

another outstanding issue is the pydensecrf conda-forge build being quite old, which (from memory) is limiting us to python 3.6. https://anaconda.org/conda-forge/pydensecrf

@rsignell-usgs am I correct in thinking that you were responsible for this conda-forge build? (It was for the 2018 CDI class that I taught)

@jbednar
Copy link

jbednar commented May 10, 2022

Ok, sounds good. We'll hand over the task of extracting the "engine" and dealing with pydensecrf to you, and should have a final report later this week (though we can still engage on questions and smaller changes after that).

@maximlt
Copy link
Collaborator

maximlt commented May 11, 2022

On pydensecrf, given the comments on the PRs opened and closed on the conda-forge recipe repo, the package needed to be updated before new recipes could be built. I think these required changes were made, except that they've not been released on PyPi, or even tagged on the repo. I had opened an issue to try to get a new PyPi release, the maintainer replied, but that was it. A workaround I have found is to declare in the environment.yml that pydensecrf should be installed from its repo directly (pinning the latest commit at the time I made that change), that seemed to work well, and allowed me to get an environment working on Python 3.7, benefiting from the latest releases of the HoloViz tools:

 - pip:
   - git+https://github.com/li-plus/pydensecrf.git@0d53acbcf5123d4c88040fe68fbb9805fc5b2fb9

Other solutions include:

  • Not quite sure, but if the maintainer of the repo would at least bump the version and add a git tag, it may be possible to change the conda-forge recipe so that it builds the package from the Github repo directly instead of using the metadata/data from PyPi.
  • Finding another package that provides the same functionality 🙃

Thanks Dan for suggesting to take care of creating the core segmentation package! You can see in the code in this repo how I've interfaced the app to the core segmentation. I'm basically just using two functions from the core:

from .segmentation.annotations_to_segmentations import label_to_colors
from .segmentation.image_segmentation import segmentation

And use them as follows:

def _compute_segmentation(self):
    # Get the doodles from the drawer component
    doodles = self.doodle_drawer.doodles

    # Rescale the vectorized doodles from their [(0,1),(0,1)] space to pixels
    img_height, img_width, _ = self.input_image.array.shape
    projected_doodles = project_doodles(
        doodles,
        x_cur_range=self.input_image.plot.range('x'),
        y_cur_range=self.input_image.plot.range('y'),
        x_target_range=(0, img_width),
        y_target_range=(0, img_height),
    )
    # Turn the vectorized doodles into a mask array (this is using Pillow)
    self._mask_doodles = doodles_as_array(
        projected_doodles,
        img_width=img_width,
        img_height=img_height,
        colormap=self.doodle_drawer.colormap,
    )

    # Compute the segmentation using core
    self._segmentation = segmentation(
        img=self.input_image.array,
        mask=self._mask_doodles,
        **self.settings.as_dict(),
    )

    # Colorize the segmentation using core
    self._segmentation_color = label_to_colors(
        self._segmentation,
        self.input_image.array[:, :, 0] == 0,
        colormap=self.doodle_drawer.colormap,
        color_class_offset=-1,
    )

    # Display the colorized segmentation on top of the image
    hv_segmentation_color = hv.RGB(self._segmentation_color, bounds=(-1, -1, 1, 1)).opts(alpha=0.5)
    self._img_pane.object = self._img_pane.object * hv_segmentation_color

I don't know to which extent the core in this repo has diverged from the core in dash_doodler. What I remember:

  • I did some refactoring to avoid having the core rely on Plotly
  • I did some code formatting
  • In this PR I changed logging to be less verbose and set joblib to use threads (that was to fix an issue we had when running the app)

I'll be available to test the new core when it is in a repo/released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants