Coder Social home page Coder Social logo

segmenteverygrain's People

Contributors

zsylvester avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

segmenteverygrain's Issues

NameError: name 'dist' is not defined

Hi zsylvester, wanted to say thank you for the great package!

Came across an issue I am struggling to fix when using the Segment_every_grain notebook. The following error pops up using the code here:
n_of_units = 10 # centimeters in this case units_per_pixel = n_of_units/dist

`---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Input In [36], in <cell line: 2>()
1 n_of_units = 10 # centimeters in this case
----> 2 units_per_pixel = n_of_units/dist

NameError: name 'dist' is not defined`

I was wondering what is the best way to fix this?

Colab notebook updates

Hi @zsylvester ,

Thank you! The colab notebook works great, two small changes removes the errors from it.

all_grains, labels, mask_all, grain_data, fig, ax = seg.sam_segmentation(sam, big_im, big_im_pred, coords, labels, min_area=50.0)

In cell 12 (or so, might be off by 1) the outputs from the function sam_segmentation needed to be updated.

all_grains, labels, mask_all, fig, ax = seg.get_grains_from_patches(ax, big_im)

Same here, around cell 17 (again, might be off by 1)

Let le know if this works for you.

Cheers,
Thomas

cc: @zanejobe

ValueError: You are trying to restore a checkpoint from a legacy Keras optimizer into a v2.11+ Optimizer, which can cause errors.

I get the following error code while using code in google collab:

ValueError: You are trying to restore a checkpoint from a legacy Keras optimizer into a v2.11+ Optimizer, which can cause errors. Please update the optimizer referenced in your code to be an instance of tf.keras.optimizers.legacy.Optimizer, e.g.: tf.keras.optimizers.legacy.Adam.

Tried both instances with no solution to the problem.

The code used is shown below:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import cv2
from skimage import measure
from tensorflow.keras.optimizers.legacy import Adam
from tensorflow.keras.preprocessing.image import load_img
from importlib import reload
import segmenteverygrain as seg
from tqdm import trange

import tensorflow as tf
model = seg.Unet()
model.compile(optimizer= "Adam", loss=seg.weighted_crossentropy, metrics=["accuracy"])
model.load_weights('./checkpoints/seg_model')

The very last line "model.load_weights" is where the error is and not sure how to approach it.

counting stars?

Would your algorithm be appropriate for counting stars?

Thanks

ValueError in Run segmentation (attempt to get argmax of an empty sequence)

Nice to meet you. Thanks for such a great model.

I am trying to run Segment_every_grain.ipynb on VScode.

I rewrote part of the contents of the distributed Segment_every_grain.ipynb (see attached photo), and when I ran it, I got a "ValueError: attempt to get argmax of an empty sequence sequence" in "Run segmentation".

I would like to know the solution.

*I am using Google Translate.

Environment
・Mac book pro14 (M1pro)
・VScode(anaconda)
・Python(3.12.2)
・library list (see attached photo)

スクリーンショット 2024-04-17 16 12 12 スクリーンショット 2024-04-17 16 12 21 スクリーンショット 2024-04-17 16 12 51 スクリーンショット 2024-04-17 16 13 11 スクリーンショット 2024-04-17 16 42 03 スクリーンショット 2024-04-17 16 42 32

error running example scripts

hi,

I have ran the example scripts both in Jupyter and in Colab and getting the same error. Have previously ran it fine so might be related to an update or package update. It does plot the figure but does not return all_grains, labels, mask_all etc...

100%|██████████| 22/22 [01:06<00:00, 3.01s/it]
100%|██████████| 21/21 [00:46<00:00, 2.20s/it]
100%|██████████| 6399/6399 [59:28<00:00, 1.79it/s]
4772it [1:21:23, 1.02s/it]
100%|██████████| 143/143 [06:31<00:00, 2.74s/it]
100%|██████████| 154/154 [00:04<00:00, 37.72it/s]
100%|██████████| 680/680 [00:48<00:00, 13.89it/s]
0.0

IndexError Traceback (most recent call last)
in <cell line: 7>()
5 # decreasing the 'dbs_max_dist' parameter results in more SAM prompts (and longer processing times):
6 labels, grains, coords = seg.label_grains(big_im, big_im_pred, dbs_max_dist=10.0)
----> 7 all_grains, labels, mask_all, grain_data, fig, ax = seg.sam_segmentation(sam, big_im, big_im_pred, coords, labels, min_area=50.0)

1 frames
/usr/local/lib/python3.10/dist-packages/segmenteverygrain/segmenteverygrain.py in plot_grain_axes_and_centroids(all_grains, labels, ax, linewidth, markersize)
763 regions = regionprops(labels.astype('int'))
764 for ind in range(len(all_grains)-1):
--> 765 y0, x0 = regions[ind].centroid
766 orientation = regions[ind].orientation
767 x1 = x0 + np.cos(orientation) * 0.5 * regions[ind].minor_axis_length

IndexError: list index out of range

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.