Skip to content

Commit

Permalink
Remove opencv as dep (#31)
Browse files Browse the repository at this point in the history
* remove opencv ad dep

* fix test

* fix test
  • Loading branch information
n3011 authored Mar 5, 2025
1 parent 1712e66 commit 120f009
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions datum/utils/common_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ def check_and_image_shape(item: ValueType, shape: list) -> list:
if len(item.shape) > 0:
item = str(item[0])
if item.endswith(('.jpg', '.jpeg', '.png')):
import cv2
im = cv2.imread(item)
from PIL import Image
im = Image.open(item)
if im is not None:
return list(im.shape)
return list(np.asarray(im).shape)
return shape


Expand Down
2 changes: 1 addition & 1 deletion datum/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = '1.12.1'
__version__ = '1.12.2'
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# core lib dep
tensorflow <2.19
opencv-python==4.5.*
pillow >=9.2.0
absl-py>=0.10
tqdm>=4.39.0
wrapt>=1.14.1
Expand Down
2 changes: 1 addition & 1 deletion tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_train_fn(self):
ds = self._dataset.train_fn('train', False)
batch = next(iter(ds))
self.assertEqual(batch['image'].shape, [1, 281, 500, 3])
self.assertEqual(batch['label'].shape, [1, 281, 500, 3])
self.assertEqual(batch['label'].shape, [1, 281, 500, 1])


class TestTextJsonDataset(absltest.TestCase):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ def test_parser(self):
batch = next(iter(dataset))
self.assertEqual(list(batch.keys()), ['image', 'label'])
self.assertEqual(batch['image'].shape, [1, 366, 500, 3])
self.assertEqual(batch['label'].shape, [1, 366, 500, 3])
self.assertEqual(batch['label'].shape, [1, 366, 500, 1])

0 comments on commit 120f009

Please sign in to comment.