Skip to content

Commit

Permalink
Batch of fixes (#1403)
Browse files Browse the repository at this point in the history
* Fixed bug when job cannot be opened

* Fixed bug when deactivated shape is still highlighted

* Fixed Error: 'AttributeError: 'tuple' object has no attribute 'read'

* Fixed: wrong semi-automatic segmentation near edges of an image

* Updated changelog

Co-authored-by: Nikita Manovich <[email protected]>
  • Loading branch information
bsekachev and nmanovic authored Apr 14, 2020
1 parent e71e460 commit 5e21b4a
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- VOC format exports Upper case labels correctly in lower case (https://github.com/opencv/cvat/pull/1379)
- Fixed polygon exporting bug in COCO dataset (https://github.com/opencv/cvat/issues/1387)
- Task creation from remote files (https://github.com/opencv/cvat/pull/1392)
- Job cannot be opened in some cases when the previous job was failed during opening (https://github.com/opencv/cvat/issues/1403)
- Deactivated shape is still highlighted on the canvas (https://github.com/opencv/cvat/issues/1403)
- AttributeError: 'tuple' object has no attribute 'read' in ReID algorithm (https://github.com/opencv/cvat/issues/1403)
- Wrong semi-automatic segmentation near edges of an image (https://github.com/opencv/cvat/issues/1403)
- Git repos paths (https://github.com/opencv/cvat/pull/1400)

### Security
Expand Down
4 changes: 3 additions & 1 deletion cvat-ui/src/actions/annotation-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,9 @@ export function getJobAsync(

dispatch({
type: AnnotationActionTypes.GET_JOB,
payload: {},
payload: {
requestedId: jid,
},
});

const loadJobEvent = await logger.log(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@ export default class CanvasWrapperComponent extends React.PureComponent<Props> {
if (prevProps.activatedStateID !== null
&& prevProps.activatedStateID !== activatedStateID) {
canvasInstance.activate(null);
}

if (activatedStateID) {
const el = window.document.getElementById(`cvat_canvas_shape_${prevProps.activatedStateID}`);
if (el) {
(el as any).instance.fill({ opacity: opacity / 100 });
Expand Down
3 changes: 2 additions & 1 deletion cvat-ui/src/containers/annotation-page/annotation-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function mapStateToProps(state: CombinedState, own: OwnProps): StateToProps {
const {
annotation: {
job: {
requestedId,
instance: job,
fetching,
},
Expand All @@ -41,7 +42,7 @@ function mapStateToProps(state: CombinedState, own: OwnProps): StateToProps {
} = state;

return {
job: !job || jobID === job.id ? job : null,
job: jobID === requestedId ? job : null,
fetching,
workspace,
};
Expand Down
3 changes: 3 additions & 0 deletions cvat-ui/src/reducers/annotation-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const defaultState: AnnotationState = {
},
job: {
labels: [],
requestedId: null,
instance: null,
attributes: {},
fetching: false,
Expand Down Expand Up @@ -105,6 +106,8 @@ export default (state = defaultState, action: AnyAction): AnnotationState => {
...state,
job: {
...state.job,
instance: null,
requestedId: action.payload.requestedId,
fetching: true,
},
};
Expand Down
1 change: 1 addition & 0 deletions cvat-ui/src/reducers/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ export interface AnnotationState {
};
job: {
labels: any[];
requestedId: number | null;
instance: any | null | undefined;
attributes: Record<number, any[]>;
fetching: boolean;
Expand Down
18 changes: 13 additions & 5 deletions cvat/apps/dextr_segmentation/dextr.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,19 @@ def handle(self, db_data, frame, points):
image = PIL.Image.open(image[0])
numpy_image = np.array(image)
points = np.asarray([[int(p["x"]), int(p["y"])] for p in points], dtype=int)

# Padding mustn't be more than the closest distance to an edge of an image
[width, height] = numpy_image.shape[:2]
x_values = points[:, 0]
y_values = points[:, 1]
[min_x, max_x] = [np.min(x_values), np.max(x_values)]
[min_y, max_y] = [np.min(y_values), np.max(y_values)]
padding = min(min_x, min_y, width - max_x, height - max_y, _DEXTR_PADDING)
bounding_box = (
max(min(points[:, 0]) - _DEXTR_PADDING, 0),
max(min(points[:, 1]) - _DEXTR_PADDING, 0),
min(max(points[:, 0]) + _DEXTR_PADDING, numpy_image.shape[1] - 1),
min(max(points[:, 1]) + _DEXTR_PADDING, numpy_image.shape[0] - 1)
max(min(points[:, 0]) - padding, 0),
max(min(points[:, 1]) - padding, 0),
min(max(points[:, 0]) + padding, numpy_image.shape[1] - 1),
min(max(points[:, 1]) + padding, numpy_image.shape[0] - 1)
)

# Prepare an image
Expand All @@ -61,7 +69,7 @@ def handle(self, db_data, frame, points):
interpolation = cv2.INTER_CUBIC).astype(np.float32)

# Make a heatmap
points = points - [min(points[:, 0]), min(points[:, 1])] + [_DEXTR_PADDING, _DEXTR_PADDING]
points = points - [min(points[:, 0]), min(points[:, 1])] + [padding, padding]
points = (points * [_DEXTR_SIZE / numpy_cropped.shape[1], _DEXTR_SIZE / numpy_cropped.shape[0]]).astype(int)
heatmap = np.zeros(shape=resized.shape[:2], dtype=np.float64)
for point in points:
Expand Down
4 changes: 2 additions & 2 deletions cvat/apps/reid/reid.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def __apply_matching(self):
job = rq.get_current_job()
box_tracks = {}

next_image = cv2.imdecode(numpy.fromstring(next(self.__frame_iter).read(), numpy.uint8), cv2.IMREAD_COLOR)
next_image = cv2.imdecode(numpy.fromstring((next(self.__frame_iter)[0]).read(), numpy.uint8), cv2.IMREAD_COLOR)
for idx, (cur_frame, next_frame) in enumerate(list(zip(frames[:-1], frames[1:]))):
job.refresh()
if "cancel" in job.meta:
Expand All @@ -172,7 +172,7 @@ def __apply_matching(self):
continue

cur_image = next_image
next_image = cv2.imdecode(numpy.fromstring(next(self.__frame_iter).read(), numpy.uint8), cv2.IMREAD_COLOR)
next_image = cv2.imdecode(numpy.fromstring((next(self.__frame_iter)[0]).read(), numpy.uint8), cv2.IMREAD_COLOR)
difference_matrix = self.__compute_difference_matrix(cur_boxes, next_boxes, cur_image, next_image)
cur_idxs, next_idxs = linear_sum_assignment(difference_matrix)
for idx, cur_idx in enumerate(cur_idxs):
Expand Down

0 comments on commit 5e21b4a

Please sign in to comment.