Closed mocherry closed 3 weeks ago
Hello @mocherry thanks a lot for trying and for your feedback! Looking into it now I will get back soon!
Hello again @mocherry I have updated the SAMJ version in Fiji, could you please update it and try if it is working? In the updated version SAM2 Tiny is the first model on the left. Sorry for the inconvenience and thanks for your patience! Regards, Carlos
Also just so you know, the new plugin implements crtl+Z for undo and ctrl+Y for redo
I will close the issue as i am assuming it is already corrected. Please feel free to reopen it if it is still not working! @mocherry
Dear developer,
I just came across SAMJ-IJ, installed it without any obvious error messages. However, when I run it I get an error: java.lang.NukkPointer Exception and the following long (sorry about that) console output (see below).
I have no idea why and where things go wrong Start the encoding task.update('start') import numpy as np from skimage import measure measure.label(np.ones((10, 10)), connectivity=1) import torch import sys sys.path.append(r'C:\Users\kirsch\Fiji.app\appose_x86_64\envs\efficient_sam_env\EfficientSAM') from multiprocessing import shared_memory task.update('import sam') from efficient_sam.efficient_sam import build_efficient_sam task.update('imported')
predictor = build_efficient_sam(encoder_patch_embed_dim=384,encoder_num_heads=6,checkpoint=r'C:\Users\kirsch\Fiji.app\appose_x86_64\envs\efficient_sam_env\EfficientSAM\weights\efficient_sam_vits.pt',).eval() task.update('created predictor') encodings_map = {} globals()['encodings_map'] = encodings_map globals()['shared_memory'] = shared_memory globals()['measure'] = measure globals()['np'] = np globals()['torch'] = torch globals()['predictor'] = predictor def is_edge_pixel(image, cx,cy):
assuming image[cy,cx] != 0
def find_contour_neighbors(image, cx,cy, last_forward_dir): ccw_dir = [8,9,6,3,2,1,4,7] # "numpad directions"
so, directions are coded, and numbers 1-4,6-9 are used,
def trace_contour(image, max_iters, offset_x = 0, offset_y = 0): sy = 0 sx = np.where(image[0] != 0)[0][0] last_forward_dir = 1 # x_coords = [int(sx+offset_x)] y_coords = [int(sy+offset_y)] x,y,last_forward_dir = find_contour_neighbors(image, sx,sy,last_forward_dir) cnt = 1 while not (x == sx and y == sy) and cnt < max_iters: x_coords.append(int(x+offset_x)) y_coords.append(int(y+offset_y)) x,y,last_forward_dir = find_contour_neighbors(image, x,y,last_forward_dir) cnt += 1 # return x_coords,y_coords
def get_polygons_from_binary_mask(sam_result, at_least_of_this_size = 3, only_biggest=False): labels = measure.regionprops( measure.label(sam_result,connectivity=1) ) x_contours = [] y_contours = [] sizes = [] for obj in labels: if obj.num_pixels >= at_least_of_this_size: x_coords,y_coords = trace_contour(obj.image, obj.num_pixels, obj.bbox[1],obj.bbox[0]) x_contours.append(x_coords) y_contours.append(y_coords) sizes.append(obj.num_pixels) if only_biggest: max_size_pos = np.array(sizes).argmax() x_contours = [x_contours[max_size_pos]] y_contours = [y_contours[max_size_pos]] return x_contours,y_contours globals()['is_edge_pixel'] = is_edge_pixel globals()['find_contour_neighbors'] = find_contour_neighbors globals()['trace_contour'] = trace_contour globals()['get_polygons_from_binary_mask'] = get_polygons_from_binary_mask
Finished the encoding Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: com.sun.jna.Native.load(Ljava/lang/String;Ljava/lang/Class;Ljava/util/Map;)Lcom/sun/jna/Library; at com.sun.jna.platform.win32.Kernel32.(Kernel32.java:44)
at io.bioimage.modelrunner.tensor.shm.SharedMemoryArrayWin.checkSHMExists(SharedMemoryArrayWin.java:280)
at io.bioimage.modelrunner.tensor.shm.SharedMemoryArrayWin.(SharedMemoryArrayWin.java:221)
at io.bioimage.modelrunner.tensor.shm.SharedMemoryArrayWin.(SharedMemoryArrayWin.java:169)
at io.bioimage.modelrunner.tensor.shm.SharedMemoryArrayWin.create(SharedMemoryArrayWin.java:348)
at io.bioimage.modelrunner.tensor.shm.SharedMemoryArray.create(SharedMemoryArray.java:303)
at ai.nets.samj.models.EfficientSamJ.createSHMArray(EfficientSamJ.java:423)
at ai.nets.samj.models.AbstractSamJ.sendCropAsNp(AbstractSamJ.java:339)
at ai.nets.samj.models.AbstractSamJ.reencodeCrop(AbstractSamJ.java:295)
at ai.nets.samj.models.AbstractSamJ.reencodeCrop(AbstractSamJ.java:290)
at ai.nets.samj.models.AbstractSamJ.processBox(AbstractSamJ.java:630)
at ai.nets.samj.communication.model.EfficientSAM.fetch2dSegmentation(EfficientSAM.java:190)
at ai.nets.samj.ij.ui.IJ1PromptsProvider.submitRectPrompt(IJ1PromptsProvider.java:598)
at ai.nets.samj.ij.ui.IJ1PromptsProvider.mouseReleased(IJ1PromptsProvider.java:421)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:290)
at java.awt.Component.processMouseEvent(Component.java:6539)
at java.awt.Component.processEvent(Component.java:6304)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
at java.awt.EventQueue$4.run(EventQueue.java:733)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)