Skip to content

Commit

Permalink
fix: fix model instance task parsing issue (#77)
Browse files Browse the repository at this point in the history
Because

- #71 

This commit

- Fix model instance task parsing issue
- close #71
  • Loading branch information
EiffelFly committed Jun 30, 2022
1 parent 28d3927 commit bac5eb0
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import cn from "clsx";
import { Nullable } from "@/types/general";
import {
ImageClassificationIcon,
KeypointDetectionIcon,
ObjectDetectionIcon,
} from "@instill-ai/design-system";

Expand All @@ -26,22 +27,25 @@ const ModelInstanceTaskLabel: FC<ModelInstanceTaskLabelProps> = ({
};

let modelInstanceTaskIcon: ReactElement;
let modelInstanceTaskLabel: string;
const taskNameList = task?.split("_");
const taskName = taskNameList?.slice(1, taskNameList.length);
const modelInstanceTaskLabel = taskName?.join(" ") || "Task not found";

switch (task) {
case "TASK_CLASSIFICATION":
modelInstanceTaskIcon = <ImageClassificationIcon {...icon} />;
modelInstanceTaskLabel = "Classification";
break;

case "TASK_DETECTION":
modelInstanceTaskIcon = <ObjectDetectionIcon {...icon} />;
modelInstanceTaskLabel = "Detection";
break;

case "TASK_KEYPOINT":
modelInstanceTaskIcon = <KeypointDetectionIcon {...icon} />;
break;

default:
modelInstanceTaskIcon = <div className={cn(icon.width, icon.height)} />;
modelInstanceTaskLabel = "Task not found";
break;
}

Expand All @@ -54,7 +58,7 @@ const ModelInstanceTaskLabel: FC<ModelInstanceTaskLabelProps> = ({
)}
>
{modelInstanceTaskIcon}
<p className="my-auto flex text-instillGrey90 text-instill-small">
<p className="my-auto flex capitalize text-instillGrey90 text-instill-small">
{modelInstanceTaskLabel}
</p>
</div>
Expand Down

0 comments on commit bac5eb0

Please sign in to comment.