Skip to content
Snippets Groups Projects
Commit d5373154 authored by Manon Blanco's avatar Manon Blanco
Browse files

Replace utils pairwise function by itertools pariwise

parent 14a54602
No related branches found
No related tags found
1 merge request!159Replace utils pairwise function by itertools pariwise
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import os import os
import pickle import pickle
from itertools import pairwise
from pathlib import Path from pathlib import Path
import cv2 import cv2
...@@ -20,7 +21,7 @@ from dan.predict.attention import ( ...@@ -20,7 +21,7 @@ from dan.predict.attention import (
plot_attention, plot_attention,
split_text_and_confidences, split_text_and_confidences,
) )
from dan.utils import pairwise, read_image from dan.utils import read_image
class DAN: class DAN:
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from itertools import tee
import cv2 import cv2
import numpy as np import numpy as np
import torch import torch
...@@ -154,13 +152,3 @@ def round_floats(float_list, decimals=2): ...@@ -154,13 +152,3 @@ def round_floats(float_list, decimals=2):
Round list of floats with fixed decimals Round list of floats with fixed decimals
""" """
return [np.around(num, decimals) for num in float_list] return [np.around(num, decimals) for num in float_list]
def pairwise(iterable):
"""
Not necessary when using 3.10. See https://docs.python.org/3/library/itertools.html#itertools.pairwise.
"""
# pairwise('ABCDEFG') --> AB BC CD DE EF FG
a, b = tee(iterable)
next(b, None)
return zip(a, b)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment