From ff93c28cf2c2ed1d4a64147f1ea01d9f27d4a432 Mon Sep 17 00:00:00 2001 From: christinab12 Date: Wed, 3 Jul 2024 17:20:13 +0200 Subject: [PATCH 01/37] update model to mmdetection --- napari_organoid_counter/_orgacount.py | 39 +++++++++++++-------------- napari_organoid_counter/_utils.py | 25 +++-------------- napari_organoid_counter/settings.py | 34 ++++++++++++++++++++--- setup.cfg | 1 + 4 files changed, 53 insertions(+), 46 deletions(-) diff --git a/napari_organoid_counter/_orgacount.py b/napari_organoid_counter/_orgacount.py index 8425309..427b17d 100644 --- a/napari_organoid_counter/_orgacount.py +++ b/napari_organoid_counter/_orgacount.py @@ -1,5 +1,6 @@ import torch from torchvision.transforms import ToTensor +from mmdet.apis import DetInferencer from urllib.request import urlretrieve from napari.utils import progress @@ -60,24 +61,20 @@ def set_scale(self, img_scale): def set_model(self, model_name): ''' Initialise model instance and load model checkpoint and send to device. ''' - self.model = frcnn(num_classes=2, rpn_score_thresh=0, box_score_thresh = self.cur_confidence) - self.load_model_checkpoint(model_name) - self.model = self.model.to(self.device) - def download_model(self, model='default'): + model_checkpoint = join_paths(str(settings.MODELS_DIR), settings.MODELS[model_name]["filename"]) + self.model = DetInferencer(str(settings.CONFIGS[model_name]["destination"]), model_checkpoint, self.device, show_progress=False) + + def download_model(self, model_name='yolov3'): ''' Downloads the model from zenodo and stores it in settings.MODELS_DIR ''' - # specify the url of the file which is to be downloaded - down_url = settings.MODELS[model]["source"] + # specify the url of the model which is to be downloaded + down_url = settings.MODELS[model_name]["source"] # specify save location where the file is to be saved - save_loc = join_paths(str(settings.MODELS_DIR), settings.MODELS[model]["filename"]) - # Downloading using urllib - urlretrieve(down_url,save_loc, self.handle_progress) - - def load_model_checkpoint(self, model_name): - ''' Loads the model checkpoint for the model specified in model_name ''' - model_checkpoint = join_paths(settings.MODELS_DIR, settings.MODELS[model_name]["filename"]) - ckpt = torch.load(model_checkpoint, map_location=self.device) - self.model.load_state_dict(ckpt) #.state_dict()) + save_loc = join_paths(str(settings.MODELS_DIR), settings.MODELS[model_name]["filename"]) + # downloading using urllib + urlretrieve(down_url, save_loc, self.handle_progress) + # now also download the corresponding config + urlretrieve(settings.CONFIGS[model_name]["source"], settings.CONFIGS[model_name]["destination"], self.handle_progress) def sliding_window(self, test_img, @@ -120,20 +117,20 @@ def sliding_window(self, for i in progress(range(0, prepadded_height, step)): for j in progress(range(0, prepadded_width, step)): # crop - img_crop = test_img[:, :, i:(i+window_size), j:(j+window_size)] + img_crop = test_img[i:(i+window_size), j:(j+window_size)] # get predictions - output = self.model(img_crop.float()) - preds = output[0]['boxes'] - if preds.size(0)==0: continue + output = self.model(img_crop) + preds = output['predictions'][0]['boxes'] + if len(preds)==0: continue else: - for bbox_id in range(preds.size(0)): + for bbox_id in range(len(preds)): y1, x1, y2, x2 = preds[bbox_id].cpu().detach() # predictions from model will be in form x1,y1,x2,y2 x1_real = torch.div(x1+i, rescale_factor, rounding_mode='floor') x2_real = torch.div(x2+i, rescale_factor, rounding_mode='floor') y1_real = torch.div(y1+j, rescale_factor, rounding_mode='floor') y2_real = torch.div(y2+j, rescale_factor, rounding_mode='floor') pred_bboxes.append(torch.Tensor([x1_real, y1_real, x2_real, y2_real])) - scores_list.append(output[0]['scores'][bbox_id].cpu().detach()) + scores_list.append(output['predictions'][0]['scores'][bbox_id].cpu().detach()) return pred_bboxes, scores_list def run(self, diff --git a/napari_organoid_counter/_utils.py b/napari_organoid_counter/_utils.py index c2cc49e..bcc0c21 100644 --- a/napari_organoid_counter/_utils.py +++ b/napari_organoid_counter/_utils.py @@ -113,16 +113,14 @@ def prepare_img(test_img, step, window_size, rescale_factor, trans, device): # pad image pad_x = (img_height//step)*step + window_size - img_height pad_y = (img_width//step)*step + window_size - img_width - test_img = np.pad(test_img, ((0, int(pad_x)), (0, int(pad_y))), mode='edge') + test_img = np.pad(test_img, ((0, int(pad_x)), (0, int(pad_y))), mode='reflect') # normalise and convert to RGB - model input has size 3 test_img = (test_img-np.min(test_img))/(np.max(test_img)-np.min(test_img)) test_img = (255*test_img).astype(np.uint8) test_img = gray2rgb(test_img) #[H,W,C] - # convert to tensor and send to device - test_img = trans(test_img) - test_img = torch.unsqueeze(test_img, axis=0) #[B, C, H, W] - test_img = test_img.to(device) + # convert from RGB to GBR - expected from DetInferencer + test_img = test_img[..., ::-1] return test_img, img_height, img_width @@ -174,21 +172,4 @@ def apply_normalization(img): img_max = np.max(img) # 2899.25 png 178 img_norm = (255 * (img - img_min) / (img_max - img_min)).astype(np.uint8) return img_norm - -class frcnn(nn.Module): - def __init__(self, num_classes,rpn_score_thresh=0,box_score_thresh=0.05): - """ An FRCNN module loads the pretrained FasterRCNN model """ - super(frcnn, self).__init__() - # define classes and load pretrained model - self.num_classes = num_classes - self.model = detection.fasterrcnn_resnet50_fpn(pretrained=True, rpn_score_thresh = rpn_score_thresh, box_score_thresh = box_score_thresh) - # get number of input features for the classifier - self.in_features = self.model.roi_heads.box_predictor.cls_score.in_features - # replace the pre-trained head with a new one - self.model.roi_heads.box_predictor = FastRCNNPredictor(self.in_features, self.num_classes) - self.model.eval() - - def forward(self, x, return_all=False): - """ A forward pass through the model """ - return self.model(x) \ No newline at end of file diff --git a/napari_organoid_counter/settings.py b/napari_organoid_counter/settings.py index b715ff3..2fe8b03 100644 --- a/napari_organoid_counter/settings.py +++ b/napari_organoid_counter/settings.py @@ -4,13 +4,41 @@ def init(): global MODELS MODELS = { - "model_1 (default)": {"filename": "model_v1.ckpt", "source": "https://zenodo.org/record/7708763/files/model_v1.ckpt"}, - "model_2": {"filename": "model_v2.ckpt", "source": "https://zenodo.org/record/8146857/files/model_v2.ckpt"}, + "faster r-cnn": {"filename": "faster-rcnn_r50_fpn_organoid_best_coco_bbox_mAP_epoch_68.pth", + "source": "https://zenodo.org/records/11388549/files/faster-rcnn_r50_fpn_organoid_best_coco_bbox_mAP_epoch_68.pth" + }, + "ssd": {"filename": "ssd_organoid_best_coco_bbox_mAP_epoch_86.pth", + "source": "https://zenodo.org/records/11388549/files/ssd_organoid_best_coco_bbox_mAP_epoch_86.pth" + }, + "yolov3": {"filename": "yolov3_416_organoid_best_coco_bbox_mAP_epoch_27.pth", + "source": "https://zenodo.org/records/11388549/files/yolov3_416_organoid_best_coco_bbox_mAP_epoch_27.pth" + }, + "rtmdet": {"filename": "rtmdet_l_organoid_best_coco_bbox_mAP_epoch_323.pth", + "source": "https://zenodo.org/records/11388549/files/rtmdet_l_organoid_best_coco_bbox_mAP_epoch_323.pth" + }, } global MODELS_DIR MODELS_DIR = Path.home() / ".cache/napari-organoid-counter/models" global MODEL_TYPE - MODEL_TYPE = '.ckpt' + MODEL_TYPE = '.pth' + + global CONFIGS + CONFIGS = { + "faster r-cnn": {"source": "https://zenodo.org/records/11388549/files/faster-rcnn_r50_fpn_organoid.py", + "destination": "./mmdetection/configs/faster_rcnn/faster-rcnn_r50_fpn_organoid.py" + }, + "ssd": {"source": "https://zenodo.org/records/11388549/files/ssd_organoid.py", + "destination": "./configs/ssd/ssd_organoid.py" + }, + "yolov3": {"source": "https://zenodo.org/records/11388549/files/yolov3_416_organoid.py", + "destination": "./mmdetection/configs/yolo/yolov3_416_organoid.py" + }, + "rtmdet": {"source": "https://zenodo.org/records/11388549/files/rtmdet_l_organoid.py", + "destination": "./mmdetection/configs/rtmdet/rtmdet_l_organoid.py" + } +} + + diff --git a/setup.cfg b/setup.cfg index ca76316..f4cb9f8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -38,6 +38,7 @@ install_requires = napari-aicsimageio>=0.7.2 torch>=1.13.1 torchvision>=0.14.1 + mmdet>=3.3.0 [options.extras_require] testing = From af9a76547a279c8407aeb71b0b108331ecf67ac3 Mon Sep 17 00:00:00 2001 From: christinab12 Date: Tue, 9 Jul 2024 18:33:01 +0200 Subject: [PATCH 02/37] remove unecessary packages and store config at mmdet path --- napari_organoid_counter/_orgacount.py | 19 +++++++------------ napari_organoid_counter/_utils.py | 5 +---- napari_organoid_counter/settings.py | 8 ++++---- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/napari_organoid_counter/_orgacount.py b/napari_organoid_counter/_orgacount.py index 427b17d..f1940d4 100644 --- a/napari_organoid_counter/_orgacount.py +++ b/napari_organoid_counter/_orgacount.py @@ -1,8 +1,6 @@ -import torch -from torchvision.transforms import ToTensor -from mmdet.apis import DetInferencer - from urllib.request import urlretrieve +import torch +import mmdet from napari.utils import progress from napari_organoid_counter._utils import * @@ -20,8 +18,6 @@ class OrganoiDL(): The confidence threshold of the model cur_min_diam: float The minimum diameter of the organoids - transfroms: torchvision.transforms.ToTensor - The transformation for converting numpy image to tensor so it can be given as an input to the model model: frcnn The Faster R-CNN model img_scale: list of floats @@ -46,7 +42,6 @@ def __init__(self, handle_progress): self.device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') self.cur_confidence = 0.05 self.cur_min_diam = 30 - self.transfroms = ToTensor() self.model = None self.img_scale = [0., 0.] @@ -63,7 +58,7 @@ def set_model(self, model_name): ''' Initialise model instance and load model checkpoint and send to device. ''' model_checkpoint = join_paths(str(settings.MODELS_DIR), settings.MODELS[model_name]["filename"]) - self.model = DetInferencer(str(settings.CONFIGS[model_name]["destination"]), model_checkpoint, self.device, show_progress=False) + self.model = mmdet.apis.DetInferencer(str(settings.CONFIGS[model_name]["destination"]), model_checkpoint, self.device, show_progress=False) def download_model(self, model_name='yolov3'): ''' Downloads the model from zenodo and stores it in settings.MODELS_DIR ''' @@ -74,7 +69,9 @@ def download_model(self, model_name='yolov3'): # downloading using urllib urlretrieve(down_url, save_loc, self.handle_progress) # now also download the corresponding config - urlretrieve(settings.CONFIGS[model_name]["source"], settings.CONFIGS[model_name]["destination"], self.handle_progress) + mmdet_path = os.path.dirname(mmdet.__file__) + config_dst = join_paths(mmdet_path, str(settings.CONFIGS[model_name]["destination"])) + urlretrieve(settings.CONFIGS[model_name]["source"], config_dst, self.handle_progress) def sliding_window(self, test_img, @@ -167,9 +164,7 @@ def run(self, ready_img, prepadded_height, prepadded_width = prepare_img(img, step, window_size, - rescale_factor, - self.transfroms, - self.device) + rescale_factor) # and run sliding window over whole image bboxes, scores = self.sliding_window(ready_img, step, diff --git a/napari_organoid_counter/_utils.py b/napari_organoid_counter/_utils.py index bcc0c21..acd7507 100644 --- a/napari_organoid_counter/_utils.py +++ b/napari_organoid_counter/_utils.py @@ -10,9 +10,6 @@ from skimage.color import gray2rgb import torch -import torch.nn as nn -from torchvision.models import detection -from torchvision.models.detection.faster_rcnn import FastRCNNPredictor from torchvision.ops import nms from napari_organoid_counter import settings @@ -104,7 +101,7 @@ def squeeze_img(img): """ Squeeze image - all dims that have size one will be removed """ return np.squeeze(img) -def prepare_img(test_img, step, window_size, rescale_factor, trans, device): +def prepare_img(test_img, step, window_size, rescale_factor): """ The original image is prepared for running model inference """ # squeeze and resize image test_img = squeeze_img(test_img) diff --git a/napari_organoid_counter/settings.py b/napari_organoid_counter/settings.py index 2fe8b03..c1b9e10 100644 --- a/napari_organoid_counter/settings.py +++ b/napari_organoid_counter/settings.py @@ -27,16 +27,16 @@ def init(): global CONFIGS CONFIGS = { "faster r-cnn": {"source": "https://zenodo.org/records/11388549/files/faster-rcnn_r50_fpn_organoid.py", - "destination": "./mmdetection/configs/faster_rcnn/faster-rcnn_r50_fpn_organoid.py" + "destination": ".mim/configs/faster_rcnn/faster-rcnn_r50_fpn_organoid.py" }, "ssd": {"source": "https://zenodo.org/records/11388549/files/ssd_organoid.py", - "destination": "./configs/ssd/ssd_organoid.py" + "destination": ".mim/configs/ssd/ssd_organoid.py" }, "yolov3": {"source": "https://zenodo.org/records/11388549/files/yolov3_416_organoid.py", - "destination": "./mmdetection/configs/yolo/yolov3_416_organoid.py" + "destination": ".mim/mmdetection/configs/yolo/yolov3_416_organoid.py" }, "rtmdet": {"source": "https://zenodo.org/records/11388549/files/rtmdet_l_organoid.py", - "destination": "./mmdetection/configs/rtmdet/rtmdet_l_organoid.py" + "destination": ".mim/mmdetection/configs/rtmdet/rtmdet_l_organoid.py" } } From 9ebbb5fe1941088fdc2b1f736b06389ec4e71afb Mon Sep 17 00:00:00 2001 From: christinab12 Date: Wed, 10 Jul 2024 14:36:54 +0200 Subject: [PATCH 03/37] update paths --- .github/workflows/test_and_deploy.yml | 1 - napari_organoid_counter/_orgacount.py | 5 ++++- napari_organoid_counter/settings.py | 4 ++-- setup.cfg | 9 ++++++--- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 03e5d4a..99d15f5 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -7,7 +7,6 @@ on: push: branches: - main - - dev-v.0.2 tags: - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 pull_request: diff --git a/napari_organoid_counter/_orgacount.py b/napari_organoid_counter/_orgacount.py index f1940d4..049cb1a 100644 --- a/napari_organoid_counter/_orgacount.py +++ b/napari_organoid_counter/_orgacount.py @@ -1,6 +1,7 @@ from urllib.request import urlretrieve import torch import mmdet +from mmdet.apis import DetInferencer from napari.utils import progress from napari_organoid_counter._utils import * @@ -58,7 +59,9 @@ def set_model(self, model_name): ''' Initialise model instance and load model checkpoint and send to device. ''' model_checkpoint = join_paths(str(settings.MODELS_DIR), settings.MODELS[model_name]["filename"]) - self.model = mmdet.apis.DetInferencer(str(settings.CONFIGS[model_name]["destination"]), model_checkpoint, self.device, show_progress=False) + mmdet_path = os.path.dirname(mmdet.__file__) + config_dst = join_paths(mmdet_path, str(settings.CONFIGS[model_name]["destination"])) + self.model = DetInferencer(config_dst, model_checkpoint, self.device, show_progress=False) def download_model(self, model_name='yolov3'): ''' Downloads the model from zenodo and stores it in settings.MODELS_DIR ''' diff --git a/napari_organoid_counter/settings.py b/napari_organoid_counter/settings.py index c1b9e10..b8b4039 100644 --- a/napari_organoid_counter/settings.py +++ b/napari_organoid_counter/settings.py @@ -33,10 +33,10 @@ def init(): "destination": ".mim/configs/ssd/ssd_organoid.py" }, "yolov3": {"source": "https://zenodo.org/records/11388549/files/yolov3_416_organoid.py", - "destination": ".mim/mmdetection/configs/yolo/yolov3_416_organoid.py" + "destination": ".mim/configs/yolo/yolov3_416_organoid.py" }, "rtmdet": {"source": "https://zenodo.org/records/11388549/files/rtmdet_l_organoid.py", - "destination": ".mim/mmdetection/configs/rtmdet/rtmdet_l_organoid.py" + "destination": ".mim/configs/rtmdet/rtmdet_l_organoid.py" } } diff --git a/setup.cfg b/setup.cfg index f4cb9f8..ca78013 100644 --- a/setup.cfg +++ b/setup.cfg @@ -30,14 +30,17 @@ project_urls = packages = napari_organoid_counter include_package_data = True -python_requires = >=3.8, <3.11 +python_requires = + ==3.8.* setup_requires = setuptools_scm # add your package requirements here install_requires = napari[all]>=0.4.17 napari-aicsimageio>=0.7.2 - torch>=1.13.1 - torchvision>=0.14.1 + torch>=2.3.1 + torchvision>=0.18.1 + mmengine>=0.10.4 + mmcv==2.1.0 mmdet>=3.3.0 [options.extras_require] From e8fb30565cf06998f038301f7ed71316bee1c3ca Mon Sep 17 00:00:00 2001 From: christinab12 Date: Wed, 10 Jul 2024 16:39:46 +0200 Subject: [PATCH 04/37] fixed bugs and made yolo default --- napari_organoid_counter/_orgacount.py | 9 +++++---- napari_organoid_counter/_utils.py | 2 +- napari_organoid_counter/_widget.py | 4 +++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/napari_organoid_counter/_orgacount.py b/napari_organoid_counter/_orgacount.py index 049cb1a..0518097 100644 --- a/napari_organoid_counter/_orgacount.py +++ b/napari_organoid_counter/_orgacount.py @@ -120,17 +120,17 @@ def sliding_window(self, img_crop = test_img[i:(i+window_size), j:(j+window_size)] # get predictions output = self.model(img_crop) - preds = output['predictions'][0]['boxes'] + preds = output['predictions'][0]['bboxes'] if len(preds)==0: continue else: for bbox_id in range(len(preds)): - y1, x1, y2, x2 = preds[bbox_id].cpu().detach() # predictions from model will be in form x1,y1,x2,y2 + y1, x1, y2, x2 = preds[bbox_id] # predictions from model will be in form x1,y1,x2,y2 x1_real = torch.div(x1+i, rescale_factor, rounding_mode='floor') x2_real = torch.div(x2+i, rescale_factor, rounding_mode='floor') y1_real = torch.div(y1+j, rescale_factor, rounding_mode='floor') y2_real = torch.div(y2+j, rescale_factor, rounding_mode='floor') pred_bboxes.append(torch.Tensor([x1_real, y1_real, x2_real, y2_real])) - scores_list.append(output['predictions'][0]['scores'][bbox_id].cpu().detach()) + scores_list.append(output['predictions'][0]['scores'][bbox_id]) return pred_bboxes, scores_list def run(self, @@ -177,9 +177,10 @@ def run(self, prepadded_width, bboxes, scores) + print('Windowsize:', len(bboxes)) # stack results bboxes = torch.stack(bboxes) - scores = torch.stack(scores) + scores = torch.Tensor(scores) # apply NMS to remove overlaping boxes bboxes, pred_scores = apply_nms(bboxes, scores) self.pred_bboxes[shapes_name] = bboxes diff --git a/napari_organoid_counter/_utils.py b/napari_organoid_counter/_utils.py index acd7507..89b685c 100644 --- a/napari_organoid_counter/_utils.py +++ b/napari_organoid_counter/_utils.py @@ -110,7 +110,7 @@ def prepare_img(test_img, step, window_size, rescale_factor): # pad image pad_x = (img_height//step)*step + window_size - img_height pad_y = (img_width//step)*step + window_size - img_width - test_img = np.pad(test_img, ((0, int(pad_x)), (0, int(pad_y))), mode='reflect') + test_img = np.pad(test_img, ((0, int(pad_x)), (0, int(pad_y))), mode='edge') # normalise and convert to RGB - model input has size 3 test_img = (test_img-np.min(test_img))/(np.max(test_img)-np.min(test_img)) test_img = (255*test_img).astype(np.uint8) diff --git a/napari_organoid_counter/_widget.py b/napari_organoid_counter/_widget.py index 2007a59..37fe7d0 100644 --- a/napari_organoid_counter/_widget.py +++ b/napari_organoid_counter/_widget.py @@ -73,7 +73,8 @@ def __init__(self, settings.init() settings.MODELS_DIR.mkdir(parents=True, exist_ok=True) utils.add_local_models() - self.model_name = list(settings.MODELS.keys())[0] + self.model_id = 2 # yolov3 + self.model_name = list(settings.MODELS.keys())[self.model_id] # init params self.window_sizes = window_sizes @@ -603,6 +604,7 @@ def _setup_model_box(self): # setup drop down option for selecting which image to process self.model_selection = QComboBox() for name in settings.MODELS.keys(): self.model_selection.addItem(name) + self.model_selection.setCurrentIndex(self.model_id) self.model_selection.currentIndexChanged.connect(self._on_model_selection_changed) # and add all these to the layout From 82f93be566468aa1d94db0565945d6b70936a725 Mon Sep 17 00:00:00 2001 From: christinab12 Date: Fri, 12 Jul 2024 14:42:29 +0200 Subject: [PATCH 05/37] adding change of mmcv version in mmdet package to allow for install --- napari_organoid_counter/_orgacount.py | 15 +++++++-------- napari_organoid_counter/_utils.py | 25 ++++++++++++++++++++++++- setup.cfg | 7 +++---- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/napari_organoid_counter/_orgacount.py b/napari_organoid_counter/_orgacount.py index 0518097..6bf6296 100644 --- a/napari_organoid_counter/_orgacount.py +++ b/napari_organoid_counter/_orgacount.py @@ -1,12 +1,13 @@ from urllib.request import urlretrieve -import torch -import mmdet -from mmdet.apis import DetInferencer from napari.utils import progress from napari_organoid_counter._utils import * from napari_organoid_counter import settings +update_version_in_mmdet_init_file('mmdet', '2.2.0', '2.2.1') +import torch +import mmdet +from mmdet.apis import DetInferencer class OrganoiDL(): ''' @@ -61,6 +62,9 @@ def set_model(self, model_name): model_checkpoint = join_paths(str(settings.MODELS_DIR), settings.MODELS[model_name]["filename"]) mmdet_path = os.path.dirname(mmdet.__file__) config_dst = join_paths(mmdet_path, str(settings.CONFIGS[model_name]["destination"])) + # download the corresponding config if it doesn't exist already + if not os.path.exists(config_dst): + urlretrieve(settings.CONFIGS[model_name]["source"], config_dst, self.handle_progress) self.model = DetInferencer(config_dst, model_checkpoint, self.device, show_progress=False) def download_model(self, model_name='yolov3'): @@ -71,10 +75,6 @@ def download_model(self, model_name='yolov3'): save_loc = join_paths(str(settings.MODELS_DIR), settings.MODELS[model_name]["filename"]) # downloading using urllib urlretrieve(down_url, save_loc, self.handle_progress) - # now also download the corresponding config - mmdet_path = os.path.dirname(mmdet.__file__) - config_dst = join_paths(mmdet_path, str(settings.CONFIGS[model_name]["destination"])) - urlretrieve(settings.CONFIGS[model_name]["source"], config_dst, self.handle_progress) def sliding_window(self, test_img, @@ -177,7 +177,6 @@ def run(self, prepadded_width, bboxes, scores) - print('Windowsize:', len(bboxes)) # stack results bboxes = torch.stack(bboxes) scores = torch.Tensor(scores) diff --git a/napari_organoid_counter/_utils.py b/napari_organoid_counter/_utils.py index 89b685c..541fa84 100644 --- a/napari_organoid_counter/_utils.py +++ b/napari_organoid_counter/_utils.py @@ -1,6 +1,7 @@ from contextlib import contextmanager import os from pathlib import Path +import pkgutil import numpy as np import math @@ -169,4 +170,26 @@ def apply_normalization(img): img_max = np.max(img) # 2899.25 png 178 img_norm = (255 * (img - img_min) / (img_max - img_min)).astype(np.uint8) return img_norm - \ No newline at end of file + +def get_package_init_file(package_name): + loader = pkgutil.get_loader(package_name) + if loader is None or not hasattr(loader, 'get_filename'): + raise ImportError(f"Cannot find package {package_name}") + package_path = loader.get_filename(package_name) + # Determine the path to the __init__.py file + if os.path.isdir(package_path): + init_file_path = os.path.join(package_path, '__init__.py') + else: + init_file_path = package_path + if not os.path.isfile(init_file_path): + raise FileNotFoundError(f"__init__.py file not found for package {package_name}") + return init_file_path + +def update_version_in_mmdet_init_file(package_name, old_version, new_version): + init_file_path = get_package_init_file(package_name) + with open(init_file_path, 'r') as file: + lines = file.readlines() + with open(init_file_path, 'w') as file: + for line in lines: + if f"mmcv_maximum_version = '{old_version}'" in line: + file.write(line.replace(old_version, new_version)) \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index ca78013..f848343 100644 --- a/setup.cfg +++ b/setup.cfg @@ -30,17 +30,16 @@ project_urls = packages = napari_organoid_counter include_package_data = True -python_requires = - ==3.8.* +python_requires = >=3.9, <3.11 setup_requires = setuptools_scm # add your package requirements here install_requires = - napari[all]>=0.4.17 + napari[all]>=0.4.17,<0.5.0 napari-aicsimageio>=0.7.2 torch>=2.3.1 torchvision>=0.18.1 mmengine>=0.10.4 - mmcv==2.1.0 + mmcv>=2.2.0 mmdet>=3.3.0 [options.extras_require] From 242863365b33aac5963cef80ff76700d7d1f08d7 Mon Sep 17 00:00:00 2001 From: christinab12 Date: Wed, 24 Jul 2024 11:04:25 +0200 Subject: [PATCH 06/37] added description for problems during installation --- .napari/DESCRIPTION.md | 17 ++++++++++++++--- setup.cfg | 3 ++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.napari/DESCRIPTION.md b/.napari/DESCRIPTION.md index 3ca73c6..c035736 100644 --- a/.napari/DESCRIPTION.md +++ b/.napari/DESCRIPTION.md @@ -1,12 +1,12 @@ ## Description -A napari plugin to automatically count lung organoids from microscopy imaging data. A Faster R-CNN model was trained on patches of microscopy data. Model inference is run using a sliding window approach, with a 50% overlap and the option for predicting on multiple window sizes and scales, the results of which are then merged using NMS. +A napari plugin to automatically count lung organoids from microscopy imaging data. Several object detection DL models were trained on patches of 2D microscopy data. Model inference is run using a sliding window approach, with a 50% overlap and the option for predicting on multiple window sizes and scales, the results of which are then merged using NMS. ![Alt Text](https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter/blob/main/readme-content/demo-plugin-v2.gif) ## What's new in v2? Here is a list of the main changes v2 of napari-organoid-counter offers: -* Use of Faster R-CNN model for object detection +* Use of DL models for object detection - pretrained models: Faster R-CNN, YOLOv3, SSD, and RTMDet. The data used for training these models along with the code for training can be found [here](https://www.kaggle.com/datasets/christinabukas/mutliorg). * Pyramid model inference with a sliding window approach and tunable parameters for window size and window downsampling rate * Model confidence added as tunable parameter * Allow to load and correct existing annotations (note: these must have been saved previously from v2 of this plugin) @@ -29,7 +29,18 @@ To install latest development version : pip install git+https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter.git -For installing on a Windows machine via napari, follow the instuctions [here](https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter/blob/main/readme-content/How%20to%20install%20on%20a%20Windows%20machine.pdf). + +**Notes** +1. If you have problems with the mmcv package installation, you may have an error like this once you start napari and try to select the plugin: +``` +ModuleNotFoundError: No module named 'mmcv._ext' +``` +In that case, you need to remove mmcv from the list of pip installed packages in your setup.cfg and instead install it using openmim as such: +``` +mim install mmcv==2.2.0 +``` + +2. For installing on a Windows machine directly from within napari, follow the instuctions [here](https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter/blob/main/readme-content/How%20to%20install%20on%20a%20Windows%20machine.pdf). ## Quickstart diff --git a/setup.cfg b/setup.cfg index f848343..4040211 100644 --- a/setup.cfg +++ b/setup.cfg @@ -38,9 +38,10 @@ install_requires = napari-aicsimageio>=0.7.2 torch>=2.3.1 torchvision>=0.18.1 + openmim mmengine>=0.10.4 - mmcv>=2.2.0 mmdet>=3.3.0 + mmcv>=2.2.0 [options.extras_require] testing = From f43f2e10949697e88d1fa3f774aa9c13e7a678a9 Mon Sep 17 00:00:00 2001 From: Christina Bukas <31160776+christinab12@users.noreply.github.com> Date: Wed, 24 Jul 2024 11:10:05 +0200 Subject: [PATCH 07/37] Update DESCRIPTION.md --- .napari/DESCRIPTION.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.napari/DESCRIPTION.md b/.napari/DESCRIPTION.md index c035736..d467d87 100644 --- a/.napari/DESCRIPTION.md +++ b/.napari/DESCRIPTION.md @@ -39,6 +39,7 @@ In that case, you need to remove mmcv from the list of pip installed packages in ``` mim install mmcv==2.2.0 ``` +Please do this in a new environment, using conda or alike. 2. For installing on a Windows machine directly from within napari, follow the instuctions [here](https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter/blob/main/readme-content/How%20to%20install%20on%20a%20Windows%20machine.pdf). From 19f8f7237cf17c6db5f5c7b4a0a62d1acda0bff8 Mon Sep 17 00:00:00 2001 From: Christina Bukas <31160776+christinab12@users.noreply.github.com> Date: Wed, 24 Jul 2024 11:10:09 +0200 Subject: [PATCH 08/37] Update README.md --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4489697..7820394 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,18 @@ For the dev branch you can clone this repo and install with: pip install -e . -For installing on a Windows machine via napari, follow the instuctions [here](https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter/blob/main/readme-content/How%20to%20install%20on%20a%20Windows%20machine.pdf). +**Notes** +1. If you have problems with the mmcv package installation, you may have an error like this once you start napari and try to select the plugin: +``` +ModuleNotFoundError: No module named 'mmcv._ext' +``` +In that case, you need to remove mmcv from the list of pip installed packages in your setup.cfg and instead install it using openmim as such: +``` +mim install mmcv==2.2.0 +``` +Please do this in a new environment, using conda or alike. + +2. For installing on a Windows machine directly from within napari, follow the instuctions [here](https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter/blob/main/readme-content/How%20to%20install%20on%20a%20Windows%20machine.pdf). ## What's new in v2? Checkout our *What's New in v2* [here](https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter/blob/main/.napari/DESCRIPTION.md#whats-new-in-v2). From fe89f086d12d0170d4ccc0d9d8732198cef3f24b Mon Sep 17 00:00:00 2001 From: Christina Bukas <31160776+christinab12@users.noreply.github.com> Date: Wed, 24 Jul 2024 11:15:05 +0200 Subject: [PATCH 09/37] Update DESCRIPTION.md --- .napari/DESCRIPTION.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.napari/DESCRIPTION.md b/.napari/DESCRIPTION.md index d467d87..4834942 100644 --- a/.napari/DESCRIPTION.md +++ b/.napari/DESCRIPTION.md @@ -81,6 +81,10 @@ This plugin has been developed and tested with 2D CZI microscopy images of lunch [2] Eva Maxfield Brown, Talley Lambert, Peter Sobolewski, Napari-AICSImageIO Contributors (2021). Napari-AICSImageIO: Image Reading in Napari using AICSImageIO [Computer software]. GitHub. https://github.com/AllenCellModeling/napari-aicsimageio +The latest version also uses models developed with the ```mmdetection``` package [3], see [here](https://github.com/open-mmlab/mmdetection) +[3] Chen, Kai, et al. "MMDetection: Open mmlab detection toolbox and benchmark." arXiv preprint arXiv:1906.07155 (2019). + + ## How to Cite If you use this plugin for your work, please cite it using the following: From 92dcde8fa6b3eef54f9900bc2f775c592ac393cc Mon Sep 17 00:00:00 2001 From: Christina Bukas <31160776+christinab12@users.noreply.github.com> Date: Wed, 24 Jul 2024 11:15:24 +0200 Subject: [PATCH 10/37] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 7820394..01cda47 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,9 @@ Distributed under the terms of the [MIT] license, [2] Eva Maxfield Brown, Talley Lambert, Peter Sobolewski, Napari-AICSImageIO Contributors (2021). Napari-AICSImageIO: Image Reading in Napari using AICSImageIO [Computer software]. GitHub. https://github.com/AllenCellModeling/napari-aicsimageio +The latest version also uses models developed with the ```mmdetection``` package [3], see [here](https://github.com/open-mmlab/mmdetection) +[3] Chen, Kai, et al. "MMDetection: Open mmlab detection toolbox and benchmark." arXiv preprint arXiv:1906.07155 (2019). + ## Issues If you encounter any problems, please [file an issue] along with a detailed description. From 6287a94c2ed440603a644a5f5b40d77ed9d3e0c3 Mon Sep 17 00:00:00 2001 From: christinab12 Date: Wed, 24 Jul 2024 11:26:08 +0200 Subject: [PATCH 11/37] remove python 3.8 support --- .github/workflows/test_and_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 99d15f5..dcb45c0 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -21,7 +21,7 @@ jobs: strategy: matrix: platform: [ubuntu-latest, windows-latest, macos-latest] - python-version: [3.8, 3.9, "3.10"] + python-version: [3.9, "3.10"] env: DISPLAY: ':99.0' steps: From 80e6f503c7fc4abd79ac77673ad64e5a980c13b3 Mon Sep 17 00:00:00 2001 From: christinab12 Date: Wed, 24 Jul 2024 13:53:39 +0200 Subject: [PATCH 12/37] attempt to remove mmcv from pip installation --- .github/workflows/test_and_deploy.yml | 13 ++++++------- post_install.py | 12 ++++++++++++ setup.cfg | 1 - tox.ini | 9 +++++---- 4 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 post_install.py diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index dcb45c0..76f05c9 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -46,16 +46,12 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest pytest-cookies tox + python -m pip install tox # this runs the platform-specific tests declared in tox.ini - - name: Test - uses: aganders3/headless-gui@v1 - with: - run: | - pip install -e ".[testing]" - python -m pytest -s -v --color=yes + - name: Test with tox + run: tox env: PLATFORM: ${{ matrix.platform }} @@ -77,6 +73,9 @@ jobs: python -m pip install --upgrade pip pip install twine pip install build + pip install openmim + - name: Run post_install.py + run: python post_install.py - name: Build and publish env: TWINE_USERNAME: __token__ diff --git a/post_install.py b/post_install.py new file mode 100644 index 0000000..7ef780a --- /dev/null +++ b/post_install.py @@ -0,0 +1,12 @@ +import subprocess +import sys + +def install_mmcv(): + try: + subprocess.check_call([sys.executable, '-m', 'mim', 'install', 'mmcv>=2.2.0']) + except subprocess.CalledProcessError as e: + print(f"Failed to install mmcv: {e}") + sys.exit(1) + +if __name__ == "__main__": + install_mmcv() diff --git a/setup.cfg b/setup.cfg index 4040211..20378c5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -41,7 +41,6 @@ install_requires = openmim mmengine>=0.10.4 mmdet>=3.3.0 - mmcv>=2.2.0 [options.extras_require] testing = diff --git a/tox.ini b/tox.ini index 2bb6897..e924407 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,9 @@ -# For more information about tox, see https://tox.readthedocs.io/en/latest/ [tox] -envlist = py{38,39,310}-{linux,macos,windows} +envlist = py{39,310}-{linux,macos,windows} isolated_build=true [gh-actions] python = - 3.8: py38 3.9: py39 3.10: py310 @@ -29,4 +27,7 @@ passenv = PYVISTA_OFF_SCREEN extras = testing -commands = pytest -v --color=yes --cov=napari_organoid_counter --cov-report=xml \ No newline at end of file +commands = + pip install . + python post_install.py + pytest -v --color=yes --cov=napari_organoid_counter --cov-report=xml From bd8defdd34b7828827e0edc5d247abf25da5a94d Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 13:58:48 +0200 Subject: [PATCH 13/37] remove tox, go back to pytest --- .github/workflows/test_and_deploy.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 76f05c9..0ed7f40 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -46,12 +46,15 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install tox + python -m pip install pytest pytest-qt pytest-cookies - # this runs the platform-specific tests declared in tox.ini - - - name: Test with tox - run: tox + - name: Test + uses: aganders3/headless-gui@v1 + with: + run: | + pip install -e ".[testing]" + mim install mmcv>=2.2.0 + python -m pytest -s -v --color=yes env: PLATFORM: ${{ matrix.platform }} From 8944912efc4e4bb6f089faa28185532e0b8ecc75 Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 14:02:32 +0200 Subject: [PATCH 14/37] fix indent --- .github/workflows/test_and_deploy.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 0ed7f40..f9158b5 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -49,14 +49,14 @@ jobs: python -m pip install pytest pytest-qt pytest-cookies - name: Test - uses: aganders3/headless-gui@v1 - with: - run: | - pip install -e ".[testing]" - mim install mmcv>=2.2.0 - python -m pytest -s -v --color=yes - env: - PLATFORM: ${{ matrix.platform }} + uses: aganders3/headless-gui@v1 + with: + run: | + pip install -e ".[testing]" + mim install mmcv>=2.2.0 + python -m pytest -s -v --color=yes + env: + PLATFORM: ${{ matrix.platform }} deploy: # this will run when you have tagged a commit, starting with "v*" From 503e949fa786170c1ac56709416e6be9b0b28cae Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 14:30:01 +0200 Subject: [PATCH 15/37] remove post_install update readmes --- .github/workflows/test_and_deploy.yml | 9 +++---- .napari/DESCRIPTION.md | 24 +++++++----------- README.md | 36 ++++++++++----------------- post_install.py | 12 --------- tox.ini | 2 +- 5 files changed, 26 insertions(+), 57 deletions(-) delete mode 100644 post_install.py diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index f9158b5..4a738db 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -53,10 +53,10 @@ jobs: with: run: | pip install -e ".[testing]" - mim install mmcv>=2.2.0 + mim install "mmcv>=2.2.0" python -m pytest -s -v --color=yes - env: - PLATFORM: ${{ matrix.platform }} + env: + PLATFORM: ${{ matrix.platform }} deploy: # this will run when you have tagged a commit, starting with "v*" @@ -76,9 +76,6 @@ jobs: python -m pip install --upgrade pip pip install twine pip install build - pip install openmim - - name: Run post_install.py - run: python post_install.py - name: Build and publish env: TWINE_USERNAME: __token__ diff --git a/.napari/DESCRIPTION.md b/.napari/DESCRIPTION.md index 4834942..01bc162 100644 --- a/.napari/DESCRIPTION.md +++ b/.napari/DESCRIPTION.md @@ -20,28 +20,21 @@ Technical Extensions: ## Installation -You can install `napari-organoid-counter` via [pip](https://pypi.org/project/napari-organoid-counter/): +This plugin has been tested with python 3.9 and 3.10 - you may consider using conda to create your dedicated environment before running the `napari-organoid-counter`. - pip install napari-organoid-counter +1. You can install `napari-organoid-counter` via [pip](https://pypi.org/project/napari-organoid-counter/): + ```pip install napari-organoid-counter``` -To install latest development version : + To install latest development version : - pip install git+https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter.git + ```pip install git+https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter.git``` +2. Additionally, you will then need to install one additional dependency: -**Notes** -1. If you have problems with the mmcv package installation, you may have an error like this once you start napari and try to select the plugin: -``` -ModuleNotFoundError: No module named 'mmcv._ext' -``` -In that case, you need to remove mmcv from the list of pip installed packages in your setup.cfg and instead install it using openmim as such: -``` -mim install mmcv==2.2.0 -``` -Please do this in a new environment, using conda or alike. + ``` mim install "mmcv>=2.2.0" ``` -2. For installing on a Windows machine directly from within napari, follow the instuctions [here](https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter/blob/main/readme-content/How%20to%20install%20on%20a%20Windows%20machine.pdf). +For installing on a Windows machine directly from within napari, follow the instuctions [here](https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter/blob/main/readme-content/How%20to%20install%20on%20a%20Windows%20machine.pdf). Step 2 additionally needs to be performed here too (mim install "mmcv>=2.2.0"). ## Quickstart @@ -82,6 +75,7 @@ This plugin has been developed and tested with 2D CZI microscopy images of lunch [2] Eva Maxfield Brown, Talley Lambert, Peter Sobolewski, Napari-AICSImageIO Contributors (2021). Napari-AICSImageIO: Image Reading in Napari using AICSImageIO [Computer software]. GitHub. https://github.com/AllenCellModeling/napari-aicsimageio The latest version also uses models developed with the ```mmdetection``` package [3], see [here](https://github.com/open-mmlab/mmdetection) + [3] Chen, Kai, et al. "MMDetection: Open mmlab detection toolbox and benchmark." arXiv preprint arXiv:1906.07155 (2019). diff --git a/README.md b/README.md index 01cda47..a248f7a 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,14 @@ # Napari Organoid Counter - Version 0.2 is out! +[![napari hub](https://img.shields.io/endpoint?url=https://api.napari-hub.org/shields/napari-organoid-counter)](https://napari-hub.org/plugins/napari-organoid-counter) ![stability-stable](https://img.shields.io/badge/stability-stable-green.svg) [![DOI](https://zenodo.org/badge/476715320.svg)](https://zenodo.org/badge/latestdoi/476715320) [![License](https://img.shields.io/pypi/l/napari-organoid-counter.svg?color=green)](https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter/raw/main/LICENSE) [![PyPI](https://img.shields.io/pypi/v/napari-organoid-counter.svg?color=green)](https://pypi.org/project/napari-organoid-counter) -[![Python Version](https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10-blue)](https://python.org) +[![Python Version](https://img.shields.io/badge/python-3.9%20%7C%203.10-blue)](https://python.org) [![tests](https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter/workflows/tests/badge.svg)](https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter/actions) [![codecov](https://codecov.io/gh/HelmholtzAI-Consultants-Munich/napari-organoid-counter/branch/main/graph/badge.svg)](https://codecov.io/gh/HelmholtzAI-Consultants-Munich/napari-organoid-counter) -[![napari hub](https://img.shields.io/endpoint?url=https://api.napari-hub.org/shields/napari-organoid-counter)](https://napari-hub.org/plugins/napari-organoid-counter) + A napari plugin to automatically count lung organoids from microscopy imaging data. Note: this plugin only supports single channel grayscale images. @@ -22,32 +23,21 @@ This [napari] plugin was generated with [Cookiecutter] using [@napari]'s [cookie ## Installation -You can install `napari-organoid-counter` via [pip]: +This plugin has been tested with python 3.9 and 3.10 - you may consider using conda to create your dedicated environment before running the `napari-organoid-counter`. - pip install napari-organoid-counter +1. You can install `napari-organoid-counter` via [pip](https://pypi.org/project/napari-organoid-counter/): + ``` pip install napari-organoid-counter``` -To install latest development version : + To install latest development version : - pip install git+https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter.git - - -For the dev branch you can clone this repo and install with: + ```pip install git+https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter.git``` - pip install -e . +2. Additionally, you will then need to install one additional dependency: -**Notes** -1. If you have problems with the mmcv package installation, you may have an error like this once you start napari and try to select the plugin: -``` -ModuleNotFoundError: No module named 'mmcv._ext' -``` -In that case, you need to remove mmcv from the list of pip installed packages in your setup.cfg and instead install it using openmim as such: -``` -mim install mmcv==2.2.0 -``` -Please do this in a new environment, using conda or alike. + ``` mim install "mmcv>=2.2.0" ``` -2. For installing on a Windows machine directly from within napari, follow the instuctions [here](https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter/blob/main/readme-content/How%20to%20install%20on%20a%20Windows%20machine.pdf). +For installing on a Windows machine directly from within napari, follow the instuctions [here](https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter/blob/main/readme-content/How%20to%20install%20on%20a%20Windows%20machine.pdf). Step 2 additionally needs to be performed here too (mim install "mmcv>=2.2.0). ## What's new in v2? Checkout our *What's New in v2* [here](https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter/blob/main/.napari/DESCRIPTION.md#whats-new-in-v2). @@ -59,7 +49,7 @@ For more information on this plugin, its' intended audience, as well as Quicksta ## Contributing -Contributions are very welcome. Tests can be run with [tox], please ensure +Contributions are very welcome. Tests can be run with [pytest], please ensure the coverage at least stays the same before you submit a pull request. ## License @@ -77,6 +67,7 @@ Distributed under the terms of the [MIT] license, [2] Eva Maxfield Brown, Talley Lambert, Peter Sobolewski, Napari-AICSImageIO Contributors (2021). Napari-AICSImageIO: Image Reading in Napari using AICSImageIO [Computer software]. GitHub. https://github.com/AllenCellModeling/napari-aicsimageio The latest version also uses models developed with the ```mmdetection``` package [3], see [here](https://github.com/open-mmlab/mmdetection) + [3] Chen, Kai, et al. "MMDetection: Open mmlab detection toolbox and benchmark." arXiv preprint arXiv:1906.07155 (2019). ## Issues @@ -97,7 +88,6 @@ If you encounter any problems, please [file an issue] along with a detailed desc [file an issue]: https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter/issues [napari]: https://github.com/napari/napari -[tox]: https://tox.readthedocs.io/en/latest/ [pip]: https://pypi.org/project/pip/ [PyPI]: https://pypi.org/ diff --git a/post_install.py b/post_install.py deleted file mode 100644 index 7ef780a..0000000 --- a/post_install.py +++ /dev/null @@ -1,12 +0,0 @@ -import subprocess -import sys - -def install_mmcv(): - try: - subprocess.check_call([sys.executable, '-m', 'mim', 'install', 'mmcv>=2.2.0']) - except subprocess.CalledProcessError as e: - print(f"Failed to install mmcv: {e}") - sys.exit(1) - -if __name__ == "__main__": - install_mmcv() diff --git a/tox.ini b/tox.ini index e924407..c0dc644 100644 --- a/tox.ini +++ b/tox.ini @@ -29,5 +29,5 @@ extras = testing commands = pip install . - python post_install.py + mim install "mmcv>=2.2.0" pytest -v --color=yes --cov=napari_organoid_counter --cov-report=xml From 23f8272e4005e11b246f71fa35c640a011f3186c Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 15:02:45 +0200 Subject: [PATCH 16/37] change mmcv version --- .github/workflows/test_and_deploy.yml | 2 +- .napari/DESCRIPTION.md | 4 ++-- README.md | 4 ++-- napari_organoid_counter/_orgacount.py | 2 +- setup.cfg | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 4a738db..e1c2718 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -53,7 +53,7 @@ jobs: with: run: | pip install -e ".[testing]" - mim install "mmcv>=2.2.0" + mim install "mmcv<2.2.0,>=2.0.0rc4" python -m pytest -s -v --color=yes env: PLATFORM: ${{ matrix.platform }} diff --git a/.napari/DESCRIPTION.md b/.napari/DESCRIPTION.md index 01bc162..da6cb33 100644 --- a/.napari/DESCRIPTION.md +++ b/.napari/DESCRIPTION.md @@ -32,9 +32,9 @@ This plugin has been tested with python 3.9 and 3.10 - you may consider using co 2. Additionally, you will then need to install one additional dependency: - ``` mim install "mmcv>=2.2.0" ``` + ``` mim install "mmcv<2.2.0,>=2.0.0rc4" ``` -For installing on a Windows machine directly from within napari, follow the instuctions [here](https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter/blob/main/readme-content/How%20to%20install%20on%20a%20Windows%20machine.pdf). Step 2 additionally needs to be performed here too (mim install "mmcv>=2.2.0"). +For installing on a Windows machine directly from within napari, follow the instuctions [here](https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter/blob/main/readme-content/How%20to%20install%20on%20a%20Windows%20machine.pdf). Step 2 additionally needs to be performed here too (mim install "mmcv<2.2.0,>=2.0.0rc4"). ## Quickstart diff --git a/README.md b/README.md index a248f7a..b316267 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,9 @@ This plugin has been tested with python 3.9 and 3.10 - you may consider using co 2. Additionally, you will then need to install one additional dependency: - ``` mim install "mmcv>=2.2.0" ``` + ``` mim install "mmcv<2.2.0,>=2.0.0rc4" ``` -For installing on a Windows machine directly from within napari, follow the instuctions [here](https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter/blob/main/readme-content/How%20to%20install%20on%20a%20Windows%20machine.pdf). Step 2 additionally needs to be performed here too (mim install "mmcv>=2.2.0). +For installing on a Windows machine directly from within napari, follow the instuctions [here](https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter/blob/main/readme-content/How%20to%20install%20on%20a%20Windows%20machine.pdf). Step 2 additionally needs to be performed here too (mim install "mmcv<2.2.0,>=2.0.0rc4"). ## What's new in v2? Checkout our *What's New in v2* [here](https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter/blob/main/.napari/DESCRIPTION.md#whats-new-in-v2). diff --git a/napari_organoid_counter/_orgacount.py b/napari_organoid_counter/_orgacount.py index 6bf6296..803ef9f 100644 --- a/napari_organoid_counter/_orgacount.py +++ b/napari_organoid_counter/_orgacount.py @@ -4,7 +4,7 @@ from napari_organoid_counter._utils import * from napari_organoid_counter import settings -update_version_in_mmdet_init_file('mmdet', '2.2.0', '2.2.1') +#update_version_in_mmdet_init_file('mmdet', '2.2.0', '2.2.1') import torch import mmdet from mmdet.apis import DetInferencer diff --git a/setup.cfg b/setup.cfg index 20378c5..04b9973 100644 --- a/setup.cfg +++ b/setup.cfg @@ -5,7 +5,7 @@ author = christinab12 author_email = christina.bukas@helmholtz-muenchen.de url = https://github.com/HelmholtzAI-Consultants-Munich/napari-organoid-counter license = MIT -description = A plugin to automatically count lung organoids +description = A plugin to automatically count lung organoids using Deep Learning. long_description = file: README.md long_description_content_type = text/markdown classifiers = From d491e998ec37a11ed8301688bd3a602dd7c289de Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 15:13:29 +0200 Subject: [PATCH 17/37] remove macos --- .github/workflows/test_and_deploy.yml | 6 +++--- napari_organoid_counter/napari.yaml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index e1c2718..8dafc09 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -20,7 +20,7 @@ jobs: runs-on: ${{ matrix.platform }} strategy: matrix: - platform: [ubuntu-latest, windows-latest, macos-latest] + platform: [ubuntu-latest, windows-latest] python-version: [3.9, "3.10"] env: DISPLAY: ':99.0' @@ -52,8 +52,8 @@ jobs: uses: aganders3/headless-gui@v1 with: run: | - pip install -e ".[testing]" - mim install "mmcv<2.2.0,>=2.0.0rc4" + pip install -e ".[testing]" --no-cache-dir + mim install "mmcv<2.2.0,>=2.0.0rc4" --no-cache-dir python -m pytest -s -v --color=yes env: PLATFORM: ${{ matrix.platform }} diff --git a/napari_organoid_counter/napari.yaml b/napari_organoid_counter/napari.yaml index cb891a4..80cf637 100644 --- a/napari_organoid_counter/napari.yaml +++ b/napari_organoid_counter/napari.yaml @@ -1,5 +1,5 @@ name: napari-organoid-counter -display_name: napari OrganoidCounter +display_name: napari organoid counter contributions: commands: - id: napari-organoid-counter.OrganoidCounterWidget From 51a96bee5fb22d37a720e7e240d5065d924915d2 Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 15:24:17 +0200 Subject: [PATCH 18/37] set mmcv download loc --- .github/workflows/test_and_deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 8dafc09..f9ba6d8 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -20,7 +20,7 @@ jobs: runs-on: ${{ matrix.platform }} strategy: matrix: - platform: [ubuntu-latest, windows-latest] + platform: [ubuntu-latest, windows-latest, macos-latest] python-version: [3.9, "3.10"] env: DISPLAY: ':99.0' @@ -53,7 +53,7 @@ jobs: with: run: | pip install -e ".[testing]" --no-cache-dir - mim install "mmcv<2.2.0,>=2.0.0rc4" --no-cache-dir + mim install "mmcv<2.2.0,>=2.0.0rc4" --no-cache-dir -f https://download.openmmlab.com/mmcv/dist/cpu/torch2.4.0/index.html python -m pytest -s -v --color=yes env: PLATFORM: ${{ matrix.platform }} From 674cb0ff55b8beec3cd31c680bc452817081bfa3 Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 17:16:16 +0200 Subject: [PATCH 19/37] change mmcv install --- .github/workflows/test_and_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index f9ba6d8..fbc9e18 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -53,7 +53,7 @@ jobs: with: run: | pip install -e ".[testing]" --no-cache-dir - mim install "mmcv<2.2.0,>=2.0.0rc4" --no-cache-dir -f https://download.openmmlab.com/mmcv/dist/cpu/torch2.4.0/index.html + python -m pip install "mmcv-full<2.2.0,>=2.0.0rc4" -f https://download.openmmlab.com/mmcv/dist/cpu/torch2.4.0/index.html python -m pytest -s -v --color=yes env: PLATFORM: ${{ matrix.platform }} From 54089d2ac4f227e9671096bda6e0b8e4501582e7 Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 17:21:02 +0200 Subject: [PATCH 20/37] mim install with python --- .github/workflows/test_and_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index fbc9e18..966ccbd 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -53,7 +53,7 @@ jobs: with: run: | pip install -e ".[testing]" --no-cache-dir - python -m pip install "mmcv-full<2.2.0,>=2.0.0rc4" -f https://download.openmmlab.com/mmcv/dist/cpu/torch2.4.0/index.html + python -m mim install "mmcv<2.2.0,>=2.0.0rc4" -f https://download.openmmlab.com/mmcv/dist/cpu/torch2.4.0/index.html python -m pytest -s -v --color=yes env: PLATFORM: ${{ matrix.platform }} From bf936c8371dd471c6e340d440159afadef331424 Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 17:26:36 +0200 Subject: [PATCH 21/37] trying with lite --- .github/workflows/test_and_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 966ccbd..a0895f4 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -53,7 +53,7 @@ jobs: with: run: | pip install -e ".[testing]" --no-cache-dir - python -m mim install "mmcv<2.2.0,>=2.0.0rc4" -f https://download.openmmlab.com/mmcv/dist/cpu/torch2.4.0/index.html + python -m mim install "mmcv-lite<2.2.0,>=2.0.0rc4" -f https://download.openmmlab.com/mmcv/dist/cpu/torch2.4.0/index.html python -m pytest -s -v --color=yes env: PLATFORM: ${{ matrix.platform }} From f2f986469bd2341f91d97a77b4074abe925616df Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 17:32:31 +0200 Subject: [PATCH 22/37] test mmcv --- .github/workflows/test_mmcv.yml | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/test_mmcv.yml diff --git a/.github/workflows/test_mmcv.yml b/.github/workflows/test_mmcv.yml new file mode 100644 index 0000000..06f5df0 --- /dev/null +++ b/.github/workflows/test_mmcv.yml @@ -0,0 +1,38 @@ +name: Install and Test MMCV +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: +jobs: + install-and-test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.9, ‘3.10’] + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + # Install mmcv-full, adjust the link to match the appropriate version of Python and PyTorch as needed + pip install mmcv-full --find-links https://download.openmmlab.com/mmcv/dist/${{ matrix.python-version }}/torch1.8.0/cpu + - name: Verify Installation + run: | + python -m pip list + python -c “import mmcv; print(‘MMCV version:’, mmcv.__version__)” + python -c “import mmcv; print(‘MMCV installation path:’, mmcv.__file__)” + + + + + + From f87e462330778897230f1f105b905f4898c3afc0 Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 17:33:35 +0200 Subject: [PATCH 23/37] python quotes --- .github/workflows/test_mmcv.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_mmcv.yml b/.github/workflows/test_mmcv.yml index 06f5df0..c7e7f54 100644 --- a/.github/workflows/test_mmcv.yml +++ b/.github/workflows/test_mmcv.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.9, ‘3.10’] + python-version: [3.9, "3.10"] steps: - name: Checkout Repository uses: actions/checkout@v3 From efe5185653f7e8ee4a8a2d631f441af8405cb575 Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 17:33:53 +0200 Subject: [PATCH 24/37] python --- .github/workflows/test_mmcv.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_mmcv.yml b/.github/workflows/test_mmcv.yml index c7e7f54..2aff6da 100644 --- a/.github/workflows/test_mmcv.yml +++ b/.github/workflows/test_mmcv.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.9, "3.10"] + python-version: ["3.10"] steps: - name: Checkout Repository uses: actions/checkout@v3 From 3e58878a9e861d3d3fa7ad34628095ff0842efe1 Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 17:35:28 +0200 Subject: [PATCH 25/37] quotations --- .github/workflows/test_mmcv.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_mmcv.yml b/.github/workflows/test_mmcv.yml index 2aff6da..40f4a7d 100644 --- a/.github/workflows/test_mmcv.yml +++ b/.github/workflows/test_mmcv.yml @@ -28,8 +28,8 @@ jobs: - name: Verify Installation run: | python -m pip list - python -c “import mmcv; print(‘MMCV version:’, mmcv.__version__)” - python -c “import mmcv; print(‘MMCV installation path:’, mmcv.__file__)” + python -c "import mmcv; print('MMCV version:', mmcv.__version__)" + python -c "import mmcv; print('MMCV installation path:', mmcv.__file__)" From 28475a2da4300b293428f722babaf4620c598978 Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 17:37:10 +0200 Subject: [PATCH 26/37] try mmcv --- .github/workflows/test_mmcv.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_mmcv.yml b/.github/workflows/test_mmcv.yml index 40f4a7d..5b77313 100644 --- a/.github/workflows/test_mmcv.yml +++ b/.github/workflows/test_mmcv.yml @@ -24,7 +24,7 @@ jobs: run: | python -m pip install --upgrade pip # Install mmcv-full, adjust the link to match the appropriate version of Python and PyTorch as needed - pip install mmcv-full --find-links https://download.openmmlab.com/mmcv/dist/${{ matrix.python-version }}/torch1.8.0/cpu + pip install mmcv --find-links https://download.openmmlab.com/mmcv/dist/${{ matrix.python-version }}/torch1.8.0/cpu - name: Verify Installation run: | python -m pip list From e6ac1e15c49743921a6c652c17086ddd8ac528fb Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 17:38:47 +0200 Subject: [PATCH 27/37] comment --- .github/workflows/test_and_deploy.yml | 154 +++++++++++++------------- 1 file changed, 77 insertions(+), 77 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index a0895f4..24dc998 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -1,87 +1,87 @@ -# This workflows will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries +# # This workflows will upload a Python Package using Twine when a release is created +# # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries -name: tests +# name: tests -on: - push: - branches: - - main - tags: - - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 - pull_request: - branches: - - main - workflow_dispatch: +# on: +# push: +# branches: +# - main +# tags: +# - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 +# pull_request: +# branches: +# - main +# workflow_dispatch: -jobs: - test: - name: ${{ matrix.platform }} py${{ matrix.python-version }} - runs-on: ${{ matrix.platform }} - strategy: - matrix: - platform: [ubuntu-latest, windows-latest, macos-latest] - python-version: [3.9, "3.10"] - env: - DISPLAY: ':99.0' - steps: - - name: Checkout Repository - uses: actions/checkout@v3 +# jobs: +# test: +# name: ${{ matrix.platform }} py${{ matrix.python-version }} +# runs-on: ${{ matrix.platform }} +# strategy: +# matrix: +# platform: [ubuntu-latest, windows-latest, macos-latest] +# python-version: [3.9, "3.10"] +# env: +# DISPLAY: ':99.0' +# steps: +# - name: Checkout Repository +# uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} +# - name: Set up Python ${{ matrix.python-version }} +# uses: actions/setup-python@v3 +# with: +# python-version: ${{ matrix.python-version }} - # these libraries enable testing on Qt on linux - - uses: tlambert03/setup-qt-libs@v1 +# # these libraries enable testing on Qt on linux +# - uses: tlambert03/setup-qt-libs@v1 - # strategy borrowed from vispy for installing opengl libs on windows - - name: Install Windows OpenGL - if: runner.os == 'Windows' - run: | - git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git - powershell gl-ci-helpers/appveyor/install_opengl.ps1 +# # strategy borrowed from vispy for installing opengl libs on windows +# - name: Install Windows OpenGL +# if: runner.os == 'Windows' +# run: | +# git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git +# powershell gl-ci-helpers/appveyor/install_opengl.ps1 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install pytest pytest-qt pytest-cookies +# - name: Install dependencies +# run: | +# python -m pip install --upgrade pip +# python -m pip install pytest pytest-qt pytest-cookies - - name: Test - uses: aganders3/headless-gui@v1 - with: - run: | - pip install -e ".[testing]" --no-cache-dir - python -m mim install "mmcv-lite<2.2.0,>=2.0.0rc4" -f https://download.openmmlab.com/mmcv/dist/cpu/torch2.4.0/index.html - python -m pytest -s -v --color=yes - env: - PLATFORM: ${{ matrix.platform }} +# - name: Test +# uses: aganders3/headless-gui@v1 +# with: +# run: | +# pip install -e ".[testing]" --no-cache-dir +# python -m mim install "mmcv-lite<2.2.0,>=2.0.0rc4" +# python -m pytest -s -v --color=yes +# env: +# PLATFORM: ${{ matrix.platform }} - deploy: - # this will run when you have tagged a commit, starting with "v*" - # and requires that you have put your twine API key in your - # github secrets (see readme for details) - needs: [test] - runs-on: ubuntu-latest - if: contains(github.ref, 'tags') - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: "3.x" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install twine - pip install build - - name: Build and publish - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }} - run: | - git tag - python -m build . - twine upload dist/* +# deploy: +# # this will run when you have tagged a commit, starting with "v*" +# # and requires that you have put your twine API key in your +# # github secrets (see readme for details) +# needs: [test] +# runs-on: ubuntu-latest +# if: contains(github.ref, 'tags') +# steps: +# - uses: actions/checkout@v3 +# - name: Set up Python +# uses: actions/setup-python@v3 +# with: +# python-version: "3.x" +# - name: Install dependencies +# run: | +# python -m pip install --upgrade pip +# pip install twine +# pip install build +# - name: Build and publish +# env: +# TWINE_USERNAME: __token__ +# TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }} +# run: | +# git tag +# python -m build . +# twine upload dist/* From 034f081cfa86e4ea8b9f69cd0bf57fef821c9670 Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 17:41:49 +0200 Subject: [PATCH 28/37] change install --- .github/workflows/test_and_deploy.yml | 154 +++++++++++++------------- .github/workflows/test_mmcv.yml | 64 +++++------ 2 files changed, 109 insertions(+), 109 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 24dc998..3be01f3 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -1,87 +1,87 @@ -# # This workflows will upload a Python Package using Twine when a release is created -# # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries +# This workflows will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries -# name: tests +name: tests -# on: -# push: -# branches: -# - main -# tags: -# - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 -# pull_request: -# branches: -# - main -# workflow_dispatch: +on: + push: + branches: + - main + tags: + - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 + pull_request: + branches: + - main + workflow_dispatch: -# jobs: -# test: -# name: ${{ matrix.platform }} py${{ matrix.python-version }} -# runs-on: ${{ matrix.platform }} -# strategy: -# matrix: -# platform: [ubuntu-latest, windows-latest, macos-latest] -# python-version: [3.9, "3.10"] -# env: -# DISPLAY: ':99.0' -# steps: -# - name: Checkout Repository -# uses: actions/checkout@v3 +jobs: + test: + name: ${{ matrix.platform }} py${{ matrix.python-version }} + runs-on: ${{ matrix.platform }} + strategy: + matrix: + platform: [ubuntu-latest, windows-latest, macos-latest] + python-version: [3.9, "3.10"] + env: + DISPLAY: ':99.0' + steps: + - name: Checkout Repository + uses: actions/checkout@v3 -# - name: Set up Python ${{ matrix.python-version }} -# uses: actions/setup-python@v3 -# with: -# python-version: ${{ matrix.python-version }} + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} -# # these libraries enable testing on Qt on linux -# - uses: tlambert03/setup-qt-libs@v1 + # these libraries enable testing on Qt on linux + - uses: tlambert03/setup-qt-libs@v1 -# # strategy borrowed from vispy for installing opengl libs on windows -# - name: Install Windows OpenGL -# if: runner.os == 'Windows' -# run: | -# git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git -# powershell gl-ci-helpers/appveyor/install_opengl.ps1 + # strategy borrowed from vispy for installing opengl libs on windows + - name: Install Windows OpenGL + if: runner.os == 'Windows' + run: | + git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git + powershell gl-ci-helpers/appveyor/install_opengl.ps1 -# - name: Install dependencies -# run: | -# python -m pip install --upgrade pip -# python -m pip install pytest pytest-qt pytest-cookies + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install pytest pytest-qt pytest-cookies -# - name: Test -# uses: aganders3/headless-gui@v1 -# with: -# run: | -# pip install -e ".[testing]" --no-cache-dir -# python -m mim install "mmcv-lite<2.2.0,>=2.0.0rc4" -# python -m pytest -s -v --color=yes -# env: -# PLATFORM: ${{ matrix.platform }} + - name: Test + uses: aganders3/headless-gui@v1 + with: + run: | + pip install -e ".[testing]" --no-cache-dir + pip install mmcv --find-links https://download.openmmlab.com/mmcv/dist/${{ matrix.python-version }}/torch1.8.0/cpu + python -m pytest -s -v --color=yes + env: + PLATFORM: ${{ matrix.platform }} -# deploy: -# # this will run when you have tagged a commit, starting with "v*" -# # and requires that you have put your twine API key in your -# # github secrets (see readme for details) -# needs: [test] -# runs-on: ubuntu-latest -# if: contains(github.ref, 'tags') -# steps: -# - uses: actions/checkout@v3 -# - name: Set up Python -# uses: actions/setup-python@v3 -# with: -# python-version: "3.x" -# - name: Install dependencies -# run: | -# python -m pip install --upgrade pip -# pip install twine -# pip install build -# - name: Build and publish -# env: -# TWINE_USERNAME: __token__ -# TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }} -# run: | -# git tag -# python -m build . -# twine upload dist/* + deploy: + # this will run when you have tagged a commit, starting with "v*" + # and requires that you have put your twine API key in your + # github secrets (see readme for details) + needs: [test] + runs-on: ubuntu-latest + if: contains(github.ref, 'tags') + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: "3.x" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install twine + pip install build + - name: Build and publish + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }} + run: | + git tag + python -m build . + twine upload dist/* diff --git a/.github/workflows/test_mmcv.yml b/.github/workflows/test_mmcv.yml index 5b77313..81d7624 100644 --- a/.github/workflows/test_mmcv.yml +++ b/.github/workflows/test_mmcv.yml @@ -1,35 +1,35 @@ -name: Install and Test MMCV -on: - push: - branches: - - main - pull_request: - branches: - - main - workflow_dispatch: -jobs: - install-and-test: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.10"] - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - name: Install Dependencies - run: | - python -m pip install --upgrade pip - # Install mmcv-full, adjust the link to match the appropriate version of Python and PyTorch as needed - pip install mmcv --find-links https://download.openmmlab.com/mmcv/dist/${{ matrix.python-version }}/torch1.8.0/cpu - - name: Verify Installation - run: | - python -m pip list - python -c "import mmcv; print('MMCV version:', mmcv.__version__)" - python -c "import mmcv; print('MMCV installation path:', mmcv.__file__)" +# name: Install and Test MMCV +# on: +# push: +# branches: +# - main +# pull_request: +# branches: +# - main +# workflow_dispatch: +# jobs: +# install-and-test: +# runs-on: ubuntu-latest +# strategy: +# matrix: +# python-version: ["3.10"] +# steps: +# - name: Checkout Repository +# uses: actions/checkout@v3 +# - name: Set up Python +# uses: actions/setup-python@v3 +# with: +# python-version: ${{ matrix.python-version }} +# - name: Install Dependencies +# run: | +# python -m pip install --upgrade pip +# # Install mmcv-full, adjust the link to match the appropriate version of Python and PyTorch as needed +# pip install mmcv --find-links https://download.openmmlab.com/mmcv/dist/${{ matrix.python-version }}/torch1.8.0/cpu +# - name: Verify Installation +# run: | +# python -m pip list +# python -c "import mmcv; print('MMCV version:', mmcv.__version__)" +# python -c "import mmcv; print('MMCV installation path:', mmcv.__file__)" From 6722a1dd131cb6446ff0d9041d294e5a24b7d44f Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 17:45:47 +0200 Subject: [PATCH 29/37] add compatibility fix --- napari_organoid_counter/_orgacount.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/napari_organoid_counter/_orgacount.py b/napari_organoid_counter/_orgacount.py index 803ef9f..535676b 100644 --- a/napari_organoid_counter/_orgacount.py +++ b/napari_organoid_counter/_orgacount.py @@ -4,7 +4,7 @@ from napari_organoid_counter._utils import * from napari_organoid_counter import settings -#update_version_in_mmdet_init_file('mmdet', '2.2.0', '2.2.1') +update_version_in_mmdet_init_file('mmdet', '2.2.0', '2.3.0') import torch import mmdet from mmdet.apis import DetInferencer From 7a7cbc7a10d7a63f0155467799aa04a6dee02790 Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 17:51:29 +0200 Subject: [PATCH 30/37] change v --- .github/workflows/test_and_deploy.yml | 6 +++--- napari_organoid_counter/_orgacount.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 3be01f3..08dbd88 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -20,8 +20,8 @@ jobs: runs-on: ${{ matrix.platform }} strategy: matrix: - platform: [ubuntu-latest, windows-latest, macos-latest] - python-version: [3.9, "3.10"] + platform: [ubuntu-latest] #, windows-latest, macos-latest] + python-version: ["3.10"] # 3.9, env: DISPLAY: ':99.0' steps: @@ -53,7 +53,7 @@ jobs: with: run: | pip install -e ".[testing]" --no-cache-dir - pip install mmcv --find-links https://download.openmmlab.com/mmcv/dist/${{ matrix.python-version }}/torch1.8.0/cpu + pip install "mmcv<2.2.0,>=2.0.0rc4" --find-links https://download.openmmlab.com/mmcv/dist/${{ matrix.python-version }}/torch1.8.0/cpu python -m pytest -s -v --color=yes env: PLATFORM: ${{ matrix.platform }} diff --git a/napari_organoid_counter/_orgacount.py b/napari_organoid_counter/_orgacount.py index 535676b..8e655a2 100644 --- a/napari_organoid_counter/_orgacount.py +++ b/napari_organoid_counter/_orgacount.py @@ -4,7 +4,7 @@ from napari_organoid_counter._utils import * from napari_organoid_counter import settings -update_version_in_mmdet_init_file('mmdet', '2.2.0', '2.3.0') +#update_version_in_mmdet_init_file('mmdet', '2.2.0', '2.3.0') import torch import mmdet from mmdet.apis import DetInferencer From 132edb017f870abebfc6e871f5cd0cbd07033243 Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 17:59:17 +0200 Subject: [PATCH 31/37] test --- .github/workflows/test_mmcv.yml | 64 ++++++++++++++++----------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/.github/workflows/test_mmcv.yml b/.github/workflows/test_mmcv.yml index 81d7624..ce5bc15 100644 --- a/.github/workflows/test_mmcv.yml +++ b/.github/workflows/test_mmcv.yml @@ -1,35 +1,35 @@ -# name: Install and Test MMCV -# on: -# push: -# branches: -# - main -# pull_request: -# branches: -# - main -# workflow_dispatch: -# jobs: -# install-and-test: -# runs-on: ubuntu-latest -# strategy: -# matrix: -# python-version: ["3.10"] -# steps: -# - name: Checkout Repository -# uses: actions/checkout@v3 -# - name: Set up Python -# uses: actions/setup-python@v3 -# with: -# python-version: ${{ matrix.python-version }} -# - name: Install Dependencies -# run: | -# python -m pip install --upgrade pip -# # Install mmcv-full, adjust the link to match the appropriate version of Python and PyTorch as needed -# pip install mmcv --find-links https://download.openmmlab.com/mmcv/dist/${{ matrix.python-version }}/torch1.8.0/cpu -# - name: Verify Installation -# run: | -# python -m pip list -# python -c "import mmcv; print('MMCV version:', mmcv.__version__)" -# python -c "import mmcv; print('MMCV installation path:', mmcv.__file__)" +name: Install and Test MMCV +on: + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: +jobs: + install-and-test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.10"] + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + # Install mmcv-full, adjust the link to match the appropriate version of Python and PyTorch as needed + pip install "mmcv<2.2.0,>=2.0.0rc4" --find-links https://download.openmmlab.com/mmcv/dist/${{ matrix.python-version }}/torch2.4.0/cpu + - name: Verify Installation + run: | + python -m pip list + python -c "import mmcv; print('MMCV version:', mmcv.__version__)" + python -c "import mmcv; print('MMCV installation path:', mmcv.__file__)" From 083c5f05f0ad00464cb90a4cd6ef5189ca906ef8 Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 18:01:29 +0200 Subject: [PATCH 32/37] toch --- .github/workflows/test_and_deploy.yml | 2 +- .github/workflows/test_mmcv.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 08dbd88..daf706d 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -53,7 +53,7 @@ jobs: with: run: | pip install -e ".[testing]" --no-cache-dir - pip install "mmcv<2.2.0,>=2.0.0rc4" --find-links https://download.openmmlab.com/mmcv/dist/${{ matrix.python-version }}/torch1.8.0/cpu + pip install "mmcv<2.2.0,>=2.0.0rc4" --find-links https://download.openmmlab.com/mmcv/dist/${{ matrix.python-version }}/torch2.4.0/cpu python -m pytest -s -v --color=yes env: PLATFORM: ${{ matrix.platform }} diff --git a/.github/workflows/test_mmcv.yml b/.github/workflows/test_mmcv.yml index ce5bc15..67a5c50 100644 --- a/.github/workflows/test_mmcv.yml +++ b/.github/workflows/test_mmcv.yml @@ -24,6 +24,7 @@ jobs: run: | python -m pip install --upgrade pip # Install mmcv-full, adjust the link to match the appropriate version of Python and PyTorch as needed + pip install "torch>=2.3.1" pip install "mmcv<2.2.0,>=2.0.0rc4" --find-links https://download.openmmlab.com/mmcv/dist/${{ matrix.python-version }}/torch2.4.0/cpu - name: Verify Installation run: | From 4974bdaaa806a403195a3bc7f5f88b9a31f190eb Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 18:10:55 +0200 Subject: [PATCH 33/37] test2 --- .github/workflows/test_and_deploy.yml | 152 +++++++++++++------------- .github/workflows/test_mmcv.yml | 1 + 2 files changed, 76 insertions(+), 77 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index daf706d..8c2936e 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -1,87 +1,85 @@ -# This workflows will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries +# # This workflows will upload a Python Package using Twine when a release is created +# # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries -name: tests +# name: tests -on: - push: - branches: - - main - tags: - - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 - pull_request: - branches: - - main - workflow_dispatch: +# on: +# push: +# branches: +# - main +# tags: +# - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 +# pull_request: +# branches: +# - main +# workflow_dispatch: -jobs: - test: - name: ${{ matrix.platform }} py${{ matrix.python-version }} - runs-on: ${{ matrix.platform }} - strategy: - matrix: - platform: [ubuntu-latest] #, windows-latest, macos-latest] - python-version: ["3.10"] # 3.9, - env: - DISPLAY: ':99.0' - steps: - - name: Checkout Repository - uses: actions/checkout@v3 +# jobs: +# test: +# name: ${{ matrix.platform }} py${{ matrix.python-version }} +# runs-on: ${{ matrix.platform }} +# strategy: +# matrix: +# platform: [ubuntu-latest] #, windows-latest, macos-latest] +# python-version: ["3.10"] # 3.9, +# env: +# DISPLAY: ':99.0' +# steps: +# - name: Checkout Repository +# uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} +# - name: Set up Python ${{ matrix.python-version }} +# uses: actions/setup-python@v3 +# with: +# python-version: ${{ matrix.python-version }} - # these libraries enable testing on Qt on linux - - uses: tlambert03/setup-qt-libs@v1 +# # these libraries enable testing on Qt on linux +# - uses: tlambert03/setup-qt-libs@v1 - # strategy borrowed from vispy for installing opengl libs on windows - - name: Install Windows OpenGL - if: runner.os == 'Windows' - run: | - git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git - powershell gl-ci-helpers/appveyor/install_opengl.ps1 +# # strategy borrowed from vispy for installing opengl libs on windows +# - name: Install Windows OpenGL +# if: runner.os == 'Windows' +# run: | +# git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git +# powershell gl-ci-helpers/appveyor/install_opengl.ps1 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install pytest pytest-qt pytest-cookies +# - name: Install dependencies +# run: | +# python -m pip install --upgrade pip +# python -m pip install pytest pytest-qt pytest-cookies +# pip install -e ".[testing]" --no-cache-dir +# pip install "mmcv<2.2.0,>=2.0.0rc4" --find-links https://download.openmmlab.com/mmcv/dist/${{ matrix.python-version }}/torch2.4.0/cpu - - name: Test - uses: aganders3/headless-gui@v1 - with: - run: | - pip install -e ".[testing]" --no-cache-dir - pip install "mmcv<2.2.0,>=2.0.0rc4" --find-links https://download.openmmlab.com/mmcv/dist/${{ matrix.python-version }}/torch2.4.0/cpu - python -m pytest -s -v --color=yes - env: - PLATFORM: ${{ matrix.platform }} +# - name: Test +# uses: aganders3/headless-gui@v1 +# with: +# run: | +# python -m pytest -s -v --color=yes - deploy: - # this will run when you have tagged a commit, starting with "v*" - # and requires that you have put your twine API key in your - # github secrets (see readme for details) - needs: [test] - runs-on: ubuntu-latest - if: contains(github.ref, 'tags') - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: "3.x" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install twine - pip install build - - name: Build and publish - env: - TWINE_USERNAME: __token__ - TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }} - run: | - git tag - python -m build . - twine upload dist/* +# deploy: +# # this will run when you have tagged a commit, starting with "v*" +# # and requires that you have put your twine API key in your +# # github secrets (see readme for details) +# needs: [test] +# runs-on: ubuntu-latest +# if: contains(github.ref, 'tags') +# steps: +# - uses: actions/checkout@v3 +# - name: Set up Python +# uses: actions/setup-python@v3 +# with: +# python-version: "3.x" +# - name: Install dependencies +# run: | +# python -m pip install --upgrade pip +# pip install twine +# pip install build +# - name: Build and publish +# env: +# TWINE_USERNAME: __token__ +# TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }} +# run: | +# git tag +# python -m build . +# twine upload dist/* diff --git a/.github/workflows/test_mmcv.yml b/.github/workflows/test_mmcv.yml index 67a5c50..3b93798 100644 --- a/.github/workflows/test_mmcv.yml +++ b/.github/workflows/test_mmcv.yml @@ -31,6 +31,7 @@ jobs: python -m pip list python -c "import mmcv; print('MMCV version:', mmcv.__version__)" python -c "import mmcv; print('MMCV installation path:', mmcv.__file__)" + python -c "from mmcv.ops.roi_align import roi_align" From f8d3804fea3acaa389946de60f60e59f612b26df Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 18:13:45 +0200 Subject: [PATCH 34/37] mim --- .github/workflows/test_mmcv.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_mmcv.yml b/.github/workflows/test_mmcv.yml index 3b93798..b7d04b6 100644 --- a/.github/workflows/test_mmcv.yml +++ b/.github/workflows/test_mmcv.yml @@ -23,9 +23,9 @@ jobs: - name: Install Dependencies run: | python -m pip install --upgrade pip + pip install openmim # Install mmcv-full, adjust the link to match the appropriate version of Python and PyTorch as needed - pip install "torch>=2.3.1" - pip install "mmcv<2.2.0,>=2.0.0rc4" --find-links https://download.openmmlab.com/mmcv/dist/${{ matrix.python-version }}/torch2.4.0/cpu + mim install "mmcv<2.2.0,>=2.0.0rc4" --find-links https://download.openmmlab.com/mmcv/dist/${{ matrix.python-version }}/torch2.4.0/cpu - name: Verify Installation run: | python -m pip list From 114606878a09e5017f61bf8b97ede6be918aa5ee Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 18:15:15 +0200 Subject: [PATCH 35/37] torch --- .github/workflows/test_mmcv.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test_mmcv.yml b/.github/workflows/test_mmcv.yml index b7d04b6..8c3720d 100644 --- a/.github/workflows/test_mmcv.yml +++ b/.github/workflows/test_mmcv.yml @@ -24,6 +24,7 @@ jobs: run: | python -m pip install --upgrade pip pip install openmim + pip intall "torch>=2.3.1" # Install mmcv-full, adjust the link to match the appropriate version of Python and PyTorch as needed mim install "mmcv<2.2.0,>=2.0.0rc4" --find-links https://download.openmmlab.com/mmcv/dist/${{ matrix.python-version }}/torch2.4.0/cpu - name: Verify Installation From 2e5be3c64ad1bce8ac1a6c0eaff6878475b274be Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 18:16:44 +0200 Subject: [PATCH 36/37] typo --- .github/workflows/test_mmcv.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_mmcv.yml b/.github/workflows/test_mmcv.yml index 8c3720d..7f23666 100644 --- a/.github/workflows/test_mmcv.yml +++ b/.github/workflows/test_mmcv.yml @@ -24,7 +24,7 @@ jobs: run: | python -m pip install --upgrade pip pip install openmim - pip intall "torch>=2.3.1" + pip install "torch>=2.3.1" # Install mmcv-full, adjust the link to match the appropriate version of Python and PyTorch as needed mim install "mmcv<2.2.0,>=2.0.0rc4" --find-links https://download.openmmlab.com/mmcv/dist/${{ matrix.python-version }}/torch2.4.0/cpu - name: Verify Installation From b920e2b6541a98a3ba8cfbae8f75f911807248ff Mon Sep 17 00:00:00 2001 From: christinab12 Date: Thu, 25 Jul 2024 18:27:30 +0200 Subject: [PATCH 37/37] final --- .github/workflows/test_and_deploy.yml | 150 +++++++++++++------------- .github/workflows/test_mmcv.yml | 41 ------- 2 files changed, 75 insertions(+), 116 deletions(-) delete mode 100644 .github/workflows/test_mmcv.yml diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 8c2936e..ba29221 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -1,85 +1,85 @@ -# # This workflows will upload a Python Package using Twine when a release is created -# # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries +# This workflows will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries -# name: tests +name: tests -# on: -# push: -# branches: -# - main -# tags: -# - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 -# pull_request: -# branches: -# - main -# workflow_dispatch: +on: + push: + branches: + - main + tags: + - "v*" # Push events to matching v*, i.e. v1.0, v20.15.10 + pull_request: + branches: + - main + workflow_dispatch: -# jobs: -# test: -# name: ${{ matrix.platform }} py${{ matrix.python-version }} -# runs-on: ${{ matrix.platform }} -# strategy: -# matrix: -# platform: [ubuntu-latest] #, windows-latest, macos-latest] -# python-version: ["3.10"] # 3.9, -# env: -# DISPLAY: ':99.0' -# steps: -# - name: Checkout Repository -# uses: actions/checkout@v3 +jobs: + test: + name: ${{ matrix.platform }} py${{ matrix.python-version }} + runs-on: ${{ matrix.platform }} + strategy: + matrix: + platform: [ubuntu-latest, windows-latest, macos-latest] + python-version: ["3.10", 3.9] + env: + DISPLAY: ':99.0' + steps: + - name: Checkout Repository + uses: actions/checkout@v3 -# - name: Set up Python ${{ matrix.python-version }} -# uses: actions/setup-python@v3 -# with: -# python-version: ${{ matrix.python-version }} + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} -# # these libraries enable testing on Qt on linux -# - uses: tlambert03/setup-qt-libs@v1 + # these libraries enable testing on Qt on linux + - uses: tlambert03/setup-qt-libs@v1 -# # strategy borrowed from vispy for installing opengl libs on windows -# - name: Install Windows OpenGL -# if: runner.os == 'Windows' -# run: | -# git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git -# powershell gl-ci-helpers/appveyor/install_opengl.ps1 + # strategy borrowed from vispy for installing opengl libs on windows + - name: Install Windows OpenGL + if: runner.os == 'Windows' + run: | + git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git + powershell gl-ci-helpers/appveyor/install_opengl.ps1 -# - name: Install dependencies -# run: | -# python -m pip install --upgrade pip -# python -m pip install pytest pytest-qt pytest-cookies -# pip install -e ".[testing]" --no-cache-dir -# pip install "mmcv<2.2.0,>=2.0.0rc4" --find-links https://download.openmmlab.com/mmcv/dist/${{ matrix.python-version }}/torch2.4.0/cpu + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install pytest pytest-qt pytest-cookies + pip install -e ".[testing]" + pip install "mmcv<2.2.0,>=2.0.0rc4" --find-links https://download.openmmlab.com/mmcv/dist/${{ matrix.python-version }}/torch2.4.0/cpu -# - name: Test -# uses: aganders3/headless-gui@v1 -# with: -# run: | -# python -m pytest -s -v --color=yes + - name: Test + uses: aganders3/headless-gui@v1 + with: + run: | + python -m pytest -s -v --color=yes -# deploy: -# # this will run when you have tagged a commit, starting with "v*" -# # and requires that you have put your twine API key in your -# # github secrets (see readme for details) -# needs: [test] -# runs-on: ubuntu-latest -# if: contains(github.ref, 'tags') -# steps: -# - uses: actions/checkout@v3 -# - name: Set up Python -# uses: actions/setup-python@v3 -# with: -# python-version: "3.x" -# - name: Install dependencies -# run: | -# python -m pip install --upgrade pip -# pip install twine -# pip install build -# - name: Build and publish -# env: -# TWINE_USERNAME: __token__ -# TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }} -# run: | -# git tag -# python -m build . -# twine upload dist/* + deploy: + # this will run when you have tagged a commit, starting with "v*" + # and requires that you have put your twine API key in your + # github secrets (see readme for details) + # needs: [test] + runs-on: ubuntu-latest + if: contains(github.ref, 'tags') + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: "3.x" + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install twine + pip install build + - name: Build and publish + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }} + run: | + git tag + python -m build . + twine upload dist/* diff --git a/.github/workflows/test_mmcv.yml b/.github/workflows/test_mmcv.yml deleted file mode 100644 index 7f23666..0000000 --- a/.github/workflows/test_mmcv.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: Install and Test MMCV -on: - push: - branches: - - main - pull_request: - branches: - - main - workflow_dispatch: -jobs: - install-and-test: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.10"] - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: ${{ matrix.python-version }} - - name: Install Dependencies - run: | - python -m pip install --upgrade pip - pip install openmim - pip install "torch>=2.3.1" - # Install mmcv-full, adjust the link to match the appropriate version of Python and PyTorch as needed - mim install "mmcv<2.2.0,>=2.0.0rc4" --find-links https://download.openmmlab.com/mmcv/dist/${{ matrix.python-version }}/torch2.4.0/cpu - - name: Verify Installation - run: | - python -m pip list - python -c "import mmcv; print('MMCV version:', mmcv.__version__)" - python -c "import mmcv; print('MMCV installation path:', mmcv.__file__)" - python -c "from mmcv.ops.roi_align import roi_align" - - - - - -