Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Commit

Permalink
Cross-Validation (#17)
Browse files Browse the repository at this point in the history
* fix & refactor CrossVal
* update CI
* update manifest
* refactoring
  • Loading branch information
Borda committed Jan 13, 2019
1 parent a6dad15 commit 43049c1
Show file tree
Hide file tree
Showing 16 changed files with 212 additions and 224 deletions.
34 changes: 0 additions & 34 deletions .shippable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,40 +52,6 @@ script:
- python setup.py check -m -s
- flake8 . --ignore=E402,E731 --max-line-length=100

# ANNOTATION section
- python handling_annotations/run_image_color_quantization.py -imgs "./data_images/drosophila_ovary_slice/segm_rgb/*.png"
- python handling_annotations/run_image_convert_label_color.py -imgs "./data_images/drosophila_ovary_slice/segm/*.png" -out ./data_images/drosophila_ovary_slice/segm_rgb
- python handling_annotations/run_overlap_images_segms.py -imgs "./data_images/drosophila_ovary_slice/image/*.jpg" -segs ./data_images/drosophila_ovary_slice/segm -out ./results/overlap_ovary_segment
- python handling_annotations/run_segm_annot_inpaint.py -imgs "./data_images/drosophila_ovary_slice/segm/*.png" --label 0
- python handling_annotations/run_segm_annot_relabel.py -imgs "./data_images/drosophila_ovary_slice/center_levels/*.png" -out ./results/relabel_center_levels

# SEGMENTATION section
- rm -r -f results && mkdir results
- python experiments_segmentation/run_compute_stat_annot_segm.py -a "data_images/drosophila_ovary_slice/annot_struct/*.png" -s "data_images/drosophila_ovary_slice/segm/*.png" --visual
- python experiments_segmentation/run_segm_slic_model_graphcut.py -i "data_images/drosophila_disc/image/img_[5,6].jpg" -cfg ./experiments_segmentation/sample_config.json --visual
- python experiments_segmentation/run_segm_slic_classif_graphcut.py -l data_images/drosophila_ovary_slice/list_imgs-annot-struct_short.csv -i "data_images/drosophila_ovary_slice/image/insitu41*.jpg" -cfg ./experiments_segmentation/sample_config.json --visual

# CENTER DETECT. section
- rm -r -f results && mkdir results
- python experiments_ovary_centres/run_create_annotation.py
- python experiments_ovary_centres/run_center_candidate_training.py
- python experiments_ovary_centres/run_center_prediction.py
- python experiments_ovary_centres/run_center_clustering.py
- python experiments_ovary_centres/run_center_evaluation.py

# download MorphSnake
- pip install git+https://github.com/Borda/morph-snakes.git
# REGION GROWING section
- rm -r -f results && mkdir results
- python experiments_ovary_detect/run_RG2Sp_estim_shape-models.py
- python experiments_ovary_detect/run_ovary_egg-segmentation.py -m ellipse_moments ellipse_ransac_mmt ellipse_ransac_crit GC_pixels-large GC_pixels-shape GC_slic-small GC_slic-shape rg2sp_greedy-single rg2sp_GC-mixture watershed_morph
- python experiments_ovary_detect/run_ovary_segm_evaluation.py
- python experiments_ovary_detect/run_export_user-annot-segm.py
- python experiments_ovary_detect/run_cut_segmented_objects.py
- python experiments_ovary_detect/run_ellipse_annot_match.py
- python experiments_ovary_detect/run_ellipse_cut_scale.py
- python experiments_ovary_detect/run_egg_swap_orientation.py

after_success:
- python setup.py install

Expand Down
11 changes: 9 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,16 @@ script:

after_success:
- codecov # public repository on Travis CI
# private repository on Travis CI
# - codecov -t 80efed4e-ac2b-4fea-a642-0a8b1c82e1c8
- coverage xml
- python-codacy-coverage -r coverage.xml
- coverage report
# ANNOTATION section
- bash handling_annotations/test_annotations.sh
# SEGMENTATION section
- bash experiments_segmentation/test_segmentations.sh
# CENTER DETECT. section
- bash experiments_ovary_centres/test_ovary_cebters.sh
# REGION GROWING section
- bash experiments_ovary_detect/test_ovary_detect.sh
# test installed package
- cd .. && python -c "import imsegm.descriptors"
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ include setup.*
# Exclude build configs
exclude *.yml

# Exclude tests
exclude test*.py
# Exclude experiments
exclude */*.sh

# Include the experiments
recursive-include experiments_* *.py *.json
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,19 @@ Moreover, we are using python [GraphCut wrapper](https://github.com/Borda/pyGCO)

**Compilation**

We have implemented cython version of some functions, especially computing descriptors, which require to compile them before using them
We have implemented `cython` version of some functions, especially computing descriptors, which require to compile them before using them
```bash
python setup.py build_ext --inplace
```
If loading of compiled descriptors in `cython` fails, it is automatically swapped to `numpy` which gives the same results, but it is significantly slower.

**Installation**

The package can be installed via pip from the folder
The package can be installed via pip
```bash
pip install git+https://github.com/Borda/pyImSegm.git
```
or using `setuptools` from local folder
```bash
python setup.py install
```
Expand Down
40 changes: 4 additions & 36 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,48 +35,16 @@ jobs:
flake8 . --ignore=E402,E731 --max-line-length=100
# ANNOTATION section
- run:
name: Annotations
command: |
python handling_annotations/run_image_color_quantization.py -imgs "./data_images/drosophila_ovary_slice/segm_rgb/*.png"
python handling_annotations/run_image_color_quantization.py -imgs "./data_images/drosophila_ovary_slice/segm_rgb/*.png" -m position
python handling_annotations/run_image_convert_label_color.py -imgs "./data_images/drosophila_ovary_slice/segm/*.png" -out ./data_images/drosophila_ovary_slice/segm_rgb
python handling_annotations/run_image_convert_label_color.py -imgs "./data_images/drosophila_ovary_slice/segm_rgb/*.png" -out ./data_images/drosophila_ovary_slice/segm
python handling_annotations/run_overlap_images_segms.py -imgs "./data_images/drosophila_ovary_slice/image/*.jpg" -segs ./data_images/drosophila_ovary_slice/segm -out ./results/overlap_ovary_segment
python handling_annotations/run_segm_annot_inpaint.py -imgs "./data_images/drosophila_ovary_slice/segm/*.png" --label 0
python handling_annotations/run_segm_annot_relabel.py -imgs "./data_images/drosophila_ovary_slice/center_levels/*.png" -out ./results/relabel_center_levels
- run: bash handling_annotations/test_annotations.sh

# SEGMENTATION section
- run:
name: Segmentation
command: |
python experiments_segmentation/run_compute_stat_annot_segm.py -a "data_images/drosophila_ovary_slice/annot_struct/*.png" -s "data_images/drosophila_ovary_slice/segm/*.png" --visual
python experiments_segmentation/run_segm_slic_model_graphcut.py -i "data_images/drosophila_disc/image/img_[5,6].jpg" -cfg ./experiments_segmentation/sample_config.json --visual
python experiments_segmentation/run_segm_slic_classif_graphcut.py -l data_images/drosophila_ovary_slice/list_imgs-annot-struct_short.csv -i "data_images/drosophila_ovary_slice/image/insitu41*.jpg" -cfg ./experiments_segmentation/sample_config.json --visual
- run: bash experiments_segmentation/test_segmentations.sh

# CENTER DETECT. section
- run:
name: Center detection
command: |
python experiments_ovary_centres/run_create_annotation.py
python experiments_ovary_centres/run_center_candidate_training.py
python experiments_ovary_centres/run_center_prediction.py
python experiments_ovary_centres/run_center_clustering.py
python experiments_ovary_centres/run_center_evaluation.py
- run: bash experiments_ovary_centres/test_ovary_cebters.sh

# REGION GROWING section
- run:
name: Region Growing
command: |
pip install --user git+https://github.com/Borda/morph-snakes.git
python experiments_ovary_detect/run_RG2Sp_estim_shape-models.py
python experiments_ovary_detect/run_ovary_egg-segmentation.py -m ellipse_moments ellipse_ransac_mmt ellipse_ransac_crit GC_pixels-large GC_pixels-shape GC_slic-small GC_slic-shape rg2sp_greedy-single rg2sp_GC-mixture watershed_morph
python experiments_ovary_detect/run_ovary_segm_evaluation.py --visual
python experiments_ovary_detect/run_export_user-annot-segm.py
python experiments_ovary_detect/run_cut_segmented_objects.py
python experiments_ovary_detect/run_ellipse_annot_match.py
python experiments_ovary_detect/run_ellipse_cut_scale.py
python experiments_ovary_detect/run_egg_swap_orientation.py
- run: bash experiments_ovary_detect/test_ovary_detect.sh

# PASSING
- run:
Expand Down
4 changes: 2 additions & 2 deletions experiments_ovary_centres/run_center_clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def cluster_center_candidates(points, max_dist=100, min_samples=1):
:return (ndarray, [int]):
"""
points = np.array(points)
if len(points) == 0:
if not list(points):
return points, []
dbscan = cluster.DBSCAN(eps=max_dist, min_samples=min_samples)
dbscan.fit(points)
Expand Down Expand Up @@ -134,7 +134,7 @@ def cluster_points_draw_export(dict_row, params, path_out=None):
'missing some required fields: %s' % repr(dict_row)
name = os.path.splitext(os.path.basename(dict_row['path_points']))[0]
points = tl_data.load_landmarks_csv(dict_row['path_points'])
if len(points) == 0:
if not list(points):
logging.debug('no points to cluster for "%s"', name)
points = tl_data.swap_coord_x_y(points)

Expand Down
8 changes: 8 additions & 0 deletions experiments_ovary_centres/test_ovary_cebters.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

rm -r -f results && mkdir results
python experiments_ovary_centres/run_create_annotation.py
python experiments_ovary_centres/run_center_candidate_training.py
python experiments_ovary_centres/run_center_prediction.py
python experiments_ovary_centres/run_center_clustering.py
python experiments_ovary_centres/run_center_evaluation.py
2 changes: 1 addition & 1 deletion experiments_ovary_detect/run_ovary_egg-segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ def image_segmentation(idx_row, params, debug_export=DEBUG_EXPORT):
return name
centers = tl_data.load_landmarks_csv(row_path['path_centers'])
centers = tl_data.swap_coord_x_y(centers)
if len(centers) == 0:
if not list(centers):
logging.warning('no center was detected for "%s"', name)
return name
# img = seg / float(seg.max())
Expand Down
13 changes: 13 additions & 0 deletions experiments_ovary_detect/test_ovary_detect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

pip install --user git+https://github.com/Borda/morph-snakes.git
rm -r -f results && mkdir results
python experiments_ovary_detect/run_RG2Sp_estim_shape-models.py
python experiments_ovary_detect/run_ovary_egg-segmentation.py \
-m ellipse_moments ellipse_ransac_mmt ellipse_ransac_crit GC_pixels-large GC_pixels-shape GC_slic-small GC_slic-shape rg2sp_greedy-single rg2sp_GC-mixture watershed_morph
python experiments_ovary_detect/run_ovary_segm_evaluation.py --visual
python experiments_ovary_detect/run_export_user-annot-segm.py
python experiments_ovary_detect/run_cut_segmented_objects.py
python experiments_ovary_detect/run_ellipse_annot_match.py
python experiments_ovary_detect/run_ellipse_cut_scale.py
python experiments_ovary_detect/run_egg_swap_orientation.py
2 changes: 1 addition & 1 deletion experiments_segmentation/run_segm_slic_model_graphcut.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ def main(params):
tl_expt.create_subfolders(params['path_exp'], LIST_FOLDERS_DEBUG)

paths_img = load_path_images(params)
assert len(paths_img) > 0, 'missing images'
assert paths_img, 'missing images'

def _path_expt(n):
return os.path.join(params['path_exp'], n)
Expand Down
16 changes: 16 additions & 0 deletions experiments_segmentation/test_segmentations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

rm -r -f results && mkdir results
python experiments_segmentation/run_compute_stat_annot_segm.py \
-a "data_images/drosophila_ovary_slice/annot_struct/*.png" \
-s "data_images/drosophila_ovary_slice/segm/*.png" \
--visual
python experiments_segmentation/run_segm_slic_model_graphcut.py \
-i "data_images/drosophila_disc/image/img_[5,6].jpg" \
-cfg ./experiments_segmentation/sample_config.json \
--visual
python experiments_segmentation/run_segm_slic_classif_graphcut.py \
-l data_images/drosophila_ovary_slice/list_imgs-annot-struct_short.csv \
-i "data_images/drosophila_ovary_slice/image/insitu41*.jpg" \
-cfg ./experiments_segmentation/sample_config.json \
--visual
23 changes: 23 additions & 0 deletions handling_annotations/test_annotations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

python handling_annotations/run_image_color_quantization.py \
-imgs "./data_images/drosophila_ovary_slice/segm_rgb/*.png"
python handling_annotations/run_image_color_quantization.py \
-imgs "./data_images/drosophila_ovary_slice/segm_rgb/*.png" \
-m position
python handling_annotations/run_image_convert_label_color.py \
-imgs "./data_images/drosophila_ovary_slice/segm/*.png" \
-out ./data_images/drosophila_ovary_slice/segm_rgb
python handling_annotations/run_image_convert_label_color.py \
-imgs "./data_images/drosophila_ovary_slice/segm_rgb/*.png" \
-out ./data_images/drosophila_ovary_slice/segm
python handling_annotations/run_overlap_images_segms.py \
-imgs "./data_images/drosophila_ovary_slice/image/*.jpg" \
-segs ./data_images/drosophila_ovary_slice/segm \
-out ./results/overlap_ovary_segment
python handling_annotations/run_segm_annot_inpaint.py \
-imgs "./data_images/drosophila_ovary_slice/segm/*.png" \
--label 0
python handling_annotations/run_segm_annot_relabel.py \
-imgs "./data_images/drosophila_ovary_slice/center_levels/*.png" \
-out ./results/relabel_center_levels

0 comments on commit 43049c1

Please sign in to comment.