Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

158 Negative Feedback #159

Merged
merged 5 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "nachet-frontend",
"private": true,
"version": "0.8.3",
"version": "0.8.4",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
8 changes: 4 additions & 4 deletions src/_versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export interface TsAppVersion {
gitTag?: string;
};
export const versions: TsAppVersion = {
version: '0.8.3',
version: '0.8.4',
name: 'nachet-frontend',
versionDate: '2024-05-28T01:42:26.974Z',
gitCommitHash: '71f4e7d',
versionLong: '0.8.3-71f4e7d',
versionDate: '2024-05-30T04:19:03.983Z',
gitCommitHash: 'd019904',
versionLong: '0.8.4-d019904',
};
export default versions;
1 change: 1 addition & 0 deletions src/common/cacheutils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ export const loadResultsToCache = (
...box.box,
inferenceId: inferenceData.inferenceId,
boxId: box.boxId,
classId: box.classId,
label: box.label,
};
}),
Expand Down
30 changes: 24 additions & 6 deletions src/common/imageutils.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { BoxCSS, BoxCoordinates } from "./types";

export const getScaledBounds = (
containerWidth: number,
containerHeight: number,
itemWidth: number,
itemHeight: number,
box: {
topX: number;
topY: number;
bottomX: number;
bottomY: number;
},
box: BoxCoordinates,
): {
scaledWidth: number;
scaledHeight: number;
Expand All @@ -28,3 +25,24 @@ export const getScaledBounds = (
scaledTopY,
};
};

