Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration tests #30

Merged
merged 50 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
e918071
integration of patch model
Jul 12, 2023
effbe6a
add comments with to dos
Jul 13, 2023
325b849
added train and eval parts in models
Jul 15, 2023
5ca7b15
add comments and small changes
Jul 17, 2023
7b4d847
finished create_patch_datasetand fixed errors
Jul 23, 2023
38a8140
rewrite the tests from unittest to pytest
KorenMary Jul 27, 2023
c18a796
add integration tests
KorenMary Sep 26, 2023
8a03102
add integration tests and adjusted models.py
KorenMary Sep 27, 2023
c0443b6
added channel axis to rescale so mask retains channel dim
Oct 18, 2023
76fde8b
adapted config for CellposePatchCNN model
Oct 18, 2023
2755ad5
adapted to allow for 2 channel mask (class+intance) to be resized cor…
Oct 18, 2023
1325572
major changes in CellClassifierFCNN and CellposePatchCNN to make comp…
Oct 18, 2023
42c3e77
adapted integration tests for test and train of patch model
Oct 19, 2023
df065a4
added tests to seperate folder
Oct 19, 2023
d972364
Added and tested synthetic data generation on-the-fly for integration…
KorenMary Oct 27, 2023
5ce4845
Update requirements.txt
KorenMary Oct 29, 2023
9de2a22
requirements modified
KorenMary Oct 29, 2023
c5de9ba
fixed test paths
KorenMary Oct 29, 2023
eb5c1f4
Updates according to code review
KorenMary Oct 29, 2023
1c97344
updated eval config to include channel and z axis
Oct 30, 2023
a3f9ab5
updated get_image_size_properties to return z and channel axis
Oct 30, 2023
7d128a2
updated the way conifgs are passed to models
Oct 30, 2023
d05c84f
updated with z and channel axis args and removed eval_config from eva…
Oct 30, 2023
a06f057
removed eval config from eval since it is in model init
Oct 30, 2023
ffe5adf
search seg bug fix
hpelin Oct 31, 2023
eb0d9c2
passed 'segmentor' into initi of CustomCellP.
hpelin Oct 31, 2023
49a3d96
Merge branch 'integration-tests' of https://github.com/HelmholtzAI-Co…
Nov 3, 2023
6f6d2fc
moved image processing and dataset creation functions to utils
Nov 3, 2023
460cdaf
commenting lines which print model weights
Nov 3, 2023
266bb72
added comment on expected formats
Nov 3, 2023
a36ec9e
added new mask_channel_axis arg in config which stores channel axis o…
Nov 3, 2023
9615f57
Merge branch 'integration-tests' of https://github.com/HelmholtzAI-Co…
Nov 3, 2023
3c86217
tested on 3 channel images
KorenMary Nov 5, 2023
b1dcda1
3 channel input tested
KorenMary Nov 5, 2023
389dab0
mask paths fixed
KorenMary Nov 5, 2023
b189b40
changed the synthetic mask format to (2,512,512) in the pytest and te…
KorenMary Nov 6, 2023
11d02ed
tested train function
KorenMary Nov 6, 2023
fe52557
changed the paths to the files due to test error
KorenMary Nov 6, 2023
c607154
fixed the bug
KorenMary Nov 6, 2023
58bebd3
changed the paths for shapes
KorenMary Nov 6, 2023
a74daf6
added pytest to requirements
Nov 8, 2023
a070912
changed convention to always convert image to grayscale on read, inpu…
Nov 8, 2023
6e270dc
changed documentation for channel_axis
Nov 8, 2023
bf62ccf
since grayscale convention changed arguments of channel_axis
Nov 8, 2023
5b60b1f
changed method to compute center of mass and return instance label as…
Nov 8, 2023
f7c795d
removed merging of image, adapted class mask to ensure label correspo…
Nov 8, 2023
f4f75f0
added min_train_masks arg
Nov 8, 2023
e5f9afc
included height and width computations for elif statements
Nov 8, 2023
10d4ed4
Add tests for multiple models including CustomCellposeModel
KorenMary Nov 12, 2023
90e7b25
fix the test in train part
KorenMary Nov 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/client/dcp_client/config.cfg
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"server":{
"user": "ubuntu",
"host": "jusuf-vm2",
"host": "local",
"data-path": "/home/ubuntu/dcp-data",
"ip": "134.94.88.74",
"ip": "0.0.0.0",
"port": 7010
}
}
109 changes: 58 additions & 51 deletions src/client/test/test_app.py
Original file line number Diff line number Diff line change
@@ -1,62 +1,69 @@
import os
import sys
from skimage import data
from skimage.io import imsave
import unittest
import pytest

sys.path.append("../")

from dcp_client.app import Application
from dcp_client.utils.bentoml_model import BentomlModel
from dcp_client.utils.fsimagestorage import FilesystemImageStorage
from dcp_client.utils.sync_src_dst import DataRSync

class TestApplication(unittest.TestCase):

def test_run_train(self):
pass

def test_run_inference(self):
pass

def test_load_image(self):

img = data.astronaut()
img2 = data.cat()
os.mkdir('in_prog')
imsave('in_prog/test_img.png', img)
imsave('in_prog/test_img2.png', img2)
rsyncer = DataRSync(user_name="local",
host_name="local",
server_repo_path='.')
self.app = Application(BentomlModel(),
rsyncer,
FilesystemImageStorage(),
"0.0.0.0",
7010)

