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

Fixed clobbering issue #4

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ htmlcov
.idea/
.vscode/
covidnet/models


out/
23 changes: 22 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,30 @@ Run
.. code:: bash

docker run --rm -v $PWD/in:/incoming -v $PWD/out:/outgoing \
fnndsc/pl-covidnet:0.2.0 covidnet \
fnndsc/pl-covidnet covidnet \
--imagefile ex-covid.jpeg /incoming /outgoing

.. code:: bash

docker run --rm -u $(id -u) \
-v $(pwd)/in:/incoming -v $(pwd)/out:/outgoing \
fnndsc/pl-covidnet covidnet --parInst <insert ID> \
/incoming /outgoing

.. code:: bash

docker run --rm -u $(id -u) \
-v $(pwd)/in:/incoming -v $(pwd)/out:/outgoing \
jonocameron/pl-covidnet covidnet --imagefile "ex-covid.jpeg" --savToDir "000" \
/incoming /outgoing

.. code:: bash

docker run --rm -u $(id -u) \
-v $(pwd)/in:/incoming -v $(pwd)/out:/outgoing \
jonocameron/pl-covidnet covidnet --imagefile "ex-covid.jpeg" \
/incoming /outgoing


Links
-----
Expand Down
6 changes: 6 additions & 0 deletions covidnet/covidnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ def define_parameters(self):
Define the CLI arguments accepted by this plugin app.
Use self.add_argument to specify a new app argument.
"""
self.add_argument('--savToDir',
dest = 'savToDir',
type = str,
optional = True,
help = 'Parent instance ID',
default = '')
self.add_argument('--metaname',
dest = 'metaname',
type = str,
Expand Down
39 changes: 32 additions & 7 deletions covidnet/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,24 +131,49 @@ def generate_severity_data(self, imagePath):
def generate_output_files(self, classification_data, severityScores):
# remove this line to display model names mapped in dict
self.args.modelused = 'default'
directory = self.args.savToDir

parent_dir = self.args.outputdir

if(directory == ''):
print("Creating prediction.json in {}...".format(self.args.outputdir))
with open('{}/prediction-{}.json'.format(self.args.outputdir, self.args.modelused), 'w') as f:
json.dump(classification_data, f, indent=4)
print("Copying over the input image to: {}...".format(self.args.outputdir))
shutil.copy(self.args.inputdir + '/' + self.args.imagefile,self.args.outputdir)
# Not covid positive
if severityScores is None:
return
print("Creating severity.json in {}...".format(self.args.outputdir))
with open('{}/severity.json'.format(self.args.outputdir), 'w') as f:
json.dump(severityScores, f, indent=4)
return



nPath = os.path.join(parent_dir , directory)
os.makedirs(nPath)

# creates the output directory if not exists
if not os.path.exists(self.args.outputdir):
os.makedirs(self.args.outputdir)
os.makedirs(nPath)

print("Creating prediction.json in {}...".format(self.args.outputdir))
with open('{}/prediction-{}.json'.format(self.args.outputdir, self.args.modelused), 'w') as f:
print("Creating prediction.json in {}...".format(nPath))
with open('{}/prediction-{}.json'.format(nPath, self.args.modelused), 'w') as f:
json.dump(classification_data, f, indent=4)

print("Copying over the input image to: {}...".format(nPath))
shutil.copy(self.args.inputdir + '/' + self.args.imagefile,nPath)


print("Copying over the input image to: {}...".format(self.args.outputdir))
shutil.copy(self.args.inputdir + '/' + self.args.imagefile,self.args.outputdir)

# Not covid positive
if severityScores is None:
return

print("Creating severity.json in {}...".format(self.args.outputdir))
with open('{}/severity.json'.format(self.args.outputdir), 'w') as f:

print("Creating severity.json in {}...".format(nPath))
with open('{}/severity.json'.format(nPath, self.args.modelused), 'w') as f:
json.dump(severityScores, f, indent=4)


Expand Down
Binary file added in/ex-covid.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name = 'covidnet',
version = '0.2.2',
version = '0.3.2',
description = 'Plugin to ChRIS for covidnet functionalities',
long_description = readme,
author = 'Jeffer Peng',
Expand Down