From bb355a36c6424450581bedb4c4f4297b7ba8abe7 Mon Sep 17 00:00:00 2001 From: Paul Crossley Date: Thu, 5 Dec 2024 15:37:41 +0000 Subject: [PATCH] Error handling and name change --- app/javascript/projects/modelling/components/index.ts | 4 ++-- .../projects/modelling/components/segment_component.ts | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/javascript/projects/modelling/components/index.ts b/app/javascript/projects/modelling/components/index.ts index 8d9dee3..8d0821d 100644 --- a/app/javascript/projects/modelling/components/index.ts +++ b/app/javascript/projects/modelling/components/index.ts @@ -67,8 +67,9 @@ export function createDefaultComponents(saveMapLayer: SaveMapLayer, saveModel: S new NumericConstantComponent(), new UkcehLandCoverComponent(projectProps), new LehLandCoverComponent(projectProps), + new SegmentComponent(projectProps), new IMDComponent(projectProps), - new MlTreeHedgeComponent(projectProps), + //new MlTreeHedgeComponent(projectProps), deprecated new BiodiversityComponent(projectProps), new NevoLayerComponent(projectProps), new ORValComponent(projectProps), @@ -81,7 +82,6 @@ export function createDefaultComponents(saveMapLayer: SaveMapLayer, saveModel: S new ATIComponent(projectProps), new DesignationsComponent(projectProps), new SoilComponent(projectProps), - new SegmentComponent(projectProps), // Outputs new MapLayerComponent(saveMapLayer), diff --git a/app/javascript/projects/modelling/components/segment_component.ts b/app/javascript/projects/modelling/components/segment_component.ts index c9417a5..e10c666 100644 --- a/app/javascript/projects/modelling/components/segment_component.ts +++ b/app/javascript/projects/modelling/components/segment_component.ts @@ -29,7 +29,9 @@ async function retrieveSegmentationMasks(prompts: string, det_conf: string, clf_ )) if(segs.status !== 200){ - err(segs.statusText) + const segsJson = await segs.json() + const errMsg = segsJson.detail || segsJson.statusText || "Unknown error" + err(`${errMsg}. If issue persists, please raise an issue on the github repo or contact the developer directly (p.j.crossley@sussex.ac.uk).`) return [] } @@ -107,7 +109,7 @@ export class SegmentComponent extends BaseComponent { projectProps: ProjectProperties constructor(projectProps: ProjectProperties) { - super("Segmentation Model") + super("AI Model") this.category = "Inputs" this.projectProps = projectProps this.cache = new Map() @@ -120,7 +122,7 @@ export class SegmentComponent extends BaseComponent { +"and a confidence value. The prompt is the object you want to segment, detector confidence is the confidence " +"threshold for the detector (it is recommended that this is set low for high recall), classifier confidence is " +"the confidence threshold for the classifier (it is recommendeded that this is set higher for increased accuracy." - +" please note: setting this to 0 will disable this function), and the number of repeats is the number of times you want to repeat the segmentation process." + +" please note: setting this to 0 will disable this function), and the number of repeats is the number of times you want to repeat the segmentation process. (must be a value higher than 0)." if (!('det_conf' in node.data)) { node.data.det_conf = "5"