Skip to content

Commit 1d273b9

Browse files
Vaghinak BasentsyanVaghinak Basentsyan
authored andcommitted
Deleted unused code
1 parent 4564d51 commit 1d273b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+32
-4000
lines changed

.pre-commit-config.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ repos:
33
rev: 3.8.2
44
hooks:
55
- id: flake8
6-
exclude: src/lib/app/analytics | src/lib/app/converters | src/lib/app/input_convertors
6+
exclude: src/lib/app/analytics | src/lib/app/converters | src/lib/app/input_converters
77
name: Style Guide Enforcement (flake8)
88
args:
99
- '--max-line-length=120'
@@ -12,15 +12,15 @@ repos:
1212
rev: v2.4.3
1313
hooks:
1414
- id: pyupgrade
15-
exclude: src/lib/app/analytics | src/lib/app/converters | src/lib/app/input_convertors
15+
exclude: src/lib/app/analytics | src/lib/app/converters | src/lib/app/input_converters
1616
name: Upgrade syntax for newer versions of the language (pyupgrade)
1717
args:
1818
- '--py37-plus'
1919
- repo: 'https://github.com/asottile/reorder_python_imports'
2020
rev: v2.3.0
2121
hooks:
2222
- id: reorder-python-imports
23-
exclude: src/lib/app/analytics | src/lib/app/converters | src/lib/app/input_convertors
23+
exclude: src/lib/app/analytics | src/lib/app/converters | src/lib/app/input_converters
2424
name: 'Reorder Python imports (src, tests)'
2525
args:
2626
- '--application-directories'
@@ -36,9 +36,9 @@ repos:
3636
hooks:
3737
- id: black
3838
name: Uncompromising Code Formatter (black)
39-
# - repo: 'https://github.com/asottile/dead'
40-
# rev: v1.3.0
41-
# hooks:
42-
# - id: dead
39+
- repo: 'https://github.com/asottile/dead'
40+
rev: v1.3.0
41+
hooks:
42+
- id: dead
4343
files: src/
44-
exclude: src/lib/app/analytics | src/lib/app/converters | src/lib/app/input_convertors
44+
exclude: src/lib/app/analytics | src/lib/app/converters | src/lib/app/input_converters

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
minversion = 3.0
33
log_cli=true
44
python_files = test_*.py
5-
;addopts = -n 32 --dist=loadscope
5+
addopts = -n 32 --dist=loadscope

