Skip to content

Commit

Permalink
[clean] clean up scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsun committed Aug 6, 2024
1 parent 80f47e5 commit 491692f
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 8 deletions.
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ docs = [
'cvtk[full]',
'sphinx-rtd-theme',
'sphinxcontrib-napoleon',
'numpy == 1.26.3',
'torch == 2.1.0',
'mmcv == 2.1.0',
'mmdet == 3.3.0',
'numpy',
'torch',
'mmcv',
'mmdet',
]


Expand Down
2 changes: 1 addition & 1 deletion src/cvtk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.2.12'
__version__ = '0.2.13'

from ._base import imread, imconvert, imwrite, imshow, imlist, imresize
from ._base import Annotation, Image, ImageDeck, JsonComplexEncoder
2 changes: 1 addition & 1 deletion src/cvtk/tmpl/_ls_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@ def __convert(self, im):
"""
Example:
uvicorn main:app --host 0.0.0.0 --port 8080 --reload
gunicorn --bind 0.0.0.0:8600 main:app --reload
"""

2 changes: 1 addition & 1 deletion src/cvtk/tmpl/_mmdet.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def train(label, train, valid, test, output_weights, batch_size=2, num_workers=8
output=os.path.splitext(output_weights)[0] + '.train_stats.valid.png')


def inference(label, data, model_weights, output, batch_size=4, num_workers=8):
def inference(label, data, model_weights, output, batch_size=2, num_workers=8):
datalabel = DataLabel(label)

model = MMDETCORE(datalabel, os.path.splitext(model_weights)[0] + '.py', model_weights, workspace=output)
Expand Down
41 changes: 40 additions & 1 deletion tests/test_ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import requests
import PIL
import cvtk.ls
import cvtk.ml
import pathlib
import unittest
import testutils



def get_app_status(url):
print(f'Checking App Server ({url}) Status... ')
try:
Expand All @@ -30,7 +33,22 @@ def test_exprot(self, host='http://localhost', port=8080):
output=os.path.join(self.ws, 'instances.coco.json'),
format='coco',
host=host, port=port)


def test_generate_app(self):
with open(os.path.join(self.ws, 'sample_label.txt'), 'w'):
pass
with open(os.path.join(self.ws, 'model.pth'), 'w'):
pass
with open(os.path.join(self.ws, 'model.py'), 'w'):
pass


cvtk.ml.generate_source(os.path.join(self.ws, 'det.py'), task='det')
cvtk.ls.generate_app(os.path.join(self.ws, 'lsbackend'),
source=os.path.join(self.ws, 'det.py'),
label=os.path.join(self.ws, 'sample_label.txt'),
model=os.path.join(self.ws, 'model.py'),
weights=os.path.join(self.ws, 'model.pth'))


class TestScritpUtils(unittest.TestCase):
Expand All @@ -48,6 +66,27 @@ def test_export(self, host='http://localhost', port=8080):
'--host', host, '--port', port])


def test_generate_app(self):
with open(os.path.join(self.ws, 'sample_label.txt'), 'w'):
pass
with open(os.path.join(self.ws, 'model.pth'), 'w'):
pass
with open(os.path.join(self.ws, 'model.py'), 'w'):
pass

testutils.run_cmd(['cvtk', 'create',
'--task', 'det',
'--script', os.path.join(self.ws, 'det.py')])

testutils.run_cmd(['cvtk', 'ls-backend',
'--project', os.path.join(self.ws, 'lsbackend'),
'--source', os.path.join(self.ws, 'det.py'),
'--label', os.path.join(self.ws, 'sample_label.txt'),
'--model', os.path.join(self.ws, 'model.py'),
'--weights', os.path.join(self.ws, 'model.pth')])





if __name__ == '__main__':
Expand Down

0 comments on commit 491692f

Please sign in to comment.