vtool-ibeis 2.2.1__py3-none-any.whl → 2.3.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
vtool_ibeis/__init__.py CHANGED
@@ -5,7 +5,7 @@ Autogenerate Command:
5
5
  mkinit vtool_ibeis -i
6
6
  """
7
7
  # flake8: noqa
8
- __version__ = '2.2.1'
8
+ __version__ = '2.3.1'
9
9
  __author__ = 'Jon Crall, Avi Weinstock, Chuck Stewart, Hendrik Weideman, Jason Parham, Zackary Rutfield'
10
10
  __author_email__ = 'erotemic@gmail.com'
11
11
  __url__ = 'https://github.com/Erotemic/vtool_ibeis'
vtool_ibeis/blend.py CHANGED
@@ -5,7 +5,7 @@ import ubelt as ub
5
5
 
6
6
  def testdata_blend(scale=128):
7
7
  import vtool_ibeis as vt
8
- img_fpath = ut.grab_test_imgpath('lena.png')
8
+ img_fpath = ut.grab_test_imgpath('astro')
9
9
  img1 = vt.imread(img_fpath)
10
10
  rng = np.random.RandomState(0)
11
11
  img2 = vt.perlin_noise(img1.shape[0:2], scale=scale, rng=rng)[None, :].T
@@ -282,7 +282,7 @@ def find_duplicate_items(item_arr):
282
282
  >>> np.random.seed(0)
283
283
  >>> item_arr = np.random.randint(100, size=30)
284
284
  >>> duplicate_items = find_duplicate_items(item_arr)
285
- >>> assert duplicate_items == list(six.iterkeys(ut.find_duplicate_items(item_arr)))
285
+ >>> assert duplicate_items == list(ut.find_duplicate_items(item_arr).keys())
286
286
  >>> result = str(duplicate_items)
287
287
  >>> print(result)
288
288
  [9, 67, 87, 88]
vtool_ibeis/confusion.py CHANGED
@@ -382,12 +382,7 @@ class ConfusionMetrics(ub.NiceRepr):
382
382
  # sklearn has much faster implementation
383
383
  # n_fp - count the number of false positives with score >= threshold[i]
384
384
  # n_tp - count the number of true positives with score >= threshold[i]
385
- try:
386
- from sklearn.metrics._ranking import _binary_clf_curve
387
- except ImportError:
388
- from sklearn.metrics.ranking import _binary_clf_curve
389
-
390
- n_fp, n_tp, thresholds = _binary_clf_curve(
385
+ n_fp, n_tp, thresholds = _binary_counts_at_thresholds(
391
386
  labels, scores, pos_label=1)
392
387
 
393
388
  n_samples = len(labels)
@@ -1160,6 +1155,58 @@ def draw_precision_recall_curve(recall_domain, p_interp, title_pref=None,
1160
1155
  #fig.show()
1161
1156
 
1162
1157
 
1158
+ def _binary_clf_curve_local(y_true, y_score, pos_label=1):
1159
+ """
1160
+ Minimal replacement for sklearn.metrics._ranking._binary_clf_curve (unweighted).
1161
+ Returns: fps, tps, thresholds
1162
+ """
1163
+ import numpy as np
1164
+
1165
+ y_true = np.asarray(y_true)
1166
+ y_score = np.asarray(y_score)
1167
+
1168
+ y_true = (y_true == pos_label)
1169
+
1170
+ # sort scores descending
1171
+ desc = np.argsort(y_score, kind="mergesort")[::-1]
1172
+ y_score = y_score[desc]
1173
+ y_true = y_true[desc]
1174
+
1175
+ # indices where score changes
1176
+ distinct = np.where(np.diff(y_score))[0]
1177
+ threshold_idxs = np.r_[distinct, y_true.size - 1]
1178
+
1179
+ tps = np.cumsum(y_true)[threshold_idxs]
1180
+ fps = (threshold_idxs + 1) - tps
1181
+ thresholds = y_score[threshold_idxs]
1182
+ return fps, tps, thresholds
1183
+
1184
+
1185
+ def _binary_counts_at_thresholds(labels, scores, pos_label=1):
1186
+ """
1187
+ Returns fps, tps, thresholds (like old _binary_clf_curve) using public API when available.
1188
+ """
1189
+ try:
1190
+ from sklearn.metrics._ranking import _binary_clf_curve
1191
+ except ImportError:
1192
+ try:
1193
+ from sklearn.metrics.ranking import _binary_clf_curve
1194
+ except ImportError:
1195
+ _binary_clf_curve = None
1196
+
1197
+ if _binary_clf_curve is not None:
1198
+ n_fp, n_tp, thresholds = _binary_clf_curve(
1199
+ labels, scores, pos_label=1)
1200
+ else:
1201
+ # scikit-learn >= 1.8
1202
+ n_fp, n_tp, thresholds = _binary_clf_curve_local(labels, scores, pos_label)
1203
+ # from sklearn.metrics import confusion_matrix_at_thresholds
1204
+ # n_tp, n_fp, fns, tps, thresholds = confusion_matrix_at_thresholds(
1205
+ # labels, scores, pos_label=pos_label
1206
+ # )
1207
+ return n_fp, n_tp, thresholds
1208
+
1209
+
1163
1210
  if __name__ == '__main__':
1164
1211
  """
