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

How can i set custom Score Threshold, custom NMS Threshold and custom Sample Points when inference with local machine? #17

Open
wwxb2012 opened this issue May 1, 2024 · 4 comments

Comments

@wwxb2012
Copy link

wwxb2012 commented May 1, 2024

I tried to download the model and tried your provided demo in my server, and I noticed the results are different when inference with the same input image and using huggingface with your default parameters:
huggingface result:
image
server result (using the provided demo code):
image

I want to set the parameters as in the huggingface.

@wwxb2012
Copy link
Author

wwxb2012 commented May 1, 2024

The input image:
0_0

@wwxb2012
Copy link
Author

wwxb2012 commented May 2, 2024

One more question: what does NMS Threshold and Sample Points mean? I may need to adjust them on myself.

@ericup
Copy link
Collaborator

ericup commented May 2, 2024

On HuggingFace we currently use a preprocessing step that is not yet part of the model. Outside of HuggingFace you'd need to apply this manually to get the same results.
You can find the function here: https://huggingface.co/spaces/ericup/celldetection/blob/d551587eddc1c8536336bbce073c32613b4f113a/prep.py#L43

Simply use the following line before running your model:

img = multi_norm(img, 'cstm-mix')

We are planning to handle this automatically, but that is not available yet.

Regarding your other question:
NMS Threshold: This is the Intersection over Union (IoU) threshold used in the Non-Maximum Suppression (NMS) algorithm, which helps prevent overlapping detections where IoU > nms_threshold. More details can be found on the PyTorch NMS documentation page.

Sample Points: This parameter allows you to specify the number of sample points defining each contour. For example, setting it to 128 ensures that each contour is defined by exactly 128 points.

To choose an NMS threshold, select a lower value (e.g., 0.3) for relatively strict suppression of overlapping detections, or a higher value (e.g., 0.5 or above) if overlap is acceptable. For sample points, use more points (e.g., 128 or more) for detailed contours in high-resolution images, or fewer points for simpler shapes or when computational efficiency is a priority.

@wwxb2012
Copy link
Author

wwxb2012 commented May 4, 2024

Thank you very much! Very fast response.

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

2 participants