Skip to content

Commit fdab9a3

Browse files
committed
hot fix
1 parent 17995bd commit fdab9a3

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

src/logic/__tests__/import/yolo/YOLOUtils.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,17 @@ describe('YOLOUtils validateYOLOAnnotationComponents method', () => {
113113
// then
114114
expect(result).toBe(true);
115115
});
116+
117+
it('should return true', () => {
118+
// given
119+
const components: string[] = ["6", "0.557911", "0.924187", "0.000673", "0.000000"]
120+
121+
// when
122+
const result = YOLOUtils.validateYOLOAnnotationComponents(components, 10);
123+
124+
// then
125+
expect(result).toBe(true);
126+
});
116127
});
117128

118129
describe('YOLOUtils parseYOLOAnnotationFromString method', () => {

src/logic/import/yolo/YOLOUtils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,14 @@ export class YOLOUtils {
7171

7272
public static validateYOLOAnnotationComponents(components: string[], labelNamesCount: number): boolean {
7373
const validateCoordinateValue = (rawValue: string): boolean => {
74-
const floatValue: number = parseFloat(rawValue);
75-
return !!floatValue && 0.0 <= floatValue && floatValue <= 1.0;
74+
const floatValue: number = Number(rawValue);
75+
return !isNaN(floatValue) && 0.0 <= floatValue && floatValue <= 1.0;
7676
}
7777
const validateLabelIdx = (rawValue: string): boolean => {
7878
const intValue: number = parseInt(rawValue);
7979
return !isNaN(intValue) && 0 <= intValue && intValue < labelNamesCount;
8080
}
81+
8182
return [
8283
components.length === 5,
8384
validateLabelIdx(components[0]),

src/views/PopupView/ImportLabelPopup/ImportLabelPopup.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,12 @@ const ImportLabelPopup: React.FC<IProps> = (
7070
};
7171

7272
const onAccept = (labelType: LabelType) => {
73-
updateImageData(loadedImageData);
74-
updateLabelNames(loadedLabelNames);
75-
updateActiveLabelType(labelType);
76-
PopupActions.close();
73+
if (loadedLabelNames.length !== 0 && loadedImageData.length !== 0) {
74+
updateImageData(loadedImageData);
75+
updateLabelNames(loadedLabelNames);
76+
updateActiveLabelType(labelType);
77+
PopupActions.close();
78+
}
7779
};
7880

7981
const onReject = (labelType: LabelType) => {

0 commit comments

Comments
 (0)