1165
1212
  CommandLine:
@@ -34,7 +34,7 @@ def make_grid_coverage_mask(kpts, chipsize, weights, pxl_per_bin=4,
34
34
  >>> from vtool_ibeis.coverage_grid import * # NOQA
35
35
  >>> import vtool_ibeis as vt
36
36
  >>> # build test data
37
- >>> kpts, chipsize, weights = coverage_kpts.testdata_coverage('easy1.png')
37
+ >>> kpts, chipsize, weights = coverage_kpts.testdata_coverage('tsukuba_l')
38
38
  >>> pxl_per_bin = 4
39
39
  >>> grid_steps = 2
40
40
  >>> # execute function
@@ -323,7 +323,7 @@ def gridsearch_coverage_grid_mask():
323
323
  """
324
324
  import plottool_ibeis as pt
325
325
  cfgdict_list, cfglbl_list = get_coverage_grid_gridsearch_configs()
326
- kpts, chipsize, weights = coverage_kpts.testdata_coverage('easy1.png')
326
+ kpts, chipsize, weights = coverage_kpts.testdata_coverage('astro')
327
327
  gridmask_list = [
328
328
  255 * make_grid_coverage_mask(kpts, chipsize, weights, **cfgdict)
329
329
  for cfgdict in ub.ProgIter(cfgdict_list, desc='coverage grid')
@@ -37,7 +37,7 @@ def make_kpts_heatmask(kpts, chipsize, cmap='plasma'):
37
37
  >>> from vtool_ibeis.coverage_kpts import * # NOQA
38
38
  >>> import vtool_ibeis as vt
39
39
  >>> import pyhesaff
40
- >>> img_fpath = ut.grab_test_imgpath('carl.jpg')
40
+ >>> img_fpath = ut.grab_test_imgpath('carl')
41
41
  >>> (kpts, vecs) = pyhesaff.detect_feats(img_fpath)
42
42
  >>> chip = vt.imread(img_fpath)
43
43
  >>> kpts = kpts[0:100]
@@ -129,7 +129,7 @@ def make_kpts_coverage_mask(
129
129
  >>> import vtool_ibeis as vt
130
130
  >>> import plottool_ibeis as pt
131
131
  >>> import pyhesaff
132
- >>> img_fpath = ut.grab_test_imgpath('carl.jpg')
132
+ >>> img_fpath = ut.grab_test_imgpath('carl')
133
133
  >>> (kpts, vecs) = pyhesaff.detect_feats(img_fpath)
134
134
  >>> kpts = kpts[::10]
135
135
  >>> chip = vt.imread(img_fpath)
@@ -210,7 +210,7 @@ def warp_patch_onto_kpts(
210
210
  >>> from vtool_ibeis.coverage_kpts import * # NOQA
211
211
  >>> import vtool_ibeis as vt
212
212
  >>> import pyhesaff
213
- >>> img_fpath = ut.grab_test_imgpath('carl.jpg')
213
+ >>> img_fpath = ut.grab_test_imgpath('carl')
214
214
  >>> (kpts, vecs) = pyhesaff.detect_feats(img_fpath)
215
215
  >>> kpts = kpts[::15]
216
216
  >>> chip = vt.imread(img_fpath)
@@ -434,7 +434,8 @@ def gridsearch_kpts_coverage_mask():
434
434
  """
435
435
  import plottool_ibeis as pt
436
436
  cfgdict_list, cfglbl_list = get_coverage_kpts_gridsearch_configs()
437
- kpts, chipsize, weights = testdata_coverage('easy1.png')
437
+ # kpts, chipsize, weights = testdata_coverage('easy1.png')
438
+ kpts, chipsize, weights = testdata_coverage('astro')
438
439
  imgmask_list = [
439
440
  255 * make_kpts_coverage_mask(kpts, chipsize, weights,
440
441
  return_patch=False, **cfgdict)
@@ -459,18 +460,18 @@ def testdata_coverage(fname=None):
459
460
  # build test data
460
461
  kpts, vecs = vt.demodata.get_testdata_kpts(fname, with_vecs=True)
461
462
  # HACK IN DISTINCTIVENESS
462
- if fname is not None:
463
- from ibeis.algo.hots import distinctiveness_normalizer
464
- cachedir = ub.ensure_app_cache_dir('ibeis', 'distinctiveness_model')
465
- species = 'zebra_plains'
466
- dstcnvs_normer = distinctiveness_normalizer.DistinctivnessNormalizer(species, cachedir=cachedir)
467
- dstcnvs_normer.load(cachedir)
468
- weights = dstcnvs_normer.get_distinctiveness(vecs)
469
- else:
470
- kpts = np.vstack((kpts, [0, 0, 1, 1, 1, 0]))
471
- kpts = np.vstack((kpts, [0.01, 10, 1, 1, 1, 0]))
472
- kpts = np.vstack((kpts, [0.94, 11.5, 1, 1, 1, 0]))
473
- weights = np.ones(len(kpts))
463
+ # if fname is not None:
464
+ # from ibeis.algo.hots import distinctiveness_normalizer
465
+ # cachedir = ub.ensure_app_cache_dir('ibeis', 'distinctiveness_model')
466
+ # species = 'zebra_plains'
467
+ # dstcnvs_normer = distinctiveness_normalizer.DistinctivnessNormalizer(species, cachedir=cachedir)
468
+ # dstcnvs_normer.load(cachedir)
469
+ # weights = dstcnvs_normer.get_distinctiveness(vecs)
470
+ # else:
471
+ kpts = np.vstack((kpts, [0, 0, 1, 1, 1, 0]))
472
+ kpts = np.vstack((kpts, [0.01, 10, 1, 1, 1, 0]))
473
+ kpts = np.vstack((kpts, [0.94, 11.5, 1, 1, 1, 0]))
474
+ weights = np.ones(len(kpts))
474
475
  chipsize = tuple(vt.iceil(vt.get_kpts_image_extent(kpts)[2:4]).tolist())
475
476
  return kpts, chipsize, weights
476
477
 
vtool_ibeis/demodata.py CHANGED
@@ -633,7 +633,7 @@ def get_testdata_kpts(fname=None, with_vecs=False):
633
633
  return kpts
634
634
 
635
635
 
636
- def testdata_ratio_matches(fname1='easy1.png', fname2='easy2.png', **kwargs):
636
+ def testdata_ratio_matches(fname1='tsukuba_r', fname2='tsukuba_l', **kwargs):
637
637
  r"""
638
638
  Runs simple ratio-test matching between two images.
639
639
  Technically this is not demodata data.
@@ -659,8 +659,8 @@ def testdata_ratio_matches(fname1='easy1.png', fname2='easy2.png', **kwargs):
659
659
  >>> # xdoctest: +REQUIRES(module:pyhesaff)
660
660
  >>> from vtool_ibeis.demodata import * # NOQA
661
661
  >>> import vtool_ibeis as vt
662
- >>> fname1 = ut.get_argval('--fname1', type_=str, default='easy1.png')
663
- >>> fname2 = ut.get_argval('--fname2', type_=str, default='easy2.png')
662
+ >>> fname1 = ut.get_argval('--fname1', type_=str, default='tsukuba_l')
663
+ >>> fname2 = ut.get_argval('--fname2', type_=str, default='tsukuba_r')
664
664
  >>> default_dict = vt.get_extract_features_default_params()
665
665
  >>> default_dict['ratio_thresh'] = .625
666
666
  >>> kwargs = ut.argparse_dict(default_dict)
vtool_ibeis/distance.py CHANGED
@@ -732,6 +732,25 @@ def safe_pdist(arr, *args, **kwargs):
732
732
 
733
733
  SeeAlso:
734
734
  scipy.spatial.distance.pdist
735
+
736
+ Example:
737
+ >>> # xdoctest: +REQUIRES(module:vtool)
738
+ >>> import vtool_ibeis as vt
739
+ >>> import numpy as np
740
+ >>> arr = np.array([1, 2, 3, 4, 5])
741
+ >>> result = vt.safe_pdist(arr)
742
+ >>> assert result.shape == (10,)
743
+ >>> # metric needs to return a scalar, even if the inputs are vectors
744
+ >>> # Test the use-cases in ibeis
745
+ >>> result = vt.safe_pdist(arr, metric=lambda x, y: abs(x - y).item())
746
+ >>> assert result.shape == (10,)
747
+ >>> result = vt.safe_pdist(arr, metric=lambda *a: ut.unixtime_hourdiff(*a)[0])
748
+ >>> assert result.shape == (10,)
749
+ >>> result = vt.safe_pdist(arr, metric=lambda *a: vt.ori_distance(*a)[0])
750
+ >>> assert result.shape == (10,)
751
+ >>> latlon_arr = np.array([(40, 20), (20, 30), (-40, 20)])
752
+ >>> km_dists = ut.safe_pdist(latlon_arr, metric=vt.haversine)
753
+ >>> assert km_dists.shape == (3,)
735
754
  """
736
755
  if arr is None or len(arr) < 2:
737
756
  return None
vtool_ibeis/exif.py CHANGED
@@ -244,7 +244,7 @@ def get_lat_lon(exif_dict, default=(-1, -1)):
244
244
  python -m vtool_ibeis.exif --test-get_lat_lon
245
245
 
246
246
  Example:
247
- >>> # DISABLE_DOCTEST
247
+ >>> # xdoctest: +SKIP("bad url")
248
248
  >>> from vtool_ibeis.exif import * # NOQA
249
249
  >>> import numpy as np
250
250
  >>> image_fpath = ut.grab_file_url('http://images.summitpost.org/original/769474.JPG')
@@ -294,7 +294,7 @@ def get_orientation(exif_dict, default=0, on_error='warn'):
294
294
  python -m vtool_ibeis.exif --test-get_orientation
295
295
 
296
296
  Example:
297
- >>> # ENABLE_DOCTEST
297
+ >>> # xdoctest: +SKIP("bad url")
298
298
  >>> from vtool_ibeis.exif import * # NOQA
299
299
  >>> from os.path import join
300
300
  >>> import numpy as np
@@ -334,7 +334,7 @@ def get_orientation_str(exif_dict, **kwargs):
334
334
  python -m vtool_ibeis.exif --test-get_orientation_str
335
335
 
336
336
  Example:
337
- >>> # ENABLE_DOCTEST
337
+ >>> # xdoctest: +SKIP("bad url")
338
338
  >>> from vtool_ibeis.exif import * # NOQA
339
339
  >>> from os.path import join
340
340
  >>> import numpy as np
@@ -360,7 +360,7 @@ def get_unixtime(exif_dict, default=-1):
360
360
  TODO: Exif.Image.TimeZoneOffset
361
361
 
362
362
  Example:
363
- >>> # ENABLE_DOCTEST
363
+ >>> # xdoctest: +SKIP("bad url")
364
364
  >>> from vtool_ibeis.exif import * # NOQA
365
365
  >>> image_fpath = ut.grab_file_url('http://images.summitpost.org/original/769474.JPG')
366
366
  >>> pil_img = Image.open(image_fpath)
vtool_ibeis/features.py CHANGED
@@ -1,6 +1,5 @@
1
1
  import utool as ut
2
2
  import ubelt as ub
3
- import six
4
3
 
5
4
 
6
5
  def extract_feature_from_patch(patch):
@@ -41,7 +40,7 @@ def extract_features(img_or_fpath, feat_type='hesaff+sift', **kwargs):
41
40
  >>> from vtool_ibeis.features import * # NOQA
42
41
  >>> import vtool_ibeis as vt
43
42
  >>> # build test data
44
- >>> img_fpath = ut.grab_test_imgpath(ut.get_argval('--fname', default='lena.png'))
43
+ >>> img_fpath = ut.grab_test_imgpath(ut.get_argval('--fname', default='astro'))
45
44
  >>> imgBGR = vt.imread(img_fpath)
46
45
  >>> feat_type = ub.argval('--feat_type', default='hesaff+sift')
47
46
  >>> import pyhesaff
@@ -69,7 +68,7 @@ def extract_features(img_or_fpath, feat_type='hesaff+sift', **kwargs):
69
68
  # hacky
70
69
  from ibeis_cnn import _plugin
71
70
  (kpts, sift) = pyhesaff.detect_feats2(img_or_fpath, **kwargs)
72
- if isinstance(img_or_fpath, six.string_types):
71
+ if isinstance(img_or_fpath, str):
73
72
  import vtool_ibeis as vt
74
73
  img_or_fpath = vt.imread(img_or_fpath)
75
74
  vecs_list = _plugin.extract_siam128_vecs([img_or_fpath], [kpts])
@@ -109,8 +108,7 @@ def detect_opencv_keypoints():
109
108
  import vtool_ibeis as vt
110
109
  import numpy as np # NOQA
111
110
 
112
- #img_fpath = ut.grab_test_imgpath(ub.argval('--fname', default='lena.png'))
113
- img_fpath = ut.grab_test_imgpath(ub.argval('--fname', default='zebra.png'))
111
+ img_fpath = ut.grab_test_imgpath(ub.argval('--fname', default='astro'))
114
112
  imgBGR = vt.imread(img_fpath)
115
113
  imgGray = cv2.cvtColor(imgBGR, cv2.COLOR_BGR2GRAY)
116
114
 
@@ -251,7 +249,7 @@ def test_mser():
251
249
  info = {key: list(ub.compress(val, flags)) for key, val in self.info.items()}
252
250
  return Keypoints(subarr, info)
253
251
 
254
- img_fpath = ut.grab_test_imgpath(ub.argval('--fname', default='zebra.png'))
252
+ img_fpath = ut.grab_test_imgpath(ub.argval('--fname', default='astro'))
255
253
  imgBGR = vt.imread(img_fpath)
256
254
  imgGray = cv2.cvtColor(imgBGR, cv2.COLOR_BGR2GRAY)
257
255
  # http://docs.opencv.org/master/d3/d28/classcv_1_1MSER.html#gsc.tab=0
vtool_ibeis/geometry.py CHANGED
@@ -23,9 +23,6 @@ def verts_from_bbox(bbox, close=False):
23
23
  Returns:
24
24
  list: verts
25
25
 
26
- CommandLine:
27
- python -m vtool_ibeis.geometry --test-verts_from_bbox
28
-
29
26
  Example:
30
27
  >>> # ENABLE_DOCTEST
31
28
  >>> from vtool_ibeis.geometry import * # NOQA
@@ -66,14 +63,11 @@ def draw_border(img_in, color=(0, 128, 255), thickness=2, out=None):
66
63
  thickness (int):
67
64
  out (None):
68
65
 
69
- CommandLine:
70
- python -m vtool_ibeis.geometry --test-draw_border --show
71
-
72
66
  Example:
73
67
  >>> # ENABLE_DOCTEST
74
68
  >>> from vtool_ibeis.geometry import * # NOQA
75
69
  >>> import vtool_ibeis as vt
76
- >>> img_in = vt.imread(ut.grab_test_imgpath('carl.jpg'))
70
+ >>> img_in = vt.imread(ut.grab_test_imgpath('carl'))
77
71
  >>> color = (0, 128, 255)
78
72
  >>> thickness = 20
79
73
  >>> out = None
@@ -121,7 +115,7 @@ def draw_verts(img_in, verts, color=(0, 128, 255), thickness=2, out=None):
121
115
  >>> import plottool_ibeis as pt
122
116
  >>> import vtool_ibeis as vt
123
117
  >>> # build test data
124
- >>> img_in = vt.imread(ut.grab_test_imgpath('carl.jpg'))
118
+ >>> img_in = vt.imread(ut.grab_test_imgpath('carl'))
125
119
  >>> verts = ((10, 10), (10, 100), (100, 100), (100, 10))
126
120
  >>> color = (0, 128, 255)
127
121
  >>> thickness = 2
@@ -143,7 +137,7 @@ def draw_verts(img_in, verts, color=(0, 128, 255), thickness=2, out=None):
143
137
  >>> import plottool_ibeis as pt
144
138
  >>> import vtool_ibeis as vt
145
139
  >>> # build test data
146
- >>> img_in = vt.imread(ut.grab_test_imgpath('carl.jpg'))
140
+ >>> img_in = vt.imread(ut.grab_test_imgpath('carl'))
147
141
  >>> verts = ((10, 10), (10, 100), (100, 100), (100, 10))
148
142
  >>> color = (0, 128, 255)
149
143
  >>> thickness = 2
vtool_ibeis/histogram.py CHANGED
@@ -20,18 +20,21 @@ def argsubmax(ydata, xdata=None):
20
20
  >>> xdata = [00, 10, 20, 30, 40]
21
21
  >>> result1 = argsubmax(ydata, xdata=None)
22
22
  >>> result2 = argsubmax(ydata, xdata=xdata)
23
- >>> result = ub.repr2([result1, result2], precision=4, nl=1, nobr=True)
24
- >>> print(result)
25
- 2.1667, 2.0208,
26
- 21.6667, 2.0208,
23
+ >>> import ubelt as ub
24
+ >>> print(f'result1 = {ub.urepr(result1, nl=0, precision=3)}')
25
+ >>> print(f'result2 = {ub.urepr(result2, nl=0, precision=3)}')
26
+ result1 = (2.167, 2.021)
27
+ result2 = (21.667, 2.021)
27
28
 
28
29
  Example:
29
30
  >>> from vtool_ibeis.histogram import * # NOQA
30
31
  >>> hist_ = np.array([0, 1, 2, 3, 4])
31
32
  >>> centers = None
32
33
  >>> maxima_thresh=None
33
- >>> argsubmax(hist_)
34
- (4.0, 4.0)
34
+ >>> result = argsubmax(hist_)
35
+ >>> import ubelt as ub
36
+ >>> print(f'result = {ub.urepr(result, nl=0)}')
37
+ result = (4.0, 4.0)
35
38
  """
36
39
  if len(ydata) == 0:
37
40
  raise IndexError('zero length array')
@@ -975,8 +978,8 @@ def show_ori_image_ondisk():
975
978
  >>> pt.show_if_requested()
976
979
  """
977
980
  #if img_fpath is not None:
978
- # img_fpath = ut.get_argval('--fpath', type_=str, default=ut.grab_test_imgpath('star.png'))
979
- # img_fpath = ut.get_argval('--fpath', type_=str, default=ut.grab_test_imgpath('star.png'))
981
+ # img_fpath = ut.get_argval('--fpath', type_=str, default=ut.grab_test_imgpath('astro'))
982
+ # img_fpath = ut.get_argval('--fpath', type_=str, default=ut.grab_test_imgpath('astro'))
980
983
  # img = vt.imread(img_fpath)
981
984
  # ori_img_fpath = ut.get_argval('--fpath-ori', type_=str,
982
985
  # default=ut.augpath(img_fpath, '_ori'))
vtool_ibeis/image.py CHANGED
@@ -1,4 +1,3 @@
1
- import six
2
1
  import os
3
2
  from os.path import exists, join # NOQA
4
3
  from os.path import splitext
@@ -82,7 +81,7 @@ def _rectify_border_mode(border_mode, default=cv2.BORDER_CONSTANT):
82
81
  """ Converts argument to cv2 style """
83
82
  if border_mode is None:
84
83
  return default
85
- elif isinstance(border_mode, six.text_type):
84
+ elif isinstance(border_mode, str):
86
85
  return CV2_BORDER_TYPES[border_mode]
87
86
  else:
88
87
  return border_mode
@@ -102,7 +101,7 @@ def _rectify_interpolation(interp, default=cv2.INTER_LANCZOS4):
102
101
  """
103
102
  if interp is None:
104
103
  return default
105
- elif isinstance(interp, six.text_type):
104
+ elif isinstance(interp, str):
106
105
  try:
107
106
  return CV2_INTERPOLATION_TYPES[interp]
108
107
  except KeyError:
@@ -289,12 +288,12 @@ def imread(img_fpath, grayscale=False, orient=False, flags=None,
289
288
  Example:
290
289
  >>> # ENABLE_DOCTEST
291
290
  >>> from vtool_ibeis.image import * # NOQA
292
- >>> img_fpath = ut.grab_test_imgpath('carl.jpg')
291
+ >>> img_fpath = ut.grab_test_imgpath('astro')
293
292
  >>> imgBGR1 = imread(img_fpath, grayscale=False)
294
293
  >>> imgBGR2 = imread(img_fpath, grayscale=True)
295
294
  >>> imgBGR3 = imread(img_fpath, orient=True)
296
- >>> assert imgBGR1.shape == (250, 300, 3)
297
- >>> assert imgBGR2.shape == (250, 300)
295
+ >>> assert imgBGR1.shape == (512, 512, 3)
296
+ >>> assert imgBGR2.shape == (512, 512)
298
297
  >>> assert np.all(imgBGR1 == imgBGR3)
299
298
  >>> # xdoctest: +REQUIRES(--show)
300
299
  >>> import plottool_ibeis as pt
@@ -332,7 +331,7 @@ def imread(img_fpath, grayscale=False, orient=False, flags=None,
332
331
  (2736, 3648, 3)
333
332
 
334
333
  Example:
335
- >>> # ENABLE_DOCTEST
334
+ >>> # xdoctest +SKIP("networking")
336
335
  >>> from vtool_ibeis.image import * # NOQA
337
336
  >>> url = 'http://www.sherv.net/cm/emo/funny/2/big-dancing-banana-smiley-emoticon.gif'
338
337
  >>> img_fpath = ut.grab_file_url(url)
@@ -441,7 +440,7 @@ def imread_remote_s3(img_fpath, **kwargs):
441
440
 
442
441
 
443
442
  def imread_remote_url(img_url, **kwargs):
444
- from six.moves import urllib
443
+ import urllib
445
444
  import io
446
445
  print("USE PIL REMOTE")
447
446
  addinfourl = urllib.request.urlopen(img_url)
@@ -470,7 +469,10 @@ def _imread_bytesio(image_stream, use_pil=False, flags=None, **kwargs):
470
469
  if flags is None:
471
470
  grayscale = kwargs.get('grayscale', False)
472
471
  flags = cv2.IMREAD_GRAYSCALE if grayscale else IMREAD_COLOR
473
- nparr = np.fromstring(image_stream.getvalue(), np.uint8)
472
+ try:
473
+ nparr = np.fromstring(image_stream.getvalue(), np.uint8)
474
+ except Exception:
475
+ nparr = np.frombuffer(image_stream.getvalue(), np.uint8)
474
476
  imgBGR = cv2.imdecode(nparr, flags=flags) # cv2.IMREAD_COLOR in OpenCV 3.1
475
477
  return imgBGR
476
478
 
@@ -540,10 +542,10 @@ def imwrite(img_fpath, imgBGR, fallback=False):
540
542
  >>> from vtool_ibeis.image import * # NOQA
541
543
  >>> import vtool_ibeis as vt
542
544
  >>> import utool as ut
543
- >>> img_fpath1 = ut.grab_test_imgpath('zebra.png')
545
+ >>> img_fpath1 = ut.grab_test_imgpath('astro')
544
546
  >>> imgBGR = vt.imread(img_fpath1)
545
547
  >>> img_dpath = ub.ensure_app_cache_dir('vtool_ibeis', 'testwrite')
546
- >>> img_fpath2 = ut.unixjoin(img_dpath, 'zebra.png')
548
+ >>> img_fpath2 = ut.unixjoin(img_dpath, 'astro.png')
547
549
  >>> fallback = False
548
550
  >>> imwrite(img_fpath2, imgBGR, fallback=fallback)
549
551
  >>> imgBGR2 = vt.imread(img_fpath2)
@@ -555,7 +557,7 @@ def imwrite(img_fpath, imgBGR, fallback=False):
555
557
  if fallback:
556
558
  try:
557
559
  imwrite_fallback(img_fpath, imgBGR)
558
- except Exception as ex:
560
+ except Exception:
559
561
  pass
560
562
  msg = '[vt.image] ERROR writing: %s' % (img_fpath,)
561
563
  ut.printex(ex, msg, keys=['imgBGR.shape'])
@@ -657,11 +659,11 @@ def open_image_size(image_fpath):
657
659
 
658
660
  Doctest:
659
661
  >>> from vtool_ibeis.image import * # NOQA
660
- >>> image_fpath = ut.grab_test_imgpath('patsy.jpg')
662
+ >>> image_fpath = ut.grab_test_imgpath('carl')
661
663
  >>> size = open_image_size(image_fpath)
662
664
  >>> result = ('size = %s' % (str(size),))
663
665
  >>> print(result)
664
- size = (800, 441)
666
+ size = (328, 448)
665
667
 
666
668
  Ignore:
667
669
  # Confirm that Image.open is a lazy load
@@ -730,7 +732,7 @@ def warpAffine(img, Aff, dsize, assume_float01=True):
730
732
  >>> # DISABLE_DOCTEST
731
733
  >>> from vtool_ibeis.image import * # NOQA
732
734
  >>> import vtool_ibeis as vt
733
- >>> img_fpath = ut.grab_test_imgpath('carl.jpg')
735
+ >>> img_fpath = ut.grab_test_imgpath('carl')
734
736
  >>> img = vt.imread(img_fpath)
735
737
  >>> Aff = vt.rotation_mat3x3(TAU / 8)
736
738
  >>> dsize = vt.get_size(img)
@@ -1106,7 +1108,7 @@ def rotate_image_ondisk(img_fpath, theta, out_fpath=None, **kwargs):
1106
1108
  >>> # DISABLE_DOCTEST
1107
1109
  >>> from vtool_ibeis.image import * # NOQA
1108
1110
  >>> # build test data
1109
- >>> img_fpath = ut.grab_test_imgpath('star.png')
1111
+ >>> img_fpath = ut.grab_test_imgpath('astro')
1110
1112
  >>> theta = TAU * 3 / 8
1111
1113
  >>> # execute function
1112
1114
  >>> out_fpath = None
@@ -1422,9 +1424,9 @@ def convert_colorspace(img, colorspace, src_colorspace='BGR'):
1422
1424
  >>> # DISABLE_DOCTEST
1423
1425
  >>> from vtool_ibeis.image import * # NOQA
1424
1426
  >>> import vtool_ibeis as vt
1425
- >>> img_fpath = ut.grab_test_imgpath('zebra.png')
1426
- >>> img_fpath = ut.grab_file_url('http://itsnasb.com/wp-content/uploads/2013/03/lisa-frank-logo1.jpg')
1427
- >>> img_fpath = ut.grab_test_imgpath('carl.jpg')
1427
+ >>> #img_fpath = ut.grab_file_url('http://itsnasb.com/wp-content/uploads/2013/03/lisa-frank-logo1.jpg')
1428
+ >>> #img_fpath = ut.grab_test_imgpath('carl')
1429
+ >>> img_fpath = ut.grab_test_imgpath('pm5644')
1428
1430
  >>> img = vt.imread(img_fpath)
1429
1431
  >>> img_float = vt.rectify_to_float01(img, np.float32)
1430
1432
  >>> colorspace = 'LAB'
@@ -1508,9 +1510,9 @@ def padded_resize(img, target_size=(64, 64), interpolation=None):
1508
1510
  >>> # ENABLE_DOCTEST
1509
1511
  >>> from vtool_ibeis.image import * # NOQA
1510
1512
  >>> import vtool_ibeis as vt
1511
- >>> imgA = vt.imread(ut.grab_test_imgpath('carl.jpg'))
1512
- >>> imgB = vt.imread(ut.grab_test_imgpath('ada.jpg'))
1513
- >>> imgC = vt.imread(ut.grab_test_imgpath('carl.jpg'), grayscale=True)
1513
+ >>> imgA = vt.imread(ut.grab_test_imgpath('carl'))
1514
+ >>> imgB = vt.imread(ut.grab_test_imgpath('astro'))
1515
+ >>> imgC = vt.imread(ut.grab_test_imgpath('carl'), grayscale=True)
1514
1516
  >>> #target_size = (64, 64)
1515
1517
  >>> target_size = (1024, 1024)
1516
1518
  >>> img3_list = [padded_resize(img, target_size) for img in [imgA, imgB, imgC]]
@@ -1554,7 +1556,7 @@ def embed_in_square_image(img, target_size, img_origin=(.5, .5),
1554
1556
  >>> # DISABLE_DOCTEST
1555
1557
  >>> from vtool_ibeis.image import * # NOQA
1556
1558
  >>> import vtool_ibeis as vt
1557
- >>> img_fpath = ut.grab_test_imgpath('carl.jpg')
1559
+ >>> img_fpath = ut.grab_test_imgpath('carl')
1558
1560
  >>> img = vt.imread(img_fpath)
1559
1561
  >>> target_size = tuple(np.array(vt.get_size(img)) * 3)
1560
1562
  >>> img_origin = (.5, .5)
@@ -1707,7 +1709,7 @@ def resize_to_maxdims(img, max_dsize=(64, 64),
1707
1709
  >>> # ENABLE_DOCTEST
1708
1710
  >>> from vtool_ibeis.image import * # NOQA
1709
1711
  >>> import vtool_ibeis as vt
1710
- >>> img_fpath = ut.grab_test_imgpath('carl.jpg')
1712
+ >>> img_fpath = ut.grab_test_imgpath('carl')
1711
1713
  >>> img = vt.imread(img_fpath)
1712
1714
  >>> max_dsize = (1024, 1024)
1713
1715
  >>> img2 = resize_to_maxdims(img, max_dsize)
@@ -1737,7 +1739,7 @@ def resize_thumb(img, max_dsize=(64, 64), interpolation=None):
1737
1739
  >>> from vtool_ibeis.image import * # NOQA
1738
1740
  >>> import vtool_ibeis as vt
1739
1741
  >>> # build test data
1740
- >>> img_fpath = ut.grab_test_imgpath('carl.jpg')
1742
+ >>> img_fpath = ut.grab_test_imgpath('carl')
1741
1743
  >>> img = vt.imread(img_fpath)
1742
1744
  >>> max_dsize = (64, 64)
1743
1745
  >>> # execute function
@@ -2008,11 +2010,11 @@ def perlin_noise(size, scale=32.0, rng=np.random):
2008
2010
  def testdata_imglist():
2009
2011
  # build test data
2010
2012
  import vtool_ibeis as vt
2011
- img1 = vt.imread(ut.grab_test_imgpath('carl.jpg'))
2012
- img2 = vt.imread(ut.grab_test_imgpath('astro.png'))
2013
- img3 = vt.imread(ut.grab_test_imgpath('ada.jpg'))
2014
- img4 = vt.imread(ut.grab_test_imgpath('jeff.png'))
2015
- img5 = vt.imread(ut.grab_test_imgpath('star.png'))
2013
+ img1 = vt.imread(ut.grab_test_imgpath('carl'))
2014
+ img2 = vt.imread(ut.grab_test_imgpath('astro'))
2015
+ img3 = vt.imread(ut.grab_test_imgpath('stars'))
2016
+ img4 = vt.imread(ut.grab_test_imgpath('pm5644'))
2017
+ img5 = vt.imread(ut.grab_test_imgpath('parrot'))
2016
2018
  img_list = [img1, img2, img3, img4, img5]
2017
2019
  return img_list
2018
2020
 
@@ -2199,7 +2201,7 @@ def combine_offset_lists(offsets_list, sfs_list, offset_tups, sf_tups):
2199
2201
  """ Helper for stacking """
2200
2202
  # combine the offsets
2201
2203
  import operator
2202
- from six.moves import reduce
2204
+ from functools import reduce
2203
2205
 
2204
2206
  assert len(offsets_list) == len(offset_tups)
2205
2207
  assert len(sfs_list) == len(sf_tups)
@@ -2423,9 +2425,9 @@ def ensure_3channel(patch):
2423
2425
  >>> # ENABLE_DOCTEST
2424
2426
  >>> from vtool_ibeis.image import * # NOQA
2425
2427
  >>> import vtool_ibeis as vt
2426
- >>> patch1 = vt.imread(ut.grab_test_imgpath('astro.png'))[0:512, 0:500, :]
2427
- >>> patch2 = vt.imread(ut.grab_test_imgpath('ada.jpg'))[:, :, 0:1]
2428
- >>> patch3 = vt.imread(ut.grab_test_imgpath('jeff.png'))[0:390, 0:400, 0]
2428
+ >>> patch1 = vt.imread(ut.grab_test_imgpath('astro'))[0:512, 0:500, :]
2429
+ >>> patch2 = vt.imread(ut.grab_test_imgpath('carl'))[:, :, 0:1]
2430
+ >>> patch3 = vt.imread(ut.grab_test_imgpath('paraview'))[0:390, 0:400, 0]
2429
2431
  >>> res1 = ensure_3channel(patch1)
2430
2432
  >>> res2 = ensure_3channel(patch2)
2431
2433
  >>> res3 = ensure_3channel(patch3)
@@ -2489,8 +2491,8 @@ def stack_images(img1, img2, vert=None, modifysize=False, return_sf=False,
2489
2491
  >>> from vtool_ibeis.image import * # NOQA
2490
2492
  >>> import vtool_ibeis as vt
2491
2493
  >>> # build test data
2492
- >>> img1 = vt.imread(ut.grab_test_imgpath('carl.jpg'))
2493
- >>> img2 = vt.imread(ut.grab_test_imgpath('astro.png'))
2494
+ >>> img1 = vt.imread(ut.grab_test_imgpath('carl'))
2495
+ >>> img2 = vt.imread(ut.grab_test_imgpath('astro'))
2494
2496
  >>> vert = True
2495
2497
  >>> modifysize = False
2496
2498
  >>> # execute function
@@ -2645,11 +2647,11 @@ def stack_image_recurse(img_list1, img_list2=None, vert=True, modifysize=False,
2645
2647
  >>> from vtool_ibeis.image import * # NOQA
2646
2648
  >>> import vtool_ibeis as vt
2647
2649
  >>> # build test data
2648
- >>> img1 = vt.imread(ut.grab_test_imgpath('carl.jpg'))
2649
- >>> img2 = vt.imread(ut.grab_test_imgpath('astro.png'))
2650
- >>> img3 = vt.imread(ut.grab_test_imgpath('ada.jpg'))
2651
- >>> img4 = vt.imread(ut.grab_test_imgpath('jeff.png'))
2652
- >>> img5 = vt.imread(ut.grab_test_imgpath('star.png'))
2650
+ >>> img1 = vt.imread(ut.grab_test_imgpath('carl'))
2651
+ >>> img2 = vt.imread(ut.grab_test_imgpath('astro'))
2652
+ >>> img3 = vt.imread(ut.grab_test_imgpath('paraview'))
2653
+ >>> img4 = vt.imread(ut.grab_test_imgpath('lowcontrast'))
2654
+ >>> img5 = vt.imread(ut.grab_test_imgpath('stars'))
2653
2655
  >>> img_list1 = [img1, img2, img3, img4, img5]
2654
2656
  >>> img_list2 = None
2655
2657
  >>> vert = True
@@ -2658,7 +2660,7 @@ def stack_image_recurse(img_list1, img_list2=None, vert=True, modifysize=False,
2658
2660
  >>> # verify results
2659
2661
  >>> # xdoctest: +REQUIRES(--show)
2660
2662
  >>> import plottool_ibeis as pt
2661
- >>> imshow(imgB)
2663
+ >>> pt.imshow(imgB)
2662
2664
  >>> #wh1 = img1.shape[0:2][::-1]
2663
2665
  >>> #wh2 = img2.shape[0:2][::-1]
2664
2666
  >>> #pt.draw_bbox((0, 0) + wh1, bbox_color=(1, 0, 0))
@@ -2732,8 +2734,8 @@ def filterflags_valid_images(gpaths, valid_formats=None,
2732
2734
  Example:
2733
2735
  >>> # ENABLE_DOCTEST
2734
2736
  >>> from vtool_ibeis.image import * # NOQA
2735
- >>> gpaths = [ut.grab_test_imgpath('carl.jpg'),
2736
- >>> ut.grab_test_imgpath('astro.png')]
2737
+ >>> gpaths = [ut.grab_test_imgpath('carl'),
2738
+ >>> ut.grab_test_imgpath('astro')]
2737
2739
  >>> flags = filterflags_valid_images(gpaths)
2738
2740
  >>> assert all(flags)
2739
2741
  """