self.app.cur_selected_img = 'test_img.png'
self.app.cur_selected_path = 'in_prog'

img_test = self.app.load_image() # if image_name is None
self.assertEqual(img.all(), img_test.all())
img_test2 = self.app.load_image('test_img2.png') # if a filename is given
self.assertEqual(img2.all(), img_test2.all())

# delete everyting we created
os.remove('in_prog/test_img.png')
os.remove('in_prog/test_img2.png')
os.rmdir('in_prog')

def test_save_image(self):
pass

def test_move_images(self):
pass

def test_delete_images(self):
pass

def test_search_segs(self):
pass

@pytest.fixture
def app():
img = data.astronaut()
img2 = data.cat()
os.mkdir('in_prog')

imsave('in_prog/test_img.png', img)
imsave('in_prog/test_img2.png', img2)

rsyncer = DataRSync(user_name="local", host_name="local", server_repo_path='.')
app = Application(BentomlModel(), rsyncer, FilesystemImageStorage(), "0.0.0.0", 7010)

app.cur_selected_img = 'test_img.png'
app.cur_selected_path = 'in_prog'

return app, img, img2

def test_load_image(app):
app, img, img2 = app # Unpack the app, img, and img2 from the fixture

img_test = app.load_image() # if image_name is None
assert img.all() == img_test.all()

img_test2 = app.load_image('test_img2.png') # if a filename is given
assert img2.all() == img_test2.all()

# delete everything we created
os.remove('in_prog/test_img.png')
os.remove('in_prog/test_img2.png')
os.rmdir('in_prog')

def test_run_train():
pass

def test_run_inference():
pass

def test_save_image():
pass

def test_move_images():
pass

def test_delete_images():
pass

def test_search_segs():
pass







if __name__=='__main__':
unittest.main()
85 changes: 40 additions & 45 deletions src/client/test/test_fsimagestorage.py
Original file line number Diff line number Diff line change
@@ -1,51 +1,46 @@
import os
import pytest
from skimage.io import imsave
from skimage import data
import unittest

from dcp_client.utils.fsimagestorage import FilesystemImageStorage


class TestFilesystemImageStorage(unittest.TestCase):

def test_load_image(self):
fis = FilesystemImageStorage()
img = data.astronaut()
fname = 'test_img.png'
imsave(fname, img)
img_test = fis.load_image('.', fname)
self.assertEqual(img.all(), img_test.all())
os.remove(fname)

def test_move_image(self):
fis = FilesystemImageStorage()
img = data.astronaut()
fname = 'test_img.png'
os.mkdir('temp')
imsave(fname, img)
fis.move_image('.', 'temp', fname)
self.assertTrue(os.path.exists('temp/test_img.png'))
os.remove('temp/test_img.png')
os.rmdir('temp')

def test_save_image(self):
fis = FilesystemImageStorage()
img = data.astronaut()
fname = 'test_img.png'
fis.save_image('.', fname, img)
self.assertTrue(os.path.exists(fname))
os.remove(fname)

def test_delete_image(self):
fis = FilesystemImageStorage()
img = data.astronaut()
fname = 'test_img.png'
os.mkdir('temp')
imsave('temp/test_img.png', img)
fis.delete_image('temp', fname)
self.assertFalse(os.path.exists('temp/test_img.png'))
os.rmdir('temp')


if __name__=='__main__':
unittest.main()
@pytest.fixture
def fis():
return FilesystemImageStorage()

@pytest.fixture
def sample_image():
# Create a sample image
img = data.astronaut()
fname = 'test_img.png'
imsave(fname, img)
return fname

def test_load_image(fis, sample_image):
img_test = fis.load_image('.', sample_image)
assert img_test.all() == data.astronaut().all()
os.remove(sample_image)

def test_move_image(fis, sample_image):
temp_dir = 'temp'
os.mkdir(temp_dir)
fis.move_image('.', temp_dir, sample_image)
assert os.path.exists(os.path.join(temp_dir, 'test_img.png'))
os.remove(os.path.join(temp_dir, 'test_img.png'))
os.rmdir(temp_dir)

def test_save_image(fis):
img = data.astronaut()
fname = 'output.png'
fis.save_image('.', fname, img)
assert os.path.exists(fname)
os.remove(fname)

def test_delete_image(fis, sample_image):
temp_dir = 'temp'
os.mkdir(temp_dir)
fis.move_image('.', temp_dir, sample_image)
fis.delete_image(temp_dir, 'test_img.png')
assert not os.path.exists(os.path.join(temp_dir, 'test_img.png'))
os.rmdir(temp_dir)
11 changes: 7 additions & 4 deletions src/server/dcp_server/config.cfg
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"setup":{
"setup": {
"segmentation": "GeneralSegmentation",
"accepted_types": [".jpg", ".jpeg", ".png", ".tiff", ".tif"],
"seg_name_string": "_seg"
},
"service":{
"service": {
"model_to_use": "CustomCellposeModel",
"save_model_path": "mytrainedmodel",
"runner_name": "cellpose_runner",
Expand All @@ -15,10 +15,13 @@
"model_type":"cyto"
},
"data": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change to 'paths' and maybe move also model path here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KorenMary please ignore this one, it is for me!

"data_root": "/home/ubuntu/dcp-data"
"data_root": "/home/ubuntu/dcp-data",
"patch_size":64,
"noise_intensity":5,
"num_classes":3
},
"train":{
"n_epochs": 2,
"n_epochs": 1,
"channels":[0]
},
"eval":{
Expand Down
Loading