Skip to main content

A tool to find cryo-em targets for cyro-em automation building on foundation ML models.

Project description

Cryo-SAM Author: James Rodgers, Aditya Balu Organization: Iowa State University - Department of Electrical and Computer Engineering Email: jmsrdgrs@iastate.edu

Uses Sam for the detection of squares, holes, and particles in cryo-em.

Usage:

from cryo_sam import Csam

Model checkpoint location, several types downloadable from https://github.com/facebookresearch/segment-anything#model-checkpoints testing done with the below model and checkpoint information:

model_name = "vit_h"
checkpoint = "sam_model/sam_vit_h_4b8939.pth" 
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

Example construction: detector = Csam(model_name, checkpoint, device)

Csam.hole_finder(numpy_image_array) Parameter: numpy image array Returns: list of square coordinates (x, y, w, h) Csam.square_finder(numpy_image_array): Parameter: numpy image array Returns: list of square coordinates (x, y, w, h)

Both of the above returns will need to be changed in the future since extra data is to be returned be the exact nature of that isn't determined yet. It will probably return a class containing the data in the near future.

Csam.visualize_detections(image, image_scale_percent, box_prompts = None, point_prompts = None, show_boxes = True, show_point_prompts = None, show_box_prompts, show_masks = True): Parameters: image: numpy image array, numpy array of points, numpy array of bounding box, bool, bool, bool image_scale_percent: int representing scaled percent i.e 60 = 60% of original size point_prompts: numpy array of points. [[x, y], [x, y], [x, y], ...] box_prompts: numpy array of rectangle boxes [[x1, y1, x2, y2], [x1, y1, x2, y2], ...] show_boxes: bool, show bounding boxes generated by the model show_masks: bool, show masks generated by the model show_point_prompts: bool, show point prompts sent to the model show_box_prompts: bool, show bounding box prompts sent to the model Returns: None

Example usage:

test_image = np.load("/mnt/big_data_2/pncc/annotated_data/160002/box4_g11/data_031022/mmm_0.npy")
test_image = cv2.cvtColor(test_image, cv2.COLOR_BGR2RGB)

print(detector.hole_finder(test_image))
detector.visualize_detections(test_image, image_scale_percent, show_boxes=True)

image_scale_percent = 40

This function will display the image with the detections overlaid on top of it. It is currently not specialized to hole or square.
This will be changed in the future, this is mostly for testing purposes.
The image_scale_percent is the percent of the original image size that the image will be displayed at. 
This is useful for large images that would be too large to display on a screen and to improve render speed. 
The default is 50% of the original size. Will probably add a save image option in the future.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cryo-sam-0.0.81.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

cryo_sam-0.0.81-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file cryo-sam-0.0.81.tar.gz.

File metadata

  • Download URL: cryo-sam-0.0.81.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for cryo-sam-0.0.81.tar.gz
Algorithm Hash digest
SHA256 4f0ef5ded1544d908c4df85108a8cc61a4789ab896e4d268a09fffbd8461b472
MD5 e6af7855bc9223eaf4ad51025260be84
BLAKE2b-256 872b508030f648f89e6a72e72489df2ef86653d7bc9cff3db83467907aa72470

See more details on using hashes here.

File details

Details for the file cryo_sam-0.0.81-py3-none-any.whl.

File metadata

  • Download URL: cryo_sam-0.0.81-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.18

File hashes

Hashes for cryo_sam-0.0.81-py3-none-any.whl
Algorithm Hash digest
SHA256 657d095faefc6c8b28999986e9c7751bce9ccc725d235e297ef4f4c5d8b15e6f
MD5 50a045e20c5b4909d1da2e82a1ae6176
BLAKE2b-256 c8e524112b4f1091d6a5381afbf43b1cf14fa9f3d1e188f8251650e1f259034e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page