Hi Douwe:
After I add "from measure_map import format_img", the snippet can be run. But it has the following error. Please help figure it our. Thank a lot in advance.
import cv2
from measure_map import format_img
img = cv2.imread('/home/mike/Documents/dl-cookbook/data/cat_dog.jpg')
# -X, ratio = format_img(img, c)
X, ratio = format_img(img, c)
# -if K.image_dim_ordering() == 'tf':
if K.image_data_format() == 'channels_last':
X = np.transpose(X, (0, 2, 3, 1))
y1, y2, f = model_rpn.predict(X)
# -r = keras_frcnn.roi_helpers.rpn_to_roi(y1, y2, c, K.image_dim_ordering(), overlap_thresh=0.7)
r = keras_frcnn.roi_helpers.rpn_to_roi(y1, y2, c, K.image_data_format(), overlap_thresh=0.7)
roi_count = R.shape[0] // c.num_rois
r2 = np.zeros((roi_count * c.num_rois, r.shape[1]))
r2 = r[:r2.shape[0],:r2.shape[1]]
r2 = np.reshape(r2, (roi_count, c.num_rois, r.shape[1]))
_Usage: ipykernel_launcher.py [options]
ipykernel_launcher.py: error: no such option: -f
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.
Traceback (most recent call last):
File "/home/mike/miniconda3/lib/python3.7/optparse.py", line 1387, in parse_args
stop = self._process_args(largs, rargs, values)
File "/home/mike/miniconda3/lib/python3.7/optparse.py", line 1431, in _process_args
self._process_short_opts(rargs, values)
File "/home/mike/miniconda3/lib/python3.7/optparse.py", line 1513, in _process_short_opts
raise BadOptionError(opt)
optparse.BadOptionError: no such option: -f
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/mike/miniconda3/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3343, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 2, in
from measure_map import format_img
File "/home/mike/Documents/dl-cookbook/keras_frcnn/measure_map.py", line 91, in
(options, args) = parser.parse_args()
File "/home/mike/miniconda3/lib/python3.7/optparse.py", line 1389, in parse_args
self.error(str(err))
File "/home/mike/miniconda3/lib/python3.7/optparse.py", line 1569, in error
self.exit(2, "%s: error: %s\n" % (self.get_prog_name(), msg))
File "/home/mike/miniconda3/lib/python3.7/optparse.py", line 1559, in exit
sys.exit(status)
SystemExit: 2
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/mike/miniconda3/lib/python3.7/site-packages/IPython/core/ultratb.py", line 1169, in get_records
return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset)
File "/home/mike/miniconda3/lib/python3.7/site-packages/IPython/core/ultratb.py", line 316, in wrapped
return f(*args, **kwargs)
File "/home/mike/miniconda3/lib/python3.7/site-packages/IPython/core/ultratb.py", line 350, in _fixed_getinnerframes
records = fix_frame_records_filenames(inspect.getinnerframes(etb, context))
File "/home/mike/miniconda3/lib/python3.7/inspect.py", line 1502, in getinnerframes
frameinfo = (tb.tb_frame,) + getframeinfo(tb, context)
AttributeError: 'tuple' object has no attribute 'tb_frame'
BadOptionError Traceback (most recent call last)
~/miniconda3/lib/python3.7/optparse.py in parse_args(self, args, values)
1386 try:
-> 1387 stop = self._process_args(largs, rargs, values)
1388 except (BadOptionError, OptionValueError) as err:
~/miniconda3/lib/python3.7/optparse.py in _process_args(self, largs, rargs, values)
1430 # value(s) for the last one only)
-> 1431 self._process_short_opts(rargs, values)
1432 elif self.allow_interspersed_args:
~/miniconda3/lib/python3.7/optparse.py in _process_short_opts(self, rargs, values)
1512 if not option:
-> 1513 raise BadOptionError(opt)
1514 if option.takes_value():
BadOptionError: no such option: -f
During handling of the above exception, another exception occurred:
SystemExit Traceback (most recent call last)
[... skipping hidden 1 frame]
in
1 import cv2
----> 2 from measure_map import format_img
3
~/Documents/dl-cookbook/keras_frcnn/measure_map.py in
90
---> 91 (options, args) = parser.parse_args()
92
~/miniconda3/lib/python3.7/optparse.py in parse_args(self, args, values)
1388 except (BadOptionError, OptionValueError) as err:
-> 1389 self.error(str(err))
1390
~/miniconda3/lib/python3.7/optparse.py in error(self, msg)
1568 self.print_usage(sys.stderr)
-> 1569 self.exit(2, "%s: error: %s\n" % (self.get_prog_name(), msg))
1570
~/miniconda3/lib/python3.7/optparse.py in exit(self, status, msg)
1558 sys.stderr.write(msg)
-> 1559 sys.exit(status)
1560
SystemExit: 2
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
[... skipping hidden 1 frame]
~/miniconda3/lib/python3.7/site-packages/IPython/core/interactiveshell.py in showtraceback(self, exc_tuple, filename, tb_offset, exception_only, running_compiled_code)
2036 'the full traceback.\n']
2037 stb.extend(self.InteractiveTB.get_exception_only(etype,
-> 2038 value))
2039 else:
2040 try:
~/miniconda3/lib/python3.7/site-packages/IPython/core/ultratb.py in get_exception_only(self, etype, value)
821 value : exception value
822 """
--> 823 return ListTB.structured_traceback(self, etype, value)
824
825 def show_exception_only(self, etype, evalue):
~/miniconda3/lib/python3.7/site-packages/IPython/core/ultratb.py in structured_traceback(self, etype, evalue, etb, tb_offset, context)
700 chained_exceptions_tb_offset, context)
701 + chained_exception_message
--> 702 + out_list)
703
704 return out_list
~/miniconda3/lib/python3.7/site-packages/IPython/core/ultratb.py in structured_traceback(self, etype, value, tb, tb_offset, number_of_lines_of_context)
1434 self.tb = tb
1435 return FormattedTB.structured_traceback(
-> 1436 self, etype, value, tb, tb_offset, number_of_lines_of_context)
1437
1438
~/miniconda3/lib/python3.7/site-packages/IPython/core/ultratb.py in structured_traceback(self, etype, value, tb, tb_offset, number_of_lines_of_context)
1334 # Verbose modes need a full traceback
1335 return VerboseTB.structured_traceback(
-> 1336 self, etype, value, tb, tb_offset, number_of_lines_of_context
1337 )
1338 elif mode == 'Minimal':
~/miniconda3/lib/python3.7/site-packages/IPython/core/ultratb.py in structured_traceback(self, etype, evalue, etb, tb_offset, number_of_lines_of_context)
1191
1192 formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,
-> 1193 tb_offset)
1194
1195 colors = self.Colors # just a shorthand + quicker name lookup
~/miniconda3/lib/python3.7/site-packages/IPython/core/ultratb.py in format_exception_as_a_whole(self, etype, evalue, etb, number_of_lines_of_context, tb_offset)
1148
1149
-> 1150 last_unique, recursion_repeat = find_recursion(orig_etype, evalue, records)
1151
1152 frames = self.format_records(records, last_unique, recursion_repeat)
~/miniconda3/lib/python3.7/site-packages/IPython/core/ultratb.py in find_recursion(etype, value, records)
449 # first frame (from in to out) that looks different.
450 if not is_recursion_error(etype, value, records):
--> 451 return len(records), 0
452
453 # Select filename, lineno, func_name to track frames with
TypeError: object of type 'NoneType' has no len()_
Hi Douwe:
After I add "from measure_map import format_img", the snippet can be run. But it has the following error. Please help figure it our. Thank a lot in advance.
_Usage: ipykernel_launcher.py [options]
ipykernel_launcher.py: error: no such option: -f
ERROR:root:Internal Python error in the inspect module.
Below is the traceback from this internal error.
Traceback (most recent call last):
File "/home/mike/miniconda3/lib/python3.7/optparse.py", line 1387, in parse_args
stop = self._process_args(largs, rargs, values)
File "/home/mike/miniconda3/lib/python3.7/optparse.py", line 1431, in _process_args
self._process_short_opts(rargs, values)
File "/home/mike/miniconda3/lib/python3.7/optparse.py", line 1513, in _process_short_opts
raise BadOptionError(opt)
optparse.BadOptionError: no such option: -f
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/mike/miniconda3/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3343, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 2, in
from measure_map import format_img
File "/home/mike/Documents/dl-cookbook/keras_frcnn/measure_map.py", line 91, in
(options, args) = parser.parse_args()
File "/home/mike/miniconda3/lib/python3.7/optparse.py", line 1389, in parse_args
self.error(str(err))
File "/home/mike/miniconda3/lib/python3.7/optparse.py", line 1569, in error
self.exit(2, "%s: error: %s\n" % (self.get_prog_name(), msg))
File "/home/mike/miniconda3/lib/python3.7/optparse.py", line 1559, in exit
sys.exit(status)
SystemExit: 2
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/mike/miniconda3/lib/python3.7/site-packages/IPython/core/ultratb.py", line 1169, in get_records
return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset)
File "/home/mike/miniconda3/lib/python3.7/site-packages/IPython/core/ultratb.py", line 316, in wrapped
return f(*args, **kwargs)
File "/home/mike/miniconda3/lib/python3.7/site-packages/IPython/core/ultratb.py", line 350, in _fixed_getinnerframes
records = fix_frame_records_filenames(inspect.getinnerframes(etb, context))
File "/home/mike/miniconda3/lib/python3.7/inspect.py", line 1502, in getinnerframes
frameinfo = (tb.tb_frame,) + getframeinfo(tb, context)
AttributeError: 'tuple' object has no attribute 'tb_frame'
BadOptionError Traceback (most recent call last)
~/miniconda3/lib/python3.7/optparse.py in parse_args(self, args, values)
1386 try:
-> 1387 stop = self._process_args(largs, rargs, values)
1388 except (BadOptionError, OptionValueError) as err:
~/miniconda3/lib/python3.7/optparse.py in _process_args(self, largs, rargs, values)
1430 # value(s) for the last one only)
-> 1431 self._process_short_opts(rargs, values)
1432 elif self.allow_interspersed_args:
~/miniconda3/lib/python3.7/optparse.py in _process_short_opts(self, rargs, values)
1512 if not option:
-> 1513 raise BadOptionError(opt)
1514 if option.takes_value():
BadOptionError: no such option: -f
During handling of the above exception, another exception occurred:
SystemExit Traceback (most recent call last)
[... skipping hidden 1 frame]
in
1 import cv2
----> 2 from measure_map import format_img
3
~/Documents/dl-cookbook/keras_frcnn/measure_map.py in
90
---> 91 (options, args) = parser.parse_args()
92
~/miniconda3/lib/python3.7/optparse.py in parse_args(self, args, values)
1388 except (BadOptionError, OptionValueError) as err:
-> 1389 self.error(str(err))
1390
~/miniconda3/lib/python3.7/optparse.py in error(self, msg)
1568 self.print_usage(sys.stderr)
-> 1569 self.exit(2, "%s: error: %s\n" % (self.get_prog_name(), msg))
1570
~/miniconda3/lib/python3.7/optparse.py in exit(self, status, msg)
1558 sys.stderr.write(msg)
-> 1559 sys.exit(status)
1560
SystemExit: 2
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
[... skipping hidden 1 frame]
~/miniconda3/lib/python3.7/site-packages/IPython/core/interactiveshell.py in showtraceback(self, exc_tuple, filename, tb_offset, exception_only, running_compiled_code)
2036 'the full traceback.\n']
2037 stb.extend(self.InteractiveTB.get_exception_only(etype,
-> 2038 value))
2039 else:
2040 try:
~/miniconda3/lib/python3.7/site-packages/IPython/core/ultratb.py in get_exception_only(self, etype, value)
821 value : exception value
822 """
--> 823 return ListTB.structured_traceback(self, etype, value)
824
825 def show_exception_only(self, etype, evalue):
~/miniconda3/lib/python3.7/site-packages/IPython/core/ultratb.py in structured_traceback(self, etype, evalue, etb, tb_offset, context)
700 chained_exceptions_tb_offset, context)
701 + chained_exception_message
--> 702 + out_list)
703
704 return out_list
~/miniconda3/lib/python3.7/site-packages/IPython/core/ultratb.py in structured_traceback(self, etype, value, tb, tb_offset, number_of_lines_of_context)
1434 self.tb = tb
1435 return FormattedTB.structured_traceback(
-> 1436 self, etype, value, tb, tb_offset, number_of_lines_of_context)
1437
1438
~/miniconda3/lib/python3.7/site-packages/IPython/core/ultratb.py in structured_traceback(self, etype, value, tb, tb_offset, number_of_lines_of_context)
1334 # Verbose modes need a full traceback
1335 return VerboseTB.structured_traceback(
-> 1336 self, etype, value, tb, tb_offset, number_of_lines_of_context
1337 )
1338 elif mode == 'Minimal':
~/miniconda3/lib/python3.7/site-packages/IPython/core/ultratb.py in structured_traceback(self, etype, evalue, etb, tb_offset, number_of_lines_of_context)
1191
1192 formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,
-> 1193 tb_offset)
1194
1195 colors = self.Colors # just a shorthand + quicker name lookup
~/miniconda3/lib/python3.7/site-packages/IPython/core/ultratb.py in format_exception_as_a_whole(self, etype, evalue, etb, number_of_lines_of_context, tb_offset)
1148
1149
-> 1150 last_unique, recursion_repeat = find_recursion(orig_etype, evalue, records)
1151
1152 frames = self.format_records(records, last_unique, recursion_repeat)
~/miniconda3/lib/python3.7/site-packages/IPython/core/ultratb.py in find_recursion(etype, value, records)
449 # first frame (from in to out) that looks different.
450 if not is_recursion_error(etype, value, records):
--> 451 return len(records), 0
452
453 # Select filename, lineno, func_name to track frames with
TypeError: object of type 'NoneType' has no len()_