export const getUnscaledCoordinates = (
containerWidth: number,
containerHeight: number,
itemWidth: number,
itemHeight: number,
box: BoxCSS,
): BoxCoordinates => {
const scaleFactorWidth = itemWidth / containerWidth;
const scaleFactorHeight = itemHeight / containerHeight;
const topX = box.left * scaleFactorWidth;
const topY = box.top * scaleFactorHeight;
const bottomX = box.left + box.minWidth * scaleFactorWidth;
const bottomY = box.top + box.minHeight * scaleFactorHeight;
return {
topX,
topY,
bottomX,
bottomY,
};
};
17 changes: 17 additions & 0 deletions src/common/tests/loadresultstocache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ describe("loadResultsToCache", () => {

let inferenceData: ApiInferenceData = {
filename: "test",
imageId: "test",
inferenceId: "test",
boxes: [
{
score: 0.1,
classId: "0",
label: "a",
boxId: "0",
box: {
Expand All @@ -38,6 +40,7 @@ describe("loadResultsToCache", () => {
},
{
score: 0.2,
classId: "1",
label: "b",
boxId: "1",
box: {
Expand All @@ -52,6 +55,7 @@ describe("loadResultsToCache", () => {
},
{
score: 0.3,
classId: "2",
label: "c",
boxId: "2",
box: {
Expand Down Expand Up @@ -87,10 +91,12 @@ describe("loadResultsToCache", () => {

inferenceData = {
filename: "test",
imageId: "test",
inferenceId: "test",
boxes: [
{
score: 0.1,
classId: "0",
label: "a",
boxId: "0",
box: {
Expand All @@ -105,6 +111,7 @@ describe("loadResultsToCache", () => {
},
{
score: 0.2,
classId: "1",
label: "b",
boxId: "1",
box: {
Expand All @@ -119,6 +126,7 @@ describe("loadResultsToCache", () => {
},
{
score: 0.3,
classId: "2",
label: "c",
boxId: "2",
box: {
Expand Down Expand Up @@ -164,6 +172,7 @@ describe("loadResultsToCache", () => {
{
boxId: "0",
inferenceId: "test",
classId: "0",
label: "a",
topX: 1,
topY: 1,
Expand All @@ -173,6 +182,7 @@ describe("loadResultsToCache", () => {
{
boxId: "1",
inferenceId: "test",
classId: "1",
label: "b",
topX: 2,
topY: 2,
Expand All @@ -182,6 +192,7 @@ describe("loadResultsToCache", () => {
{
boxId: "2",
inferenceId: "test",
classId: "2",
label: "c",
topX: 3,
topY: 3,
Expand Down Expand Up @@ -238,6 +249,7 @@ describe("loadResultsToCache", () => {
{
boxId: "0",
inferenceId: "test",
classId: "0",
label: "a",
topX: 1,
topY: 1,
Expand All @@ -247,6 +259,7 @@ describe("loadResultsToCache", () => {
{
boxId: "1",
inferenceId: "test",
classId: "1",
label: "b",
topX: 2,
topY: 2,
Expand All @@ -256,6 +269,7 @@ describe("loadResultsToCache", () => {
{
boxId: "2",
inferenceId: "test",
classId: "2",
label: "c",
topX: 3,
topY: 3,
Expand All @@ -278,6 +292,7 @@ describe("loadResultsToCache", () => {
{
boxId: "0",
inferenceId: "test",
classId: "0",
label: "a",
topX: 1,
topY: 1,
Expand All @@ -287,6 +302,7 @@ describe("loadResultsToCache", () => {
{
boxId: "1",
inferenceId: "test",
classId: "1",
label: "b",
topX: 2,
topY: 2,
Expand All @@ -296,6 +312,7 @@ describe("loadResultsToCache", () => {
{
boxId: "2",
inferenceId: "test",
classId: "2",
label: "c",
topX: 3,
topY: 3,
Expand Down
59 changes: 37 additions & 22 deletions src/common/types.d.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont get what the classId is? What is it representing?

Copy link
Contributor Author

@ChromaticPanic ChromaticPanic Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just gave it a generic name. it would be the species id/uuid . In image classification, the label is the class. For Nachet the classes are species names, but this interface can technically be used for any image classification project.

Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
export interface ApiInferenceData {
filename: string;
imageId: string;
inferenceId: string;
boxes: Array<{
topN: Array<{ score: number; label: string }>;
score: number;
label: string;
classId: string;
boxId: string;
box: {
topX: number;
topY: number;
bottomX: number;
bottomY: number;
};
box: BoxCoordinates;
overlapping: boolean;
overlappingIndices: number;
}>;
Expand All @@ -26,22 +23,37 @@ export interface Images {
src: string;
scores: number[];
classifications: string[];
boxes: Array<{
inferenceId: string;
boxId: string;
label: string;
topX: number;
topY: number;
bottomX: number;
bottomY: number;
}>;
boxes: InferenceBox[];
annotated: boolean;
imageDims: number[];
overlapping: boolean[];
overlappingIndices: number[];
topN: Array<Array<{ score: number; label: string }>>;
}

export interface BoxCoordinates {
topX: number;
topY: number;
bottomX: number;
bottomY: number;
}

export interface InferenceBox extends BoxCoordinates {
inferenceId: string;
boxId: string;
classId: string;
label: string;
}

export interface BoxCSS {
minWidth: number;
minHeight: number;
maxWidth: number;
maxHeight: number;
left: number;
top: number;
}

interface FeedbackData {
userId: string;
inferenceId: string;
Expand All @@ -56,13 +68,10 @@ export interface FeedbackDataPositive extends FeedbackData {
export interface FeedbackDataNegative extends FeedbackData {
boxes: Array<{
label: string;
classId: string;
boxId: string;
box: {
topX: number;
topY: number;
bottomX: number;
bottomY: number;
};
box: BoxCoordinates;
comment: string;
}>;
}

Expand All @@ -71,8 +80,14 @@ export interface LabelOccurrences {
}

// TODO: Redefine when the backend is updated
interface SpeciesData {
interface ClassData {
id: number;
classId: string;
label: string;
}

interface ApiSpeciesData {
classId: string;
label: string;
}

Expand Down
Loading
Loading