Unverified Commit ac693871 authored by Cagri Eryilmaz's avatar Cagri Eryilmaz Committed by GitHub
Browse files

Nb clean + cleaning python files in /example/ with pyflakes (#898)



* nb-clean some notebooks

* empty cells

* pyflakes cleanup for /example/

* formatting

* additional fix for 3dunet pyflakes warnings

* formatting
Co-authored-by: default avatarPaul Fultz II <pfultz2@yahoo.com>
parent 78f7af1d
...@@ -148,13 +148,6 @@ ...@@ -148,13 +148,6 @@
"\n", "\n",
"print(process.stdout)" "print(process.stdout)"
] ]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
} }
], ],
"metadata": { "metadata": {
...@@ -172,8 +165,7 @@ ...@@ -172,8 +165,7 @@
"mimetype": "text/x-python", "mimetype": "text/x-python",
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3"
"version": "3.7.9"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
...@@ -38,15 +38,13 @@ def show_n_images(imgs, titles=None, enlarge=20, cmap='jet'): ...@@ -38,15 +38,13 @@ def show_n_images(imgs, titles=None, enlarge=20, cmap='jet'):
#-------------------------------------------------------------- #--------------------------------------------------------------
from skimage import io, color, img_as_float from skimage import color, img_as_float
from skimage.exposure import adjust_gamma from skimage.exposure import adjust_gamma
# Creates an image of original brain with segmentation overlay # Creates an image of original brain with segmentation overlay
def show_label_on_image(test_img, test_lbl): def show_label_on_image(test_img, test_lbl):
modes = {'flair': 0, 't1': 1, 't1c': 2, 't2': 3}
label_im = test_lbl label_im = test_lbl
ones = np.argwhere(label_im == 1) ones = np.argwhere(label_im == 1)
...@@ -61,7 +59,6 @@ def show_label_on_image(test_img, test_lbl): ...@@ -61,7 +59,6 @@ def show_label_on_image(test_img, test_lbl):
image = adjust_gamma(np.abs(color.gray2rgb(gray_img)), 0.45) image = adjust_gamma(np.abs(color.gray2rgb(gray_img)), 0.45)
#sliced_image = image.copy() #sliced_image = image.copy()
red_multiplier = [1, 0.2, 0.2]
green_multiplier = [0.35, 0.75, 0.25] green_multiplier = [0.35, 0.75, 0.25]
blue_multiplier = [0, 0.5, 1.] #[0,0.25,0.9] blue_multiplier = [0, 0.5, 1.] #[0,0.25,0.9]
yellow_multiplier = [1, 1, 0.25] yellow_multiplier = [1, 1, 0.25]
...@@ -69,7 +66,7 @@ def show_label_on_image(test_img, test_lbl): ...@@ -69,7 +66,7 @@ def show_label_on_image(test_img, test_lbl):
# change colors of segmented classes # change colors of segmented classes
for i in range(len(ones)): for i in range(len(ones)):
image[ones[i][0]][ones[i][1]] = blue_multiplier #red_multiplier image[ones[i][0]][ones[i][1]] = blue_multiplier
for i in range(len(twos)): for i in range(len(twos)):
image[twos[i][0]][twos[i][1]] = yellow_multiplier image[twos[i][0]][twos[i][1]] = yellow_multiplier
for i in range(len(threes)): for i in range(len(threes)):
...@@ -90,7 +87,6 @@ def show_label_on_image4(test_img, label_im): ...@@ -90,7 +87,6 @@ def show_label_on_image4(test_img, label_im):
# Construct a colour image to superimpose # Construct a colour image to superimpose
color_mask = np.zeros((rows, cols, 3)) color_mask = np.zeros((rows, cols, 3))
red_multiplier = [1, 0.2, 0.2]
green_multiplier = [0.35, 0.75, 0.25] green_multiplier = [0.35, 0.75, 0.25]
blue_multiplier = [0, 0.25, 0.9] blue_multiplier = [0, 0.25, 0.9]
yellow_multiplier = [1, 1, 0.25] yellow_multiplier = [1, 1, 0.25]
......
...@@ -339,8 +339,7 @@ ...@@ -339,8 +339,7 @@
"mimetype": "text/x-python", "mimetype": "text/x-python",
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3"
"version": "3.6.9"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
...@@ -273,8 +273,7 @@ ...@@ -273,8 +273,7 @@
"mimetype": "text/x-python", "mimetype": "text/x-python",
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3"
"version": "3.6.9"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
import numpy as np import numpy as np
import json import json
import time
import os.path import os.path
from os import path
import sys
import tokenizers import tokenizers
from run_onnx_squad import * import collections
from run_onnx_squad import read_squad_examples, write_predictions, convert_examples_to_features
import migraphx import migraphx
RawResult = collections.namedtuple("RawResult",
["unique_id", "start_logits", "end_logits"])
####################################### #######################################
input_file = 'inputs_amd.json' input_file = 'inputs_amd.json'
with open(input_file) as json_file: with open(input_file) as json_file:
......
...@@ -29,7 +29,6 @@ python onnx_squad.py --model $SQUAD_MODEL/squad.onnx \ ...@@ -29,7 +29,6 @@ python onnx_squad.py --model $SQUAD_MODEL/squad.onnx \
import argparse import argparse
import collections import collections
import json import json
import logging
import math import math
import os import os
import sys import sys
...@@ -145,8 +144,6 @@ def convert_examples_to_features(examples, tokenizer, max_seq_length, ...@@ -145,8 +144,6 @@ def convert_examples_to_features(examples, tokenizer, max_seq_length,
tok_to_orig_index.append(i) tok_to_orig_index.append(i)
all_doc_tokens.append(sub_token) all_doc_tokens.append(sub_token)
tok_start_position = None
tok_end_position = None
# The -3 accounts for [CLS], [SEP] and [SEP] # The -3 accounts for [CLS], [SEP] and [SEP]
max_tokens_for_doc = max_seq_length - len(query_tokens) - 3 max_tokens_for_doc = max_seq_length - len(query_tokens) - 3
...@@ -567,7 +564,7 @@ def main(): ...@@ -567,7 +564,7 @@ def main():
sess_options = onnxrt.SessionOptions() sess_options = onnxrt.SessionOptions()
sess_options.session_log_verbosity_level = args.log sess_options.session_log_verbosity_level = args.log
tokenizer = BertWordPieceTokenizer(vocab_file) tokenizer = BertWordPieceTokenizer(args.vocab_file)
eval_examples = read_squad_examples(input_file=args.predict_file) eval_examples = read_squad_examples(input_file=args.predict_file)
input_ids, input_mask, segment_ids, extra_data = \ input_ids, input_mask, segment_ids, extra_data = \
......
...@@ -250,8 +250,7 @@ ...@@ -250,8 +250,7 @@
"mimetype": "text/x-python", "mimetype": "text/x-python",
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3"
"version": "3.6.9"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
...@@ -210,8 +210,7 @@ ...@@ -210,8 +210,7 @@
"mimetype": "text/x-python", "mimetype": "text/x-python",
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3"
"version": "3.6.9"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment