diff --git a/labelme/__init__.py b/labelme/__init__.py index a544e969a..0f3b158d7 100644 --- a/labelme/__init__.py +++ b/labelme/__init__.py @@ -1,7 +1,6 @@ # flake8: noqa import logging -import sys from qtpy import QT_VERSION @@ -19,10 +18,6 @@ QT5 = QT_VERSION[0] == "5" del QT_VERSION -PY2 = sys.version[0] == "2" -PY3 = sys.version[0] == "3" -del sys - from labelme.label_file import LabelFile from labelme import testing from labelme import utils diff --git a/labelme/app.py b/labelme/app.py index 7bbce4936..9238bbcf2 100644 --- a/labelme/app.py +++ b/labelme/app.py @@ -16,7 +16,6 @@ from qtpy import QtWidgets from qtpy.QtCore import Qt -from labelme import PY2 from labelme import __appname__ from labelme import ai from labelme.ai import MODELS @@ -1429,7 +1428,7 @@ def format_shape(s): data = s.other_data.copy() data.update( dict( - label=s.label.encode("utf-8") if PY2 else s.label, + label=s.label, points=[(p.x(), p.y()) for p in s.points], group_id=s.group_id, description=s.description, diff --git a/labelme/cli/draw_json.py b/labelme/cli/draw_json.py index 0ad3389f4..9bedf8c22 100644 --- a/labelme/cli/draw_json.py +++ b/labelme/cli/draw_json.py @@ -1,7 +1,6 @@ #!/usr/bin/env python import argparse -import sys import imgviz import matplotlib.pyplot as plt @@ -9,8 +8,6 @@ from labelme import utils from labelme.label_file import LabelFile -PY2 = sys.version_info[0] == 2 - def main(): parser = argparse.ArgumentParser() diff --git a/labelme/label_file.py b/labelme/label_file.py index 3c1f31530..36b0aa938 100644 --- a/labelme/label_file.py +++ b/labelme/label_file.py @@ -6,8 +6,6 @@ import PIL.Image -from labelme import PY2 -from labelme import QT4 from labelme import __version__ from labelme import utils from labelme.logger import logger @@ -18,12 +16,7 @@ @contextlib.contextmanager def open(name, mode): assert mode in ["r", "w"] - if PY2: - mode += "b" - encoding = None - else: - encoding = "utf-8" - yield io.open(name, mode, encoding=encoding) + yield io.open(name, mode, encoding="utf-8") return @@ -55,9 +48,7 @@ def load_image_file(filename): with io.BytesIO() as f: ext = osp.splitext(filename)[1].lower() - if PY2 and QT4: - format = "PNG" - elif ext in [".jpg", ".jpeg"]: + if ext in [".jpg", ".jpeg"]: format = "JPEG" else: format = "PNG" @@ -90,8 +81,6 @@ def load(self, filename): if data["imageData"] is not None: imageData = base64.b64decode(data["imageData"]) - if PY2 and QT4: - imageData = utils.img_data_to_png_data(imageData) else: # relative path from label file to relative path from cwd imagePath = osp.join(osp.dirname(filename), data["imagePath"])