src/superannotate/__init__.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,21 @@
1313
from superannotate.lib.app.annotation_helpers import add_annotation_polyline_to_json
1414
from superannotate.lib.app.annotation_helpers import add_annotation_template_to_json
1515
from superannotate.lib.app.common import image_path_to_annotation_paths
16-
from superannotate.lib.app.convertors.df_converter import df_to_annotations
17-
from superannotate.lib.app.convertors.df_converter import filter_annotation_instances
18-
from superannotate.lib.app.convertors.df_converter import filter_images_by_comments
19-
from superannotate.lib.app.convertors.df_converter import filter_images_by_tags
20-
from superannotate.lib.app.convertors.dicom_converter import dicom_to_rgb_sequence
2116
from superannotate.lib.app.exceptions import AppException
2217
from superannotate.lib.app.input_converters.conversion import coco_split_dataset
2318
from superannotate.lib.app.input_converters.conversion import convert_json_version
2419
from superannotate.lib.app.input_converters.conversion import convert_project_type
2520
from superannotate.lib.app.input_converters.conversion import export_annotation
2621
from superannotate.lib.app.input_converters.conversion import import_annotation
22+
from superannotate.lib.app.input_converters.df_converter import df_to_annotations
23+
from superannotate.lib.app.input_converters.df_converter import (
24+
filter_annotation_instances,
25+
)
26+
from superannotate.lib.app.input_converters.df_converter import (
27+
filter_images_by_comments,
28+
)
29+
from superannotate.lib.app.input_converters.df_converter import filter_images_by_tags
30+
from superannotate.lib.app.input_converters.dicom_converter import dicom_to_rgb_sequence
2731
from superannotate.lib.app.interface.sdk_interface import add_annotation_bbox_to_image
2832
from superannotate.lib.app.interface.sdk_interface import (
2933
add_annotation_comment_to_image,
@@ -171,7 +175,7 @@
171175
# common
172176
"df_to_annotations",
173177
"image_path_to_annotation_paths",
174-
# convertors
178+
# converters
175179
"dicom_to_rgb_sequence",
176180
"coco_split_dataset",
177181
"convert_json_version",

src/superannotate/lib/app/analytics/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ def image_consensus(df, image_name, annot_type):
648648
return image_data
649649

650650

651-
def consensus_plot(consensus_df, projects):
651+
def consensus_plot(consensus_df, *_, **__):
652652
plot_data = consensus_df.copy()
653653

654654
# annotator-wise boxplot
Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +0,0 @@
1-
DEFAULT_IMAGE_EXTENSIONS = ("jpg", "jpeg", "png", "tif", "tiff", "webp", "bmp")
2-
3-
DEFAULT_FILE_EXCLUDE_PATTERNS = ("___save.png", "___fuse.png")
4-
5-
DEFAULT_VIDEO_EXTENSIONS = ("mp4", "avi", "mov", "webm", "flv", "mpg", "ogg")
6-
7-
SPECIAL_CHARACTERS_IN_PROJECT_FOLDER_NAMES = set('/\\:*?"<>|')
8-
9-
_PROJECT_TYPES = {"Vector": 1, "Pixel": 2}
10-
11-
_ANNOTATION_STATUSES = {
12-
"NotStarted": 1,
13-
"InProgress": 2,
14-
"QualityCheck": 3,
15-
"Returned": 4,
16-
"Completed": 5,
17-
"Skipped": 6,
18-
}
19-
20-
UPLOAD_STATES_STR_TO_CODES = {"Initial": 1, "Basic": 2, "External": 3}
21-
UPLOAD_STATES_CODES_TO_STR = {1: "Initial", 2: "Basic", 3: "External"}
22-
23-
USER_ROLES = {"Admin": 2, "Annotator": 3, "QA": 4, "Customer": 5, "Viewer": 6}
24-
AVAILABLE_SEGMENTATION_MODELS = ["autonomous", "generic"]
25-
MODEL_TRAINING_STATUSES = {
26-
"NotStarted": 1,
27-
"InProgress": 2,
28-
"Completed": 3,
29-
"FailedBeforeEvaluation": 4,
30-
"FailedAfterEvaluation": 5,
31-
"FailedAfterEvaluationWithSavedModel": 6,
32-
}
33-
34-
PREDICTION_SEGMENTATION_STATUSES = {
35-
"NotStarted": 1,
36-
"InProgress": 2,
37-
"Completed": 3,
38-
"Failed": 4,
39-
}
40-
41-
MODEL_TRAINING_TASKS = {
42-
"Instance Segmentation for Pixel Projects": "instance_segmentation_pixel",
43-
"Instance Segmentation for Vector Projects": "instance_segmentation_vector",
44-
"Keypoint Detection for Vector Projects": "keypoint_detection_vector",
45-
"Object Detection for Vector Projects": "object_detection_vector",
46-
"Semantic Segmentation for Pixel Projects": "semantic_segmentation_pixel",
47-
}

src/superannotate/lib/app/bin/superannotate.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66

77
logger = logging.getLogger()
88

9-
# TODO Add help text
10-
HELP_TEXT = ""
11-
129

1310
def main():
1411
fire.Fire(CLIFacade)

src/superannotate/lib/app/common.py

Lines changed: 0 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import functools
21
import json
32
import logging
43
import os
@@ -12,13 +11,6 @@
1211

1312
logger = logging.getLogger()
1413

15-
DEFAULT_IMAGE_EXTENSIONS = ("jpg", "jpeg", "png", "tif", "tiff", "webp", "bmp")
16-
DEFAULT_FILE_EXCLUDE_PATTERNS = ("___save.png", "___fuse.png")
17-
18-
DEFAULT_VIDEO_EXTENSIONS = ("mp4", "avi", "mov", "webm", "flv", "mpg", "ogg")
19-
20-
SPECIAL_CHARACTERS_IN_PROJECT_FOLDER_NAMES = set('/\\:*?"<>|')
21-
2214
_PROJECT_TYPES = {"Vector": 1, "Pixel": 2}
2315

2416
_ANNOTATION_STATUSES = {
@@ -30,57 +22,6 @@
3022
"Skipped": 6,
3123
}
3224

33-
_UPLOAD_STATES_STR_TO_CODES = {"Initial": 1, "Basic": 2, "External": 3}
34-
_UPLOAD_STATES_CODES_TO_STR = {1: "Initial", 2: "Basic", 3: "External"}
35-
36-
_USER_ROLES = {"Admin": 2, "Annotator": 3, "QA": 4, "Customer": 5, "Viewer": 6}
37-
_AVAILABLE_SEGMENTATION_MODELS = ["autonomous", "generic"]
38-
_MODEL_TRAINING_STATUSES = {
39-
"NotStarted": 1,
40-
"InProgress": 2,
41-
"Completed": 3,
42-
"FailedBeforeEvaluation": 4,
43-
"FailedAfterEvaluation": 5,
44-
"FailedAfterEvaluationWithSavedModel": 6,
45-
}
46-
47-
_PREDICTION_SEGMENTATION_STATUSES = {
48-
"NotStarted": 1,
49-
"InProgress": 2,
50-
"Completed": 3,
51-
"Failed": 4,
52-
}
53-
54-
_MODEL_TRAINING_TASKS = {
55-
"Instance Segmentation for Pixel Projects": "instance_segmentation_pixel",
56-
"Instance Segmentation for Vector Projects": "instance_segmentation_vector",
57-
"Keypoint Detection for Vector Projects": "keypoint_detection_vector",
58-
"Object Detection for Vector Projects": "object_detection_vector",
59-
"Semantic Segmentation for Pixel Projects": "semantic_segmentation_pixel",
60-
}
61-
62-
63-
def prediction_segmentation_status_from_str_to_int(status):
64-
return _PREDICTION_SEGMENTATION_STATUSES[status]
65-
66-
67-
def prediction_segmentation_status_from_int_to_str(status):
68-
for idx, item in _PREDICTION_SEGMENTATION_STATUSES.items():
69-
if item == status:
70-
return idx
71-
raise RuntimeError("NA segmentation/prediction status")
72-
73-
74-
def model_training_status_int_to_str(project_status):
75-
for item in _MODEL_TRAINING_STATUSES:
76-
if _MODEL_TRAINING_STATUSES[item] == project_status:
77-
return item
78-
raise RuntimeError("NA training status")
79-
80-
81-
def model_training_status_str_to_int(project_status):
82-
return _MODEL_TRAINING_STATUSES[project_status]
83-
8425

8526
def image_path_to_annotation_paths(image_path, project_type):
8627
image_path = Path(image_path)
@@ -94,98 +35,13 @@ def image_path_to_annotation_paths(image_path, project_type):
9435
)
9536

