-
Notifications
You must be signed in to change notification settings - Fork 5
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
Changes from 8 commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
e918071
integration of patch model
effbe6a
add comments with to dos
325b849
added train and eval parts in models
5ca7b15
add comments and small changes
7b4d847
finished create_patch_datasetand fixed errors
38a8140
rewrite the tests from unittest to pytest
KorenMary c18a796
add integration tests
KorenMary 8a03102
add integration tests and adjusted models.py
KorenMary c0443b6
added channel axis to rescale so mask retains channel dim
76fde8b
adapted config for CellposePatchCNN model
2755ad5
adapted to allow for 2 channel mask (class+intance) to be resized cor…
1325572
major changes in CellClassifierFCNN and CellposePatchCNN to make comp…
42c3e77
adapted integration tests for test and train of patch model
df065a4
added tests to seperate folder
d972364
Added and tested synthetic data generation on-the-fly for integration…
KorenMary 5ce4845
Update requirements.txt
KorenMary 9de2a22
requirements modified
KorenMary c5de9ba
fixed test paths
KorenMary eb5c1f4
Updates according to code review
KorenMary 1c97344
updated eval config to include channel and z axis
a3f9ab5
updated get_image_size_properties to return z and channel axis
7d128a2
updated the way conifgs are passed to models
d05c84f
updated with z and channel axis args and removed eval_config from eva…
a06f057
removed eval config from eval since it is in model init
ffe5adf
search seg bug fix
hpelin eb0d9c2
passed 'segmentor' into initi of CustomCellP.
hpelin 49a3d96
Merge branch 'integration-tests' of https://github.com/HelmholtzAI-Co…
6f6d2fc
moved image processing and dataset creation functions to utils
460cdaf
commenting lines which print model weights
266bb72
added comment on expected formats
a36ec9e
added new mask_channel_axis arg in config which stores channel axis o…
9615f57
Merge branch 'integration-tests' of https://github.com/HelmholtzAI-Co…
3c86217
tested on 3 channel images
KorenMary b1dcda1
3 channel input tested
KorenMary 389dab0
mask paths fixed
KorenMary b189b40
changed the synthetic mask format to (2,512,512) in the pytest and te…
KorenMary 11d02ed
tested train function
KorenMary fe52557
changed the paths to the files due to test error
KorenMary c607154
fixed the bug
KorenMary 58bebd3
changed the paths for shapes
KorenMary a74daf6
added pytest to requirements
a070912
changed convention to always convert image to grayscale on read, inpu…
6e270dc
changed documentation for channel_axis
bf62ccf
since grayscale convention changed arguments of channel_axis
5b60b1f
changed method to compute center of mass and return instance label as…
f7c795d
removed merging of image, adapted class mask to ensure label correspo…
f4f75f0
added min_train_masks arg
e5f9afc
included height and width computations for elif statements
10d4ed4
Add tests for multiple models including CustomCellposeModel
KorenMary 90e7b25
fix the test in train part
KorenMary File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!