Skip to content

Update 08-Train-AI-Services.ipynb #32

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,19 @@
},
"outputs": [],
"source": [
"async Task<bool> ProjectExistsAsync(CustomVisionTrainingClient client, string projectName)\n",
"async Task<Project> GetProjectAsync(CustomVisionTrainingClient client, string projectName)\n",
"{\n",
" var projects = await client.GetProjectsAsync();\n",
" return projects.Where(x => x.Name == projectName).Count() > 0 ? true : false;\n",
" return projects.FirstOrDefault(x => x.Name == projectName);\n",
"}\n",
"\n",
"async Task<bool> ProjectExistsAsync(CustomVisionTrainingClient client, string projectName) => await GetProjectAsync(client, projectName) == null;\n",
"\n",
"async Task<bool> TagExistsAsync(CustomVisionTrainingClient client, string projectName, string tagName)\n",
"{\n",
" var projects = await client.GetProjectsAsync();\n",
" var project = projects.First(x => x.Name == projectName);\n",
" var project = await GetProjectAsync(client, projectName);\n",
" var tags = await client.GetTagsAsync(project.Id);\n",
" return tags.Where(x => x.Name == tagName).Count() > 0 ? true : false;\n",
" return tags.Where(x => x.Name == tagName).Count();\n",
"}"
]
},
Expand Down Expand Up @@ -193,16 +194,14 @@
"outputs": [],
"source": [
"var projectName = \"Infrastructure CV Project\";\n",
"var projectExists = await ProjectExistsAsync(trainingClient, projectName);\n",
"Project project;\n",
"if(!projectExists)\n",
"if(await ProjectExistsAsync(trainingClient, projectName))\n",
"{\n",
" project = await trainingClient.CreateProjectAsync(\"Infrastructure CV Project\", \"An image classifier to detect cracks in pavement\");\n",
"}\n",
"else\n",
"{\n",
" var projects = await trainingClient.GetProjectsAsync();\n",
" project = projects.First(x => x.Name == projectName);\n",
" project = await GetProjectAsync(trainingClient, projectName);\n",
"}"
]
},
Expand Down