9637

97-
def project_type_str_to_int(project_type):
98-
return _PROJECT_TYPES[project_type]
99-
100-
101-
def project_type_int_to_str(project_type):
102-
"""Converts metadata project_type int value to a string
103-
104-
:param project_type: int in project metadata's 'type' key
105-
:type project_type: int
106-
107-
:return: 'Vector' or 'Pixel'
108-
:rtype: str
109-
"""
110-
for k, v in _PROJECT_TYPES.items():
111-
if v == project_type:
112-
return k
113-
raise RuntimeError("NA Project type")
114-
115-
116-
def user_role_str_to_int(user_role):
117-
return _USER_ROLES[user_role]
118-
119-
120-
def user_role_int_to_str(user_role):
121-
for k, v in _USER_ROLES.items():
122-
if v == user_role:
123-
return k
124-
return None
125-
126-
127-
def annotation_status_str_to_int(annotation_status):
128-
return _ANNOTATION_STATUSES[annotation_status]
129-
130-
131-
def upload_state_str_to_int(upload_state):
132-
return _UPLOAD_STATES_STR_TO_CODES[upload_state]
133-
134-
135-
def upload_state_int_to_str(upload_state):
136-
return _UPLOAD_STATES_CODES_TO_STR[upload_state]
137-
138-
139-
def annotation_status_int_to_str(annotation_status):
140-
"""Converts metadata annotation_status int value to a string
141-
142-
:param annotation_status: int in image metadata's 'annotation_status' key
143-
:type annotation_status: int
144-
145-
:return: One of 'NotStarted' 'InProgress' 'QualityCheck' 'Returned' 'Completed' 'Skipped'
146-
:rtype: str
147-
"""
148-
149-
for k, v in _ANNOTATION_STATUSES.items():
150-
if v == annotation_status:
151-
return k
152-
return None
153-
154-
155-
def deprecated_alias(**aliases):
156-
def deco(f):
157-
@functools.wraps(f)
158-
def wrapper(*args, **kwargs):
159-
rename_kwargs(f.__name__, kwargs, aliases)
160-
return f(*args, **kwargs)
161-
162-
return wrapper
163-
164-
return deco
165-
166-
167-
def rename_kwargs(func_name, kwargs, aliases):
168-
for alias, new in aliases.items():
169-
if alias in kwargs:
170-
if new in kwargs:
171-
raise TypeError(f"{func_name} received both {alias} and {new}")
172-
logger.warning("%s is deprecated; use %s in %s", alias, new, func_name)
173-
kwargs[new] = kwargs.pop(alias)
174-
175-
17638
def hex_to_rgb(hex_string):
17739
"""Converts HEX values to RGB values
17840
"""
17941
h = hex_string.lstrip("#")
18042
return tuple(int(h[i : i + 2], 16) for i in (0, 2, 4))
18143

18244

183-
def rgb_to_hex(rgb_tuple):
184-
"""Converts RGB values to HEX values
185-
"""
186-
return "#%02x%02x%02x" % rgb_tuple
187-
188-
18945
def blue_color_generator(n, hex_values=True):
19046
""" Blue colors generator for SuperAnnotate blue mask.
19147
"""
@@ -305,7 +161,6 @@ def write_to_json(output_path, json_data):
305161

306162

307163
MAX_IMAGE_SIZE = 100 * 1024 * 1024 # 100 MB limit
308-
MAX_IMAGE_RESOLUTION = {"Vector": 100_000_000, "Pixel": 4_000_000} # Resolution limit
309164

310165

311166
def tqdm_converter(total_num, images_converted, images_not_converted, finish_event):

src/superannotate/lib/app/convertors/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)