Skip to content

Labels.txt Upload#1072

Merged
marySalvi merged 19 commits into
mainfrom
labelsUpload
Dec 20, 2021
Merged

Labels.txt Upload#1072
marySalvi merged 19 commits into
mainfrom
labelsUpload

Conversation

@marySalvi
Copy link
Copy Markdown
Collaborator

Fixes #599
Currently on web platform only:
Adds ability for user to upload a labels.txt file via the training menu
If the file is present, writes to the temp directory and sends the file to viame with the run_training task

Copy link
Copy Markdown
Contributor

@subdavis subdavis left a comment

Choose a reason for hiding this comment

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

This looks good. Two main comments:

  • When you add new optional parameters to a method, I think it's best to add them at the end rather than in the middle. It breaks the previous API unnecessarily, and if you add them at the end, you don't risk creating a bug somewhere that you forgot to update the function call.
  • I think the text argument needs to be added into the request body (comment below)

Comment thread client/dive-common/apispec.ts Outdated
import { CustomStyle } from 'vue-media-annotator/use/useStyling';

type DatasetType = 'image-sequence' | 'video' | 'multi';
type DatasetType = 'image-sequence' | 'video' | 'multi' | 'txt';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

'txt' shouldn't be a dataset type. This is like an image sequence, a video, or a multi-camera dataset.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

should be set now

Comment thread client/dive-common/apispec.ts Outdated
folderIds: string[], pipelineName: string, config: string, annotatedFramesOnly: boolean
folderIds: string[],
pipelineName: string,
labelText: string | null,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Optional params should probably move to the end of the method and become labelText?: string

If you make it a new optional param at the end, the API spec will be backward compatible.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

should be set now

Comment thread client/dive-common/constants.ts Outdated
[ImageSequenceType]: 'image sequence',
[VideoType]: 'video',
[MultiType]: 'multi',
[TxtType]: 'txt',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think you want to modify MediaTypes at all for this feature. No new dataset types are being added.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

should be set now

Comment thread client/dive-common/constants.ts Outdated
const ImageSequenceType = 'image-sequence';
const VideoType = 'video';
const MultiType = 'multi';
const TxtType = 'txt';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Probably remove?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

should be set now

Comment thread server/dive_tasks/tasks.py Outdated
source_folder_list: List[GirderModel],
groundtruth_list: List[GirderModel],
pipeline_name: str,
label_text:str,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this should be an optional param and move to the end:

label_text: Optional[str] = None

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

should be set now

if (dataset.value === null) return null;
const { type } = dataset.value;
if (type === MultiType) throw new Error('Cannot export multicamera dataset');
if (type === TxtType) throw new Error('Cannot export txt dataset');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this can be removed.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

should be set now

Comment thread server/dive_server/crud_rpc.py Outdated
newjob.job[constants.JOBCONST_PRIVATE_QUEUE] = job_is_private
newjob.job[constants.JOBCONST_TRAINING_INPUT_IDS] = folderIds
newjob.job[constants.JOBCONST_RESULTS_FOLDER_ID] = str(results_folder['_id'])
newjob.job[constants.JOBCONST_LABEL_TEXT] = labelText
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just FYI, these meta values aren't really used for anything. They're here because we thought it would be better to have this information than not. No need to change, though.

Comment on lines +187 to +200
<v-file-input
v-if="labelText"
v-model="labelFile"
clearable
/>
<import-button
name="Upload labels.txt File"
icon="mdi-folder-open"
open-type="txt"
class="grow"
@open="openTxt"
/>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two notes:

  • Is the import button necessary, or could we just use the v-file-input here? In other places in the app where file inputs are expected (Such as annotation file during import) only the v-file-input is used.
  • I don't think it's clear to the user what this is or that it's optional. Perhaps we need a short description and a link to documentation. I don't think matt has written any documentation about this file, so we should probably add it somewhere in our docs.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I have changed the UI to use v-file-input instead of the import button. This also removes the need to use the OpenFromDisk method.
I added the optional verbiage but I still don't feel I understand the contents of labels.txt file enough to provide meaningful documentation on it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

should be set now

trainingOutputName.value = null;
}

const openTxt = async () => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please use async function function definition for consistency with line 60.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

should be set now

};
reader.readAsText(data.fileList[0]);
// eslint-disable-next-line prefer-destructuring
labelFile.value = data.fileList[0];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
labelFile.value = data.fileList[0];
[labelFile.value] = data.fileList;

This will resolve the eslint warning so you can remove the disable comment.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

should be set now

Copy link
Copy Markdown
Collaborator

@BryonLewis BryonLewis left a comment

Choose a reason for hiding this comment

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

I generally agree that the datatype for datasets shouldn't be modified and that file-input should work fully.

This is just a note I believe about labels.txt from testing. The labels used have to be present in all training datasets I think? I was getting an error if they weren't. This is probably a question for Matt.

Comment thread client/platform/web-girder/views/RunTrainingMenu.vue Outdated
Comment thread client/platform/web-girder/views/RunTrainingMenu.vue
Comment thread server/dive_server/views_rpc.py Outdated
@marySalvi
Copy link
Copy Markdown
Collaborator Author

For the record I was calling the fact that I missed that linting issue silly, not that the rule existed. I don't have strong opinions about the rule but love the idea of black fixing it for us.

Copy link
Copy Markdown
Collaborator

@BryonLewis BryonLewis left a comment

Choose a reason for hiding this comment

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

Just asking about removing the 'txt' from openFromDisk if it is no longer being used.

Other than that it seems to load and run fine. I was able to get two pipelines trained which presented different results based on having a labels.txt to restrict the training vs letting it train with no labels.txt.

Comment thread client/dive-common/apispec.ts Outdated
saveAttributes(datasetId: string, args: SaveAttributeArgs): Promise<unknown>;
// Non-Endpoint shared functions
openFromDisk(datasetType: DatasetType | 'calibration' | 'annotation' | 'text', directory?: boolean):
openFromDisk(datasetType: DatasetType | 'calibration' | 'annotation' | 'txt' | 'text', directory?: boolean):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this necessary now that we are no longer using openFromDisk?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

should be set now

Comment thread client/platform/web-girder/utils.ts Outdated
Comment on lines +54 to +55
} else if (datasetType === 'txt') {
input.accept = inputTxtTypes;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Now that txt is no longer being used is this necessary to keep in this PR?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You are absolutely right, that can be removed now

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

should be set now

@marySalvi marySalvi requested a review from BryonLewis December 14, 2021 18:01
BryonLewis
BryonLewis previously approved these changes Dec 16, 2021
Copy link
Copy Markdown
Collaborator

@BryonLewis BryonLewis left a comment

Choose a reason for hiding this comment

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

Took another look at stuff, only changes from last review should be that removal. As a precaution I pulled/built and ran integration testing as well as looked at some basic training results. Looks good to me.

@subdavis
Copy link
Copy Markdown
Contributor

I'd like to combine #1092 into this, and then this is good to go!

* WIP

* Update Pipeline-Documentation.md
Copy link
Copy Markdown
Contributor

@subdavis subdavis left a comment

Choose a reason for hiding this comment

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

:shipit:

@marySalvi marySalvi merged commit f63ad12 into main Dec 20, 2021
@marySalvi marySalvi deleted the labelsUpload branch December 20, 2021 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] More granular training configuration (selective labels)

4 participants