Skip to content

Commit

Permalink
Augmentation Pagination and General Error handling (#370)
Browse files Browse the repository at this point in the history
* Add aug pagination and error handling for deepssm_error

* Add white space to EOF

* Update error handling for deepSSMResult.value

* Update constant name

* Add `-P threads` to the prod celery startup script

---------

Co-authored-by: Anne Haley <anne.haley@kitware.com>
  • Loading branch information
JakeWags and annehaley authored Apr 15, 2024
1 parent 5660983 commit c7a9f97
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 20 deletions.
2 changes: 1 addition & 1 deletion dev/prod.celery.start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ cd ~/celery_project
for keyval in $(cat .env | sed -e 's/: /=/g' -e "s/'\|,\|{\|}//g" -e 's/", "/ /g' -e 's/"}//g' ); do export $keyval; done

conda activate shapeworks
celery -A shapeworks_cloud.celery worker -n "w1@${HOSTNAME}" -Q gpu --logfile=celery-logs
celery -A shapeworks_cloud.celery worker -n "w1@${HOSTNAME}" -Q gpu -P threads --logfile=celery-logs
6 changes: 4 additions & 2 deletions web/shapeworks/src/components/DeepSSM/DeepSSMTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ export default {
onMounted(async () => {
if (!deepSSMResult.value && selectedProject.value) {
deepSSMLoadingData.value = true;
await loadDeepSSMDataForProject();
deepSSMLoadingData.value = false;
}
if (deepSSMResult.value) {
if (deepSSMResult.value && deepSSMResult.value.result) {
try {
Promise.all([
await getCSVDataFromURL(deepSSMResult.value.result.aug_total_data),
Expand Down Expand Up @@ -311,7 +313,7 @@ export default {
<v-btn @click="submitDeepSSMJob">Run DeepSSM tasks</v-btn>
</v-expansion-panel-content>
</v-expansion-panel>
<v-expansion-panel v-if="deepSSMResult">
<v-expansion-panel v-if="deepSSMResult && deepSSMResult.result">
<v-expansion-panel-header>Data</v-expansion-panel-header>
<v-expansion-panel-content>
<v-tabs v-model="deepSSMDataTab">
Expand Down
34 changes: 34 additions & 0 deletions web/shapeworks/src/components/RenderControls.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import { setDatasetThumbnail, setProjectThumbnail } from '@/api/rest';
import { computed, ref, watch } from 'vue';
import _ from 'lodash';
import {
particleSize,
layers,
Expand Down Expand Up @@ -29,7 +30,9 @@ import {
imageViewLevelRange,
deepSSMResult,
deepSSMDataTab,
deepSSMSamplePage,
uniformScale,
DEEPSSM_SAMPLES_PER_PAGE,
} from '@/store';
Expand Down Expand Up @@ -181,6 +184,14 @@ export default {
return false;
})
const showSamplePageSelector = computed(() => {
return deepSSMDataTab.value === 0 && deepSSMSamplePage.value;
})
const maxSamplePage = computed(() => {
return Math.ceil(Object.values(deepSSMResult.value?.aug_pairs).length / DEEPSSM_SAMPLES_PER_PAGE);
})
const showUniformScaleOption = computed(() => {
return deepSSMDataTab.value >= 1; // deepssm data tab training or testing
})
Expand Down Expand Up @@ -232,6 +243,16 @@ export default {
}
})
function changeSamplePage(page: number) {
if (page < 1) {
page = 1
} else if (page > maxSamplePage.value) {
page = maxSamplePage.value
}
deepSSMSamplePage.value = page
}
return {
particleSize,
layersShown,
Expand Down Expand Up @@ -259,6 +280,10 @@ export default {
showAnalysisOptions,
showUniformScaleOption,
uniformScale,
deepSSMSamplePage,
onChangeSamplePage: _.debounce(changeSamplePage, 1000),
showSamplePageSelector,
maxSamplePage,
currentTab: props.currentTab,
}
}
Expand Down Expand Up @@ -313,6 +338,15 @@ export default {
v-model="showDifferenceFromMeanMode"
label="Show difference from mean"
/>
<v-text-field
v-if="showSamplePageSelector"
:value="deepSSMSamplePage"
label="Sample Page"
min="0"
step="1"
@input="onChangeSamplePage"
type="number"
/>
<v-switch
v-if="showUniformScaleOption"
v-model="uniformScale"
Expand Down
29 changes: 16 additions & 13 deletions web/shapeworks/src/components/ShapeViewer/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,20 +250,23 @@ export default {
}
if ([1, 2].includes(deepSSMDataTab.value)) {
const data = shapeData.getPointData().getArrayByName('deepssm_error').getData()
let normalizeRange;
if (uniformScale.value) {
normalizeRange = deepSSMErrorGlobalRange.value
} else {
normalizeRange = [Math.min(...data), Math.max(...data)]

if (data) {
let normalizeRange;
if (uniformScale.value) {
normalizeRange = deepSSMErrorGlobalRange.value
} else {
normalizeRange = [Math.min(...data), Math.max(...data)]
}
const normalizedData = data.map((v) => v / (normalizeRange[1] - normalizeRange[0]))
const normalizedArray = vtkDataArray.newInstance({
name: 'deepssm_error_normalized',
values: normalizedData,
})
shapeData.getPointData().addArray(normalizedArray)
mapper.setColorByArrayName('deepssm_error_normalized')
mapper.setLookupTable(this.lookupTable)
}
const normalizedData = data.map((v) => v / (normalizeRange[1] - normalizeRange[0]))
const normalizedArray = vtkDataArray.newInstance({
name: 'deepssm_error_normalized',
values: normalizedData,
})
shapeData.getPointData().addArray(normalizedArray)
mapper.setColorByArrayName('deepssm_error_normalized')
mapper.setLookupTable(this.lookupTable)
}
const actor = vtkActor.newInstance();
if (type) actor.getProperty().setColor(...type.rgb);
Expand Down
2 changes: 2 additions & 0 deletions web/shapeworks/src/store/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,5 @@ export const COLORS = [
[255, 255, 153],
[177, 89, 40],
];

export const DEEPSSM_SAMPLES_PER_PAGE = 12;
2 changes: 2 additions & 0 deletions web/shapeworks/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,5 @@ export const optimizationFormData = ref({});
export const uniformScale = ref<boolean>(true);

export const deepSSMErrorGlobalRange = ref<number[]>([0, 1]);

export const deepSSMSamplePage = ref<number>(1);
2 changes: 0 additions & 2 deletions web/shapeworks/src/store/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ export const loadReconstructedSamplesForProject = async (type: string, id: numbe

export const loadDeepSSMDataForProject = async () => {
if (selectedProject.value) {
deepSSMLoadingData.value = true;
const results = await Promise.all([
await getDeepSSMResultForProject(
selectedProject.value.id
Expand All @@ -189,7 +188,6 @@ export const loadDeepSSMDataForProject = async () => {
images: results[3],
test_pairs: results[4]
}
deepSSMLoadingData.value = false;
}
}

Expand Down
8 changes: 6 additions & 2 deletions web/shapeworks/src/views/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ import {
deepSSMResult,
deepSSMAugDataShown,
allDataObjectsInDataset,
uniformScale,
uniformScale,
deepSSMSamplePage,
DEEPSSM_SAMPLES_PER_PAGE,
} from '@/store';
import router from '@/router';
import TabForm from '@/components/TabForm.vue';
Expand Down Expand Up @@ -252,7 +254,8 @@ export default {
// populate labelledGroups from aug_pairs
// if generated data is shown. Else pass groupedSelections
if (deepSSMAugDataShown.value === 'Generated') {
labelledGroups = groupBy(deepSSMResult.value.aug_pairs, 'sample_num')
const paginatedAugPairs = augImages.slice(DEEPSSM_SAMPLES_PER_PAGE * (deepSSMSamplePage.value - 1), DEEPSSM_SAMPLES_PER_PAGE * deepSSMSamplePage.value)
labelledGroups = groupBy(paginatedAugPairs, 'sample_num')
}
else {
labelledGroups = groupedSelections;
Expand Down Expand Up @@ -536,6 +539,7 @@ export default {
watch(deepSSMDataTab, debouncedRefreshRender)
watch(deepSSMAugDataShown, debouncedRefreshRender)
watch(uniformScale, debouncedRefreshRender)
watch(deepSSMSamplePage, debouncedRefreshRender)
watch(tab, switchTab)
return {
Expand Down

0 comments on commit c7a9f97

Please sign in to comment.