Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit 2becaa1

Browse files
authored
Added recipes endpoint to sparsezoo table ui (#77)
* Added recipes endpoint to sparsezoo table ui * Removed commented code
1 parent a762ef1 commit 2becaa1

File tree

21 files changed

+651
-50
lines changed

21 files changed

+651
-50
lines changed

docs/source/recipes.md

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,35 +40,16 @@ The properties within each model stub are defined as the following:
4040

4141
### Image Classification
4242

43-
| Model Tag | Validation Baseline Metric |
44-
| ----------------------------------------------------------------------------------------------------------------- | -------------------------- |
45-
| cv/classification/efficientnet-b0/pytorch/sparseml/imagenet/arch-moderate?recipe_type=original | 76.5% top1 accuracy |
46-
| cv/classification/efficientnet-b4/pytorch/sparseml/imagenet/arch-moderate?recipe_type=original | 82.1% top1 accuracy |
47-
| cv/classification/inception_v3/pytorch/sparseml/imagenet/pruned-conservative?recipe_type=original | 77.4% top1 accuracy |
48-
| cv/classification/inception_v3/pytorch/sparseml/imagenet/pruned-moderate?recipe_type=original | 76.6% top1 accuracy |
49-
| cv/classification/mobilenet_v1-1.0/pytorch/sparseml/imagenet/base-none?recipe_type=original | 70.9% top1 accuracy |
50-
| cv/classification/mobilenet_v1-1.0/pytorch/sparseml/imagenet/pruned-conservative?recipe_type=original | 70.9% top1 accuracy |
51-
| cv/classification/mobilenet_v1-1.0/pytorch/sparseml/imagenet/pruned-moderate?recipe_type=original | 70.1% top1 accuracy |
52-
| cv/classification/mobilenet_v1-1.0/pytorch/sparseml/imagenet/pruned_quant-moderate?recipe_type=original | 70.1% top1 accuracy |
53-
| cv/classification/mobilenet_v1-1.0/pytorch/sparseml/imagenet/pruned_quant-moderate?recipe_type=original | 70.1% top1 accuracy |
54-
| cv/classification/resnet_v1-101/pytorch/sparseml/imagenet/pruned-moderate?recipe_type=original | 76.6% top1 accuracy |
55-
| cv/classification/resnet_v1-152/pytorch/sparseml/imagenet/pruned-moderate?recipe_type=original | 77.5% top1 accuracy |
56-
| cv/classification/resnet_v1-18/pytorch/sparseml/imagenet/pruned-conservative?recipe_type=original | 69.8% top1 accuracy |
57-
| cv/classification/resnet_v1-34/pytorch/sparseml/imagenet/pruned-conservative?recipe_type=original | 73.3% top1 accuracy |
58-
| cv/classification/resnet_v1-50/pytorch/sparseml/imagenet/pruned-conservative?recipe_type=original | 76.1% top1 accuracy |
59-
| cv/classification/resnet_v1-50/pytorch/sparseml/imagenet/pruned-moderate?recipe_type=original | 75.3% top1 accuracy |
60-
| cv/classification/resnet_v1-50/pytorch/sparseml/imagenet-augmented/pruned_quant-aggressive?recipe_type=original | 76.1% top1 accuracy |
61-
| cv/classification/resnet_v1-50/pytorch/sparseml/imagenette/pruned-conservative?recipe_type=original | 99.9% top1 accuracy |
62-
| cv/classification/resnet_v1-50/pytorch/torchvision/imagenette/pruned-conservative?recipe_type=original | 99.9% top1 accuracy |
63-
| cv/classification/vgg-11/pytorch/sparseml/imagenet/pruned-moderate?recipe_type=original | 68.3% top1 accuracy |
64-
| cv/classification/vgg-16/pytorch/sparseml/imagenet/pruned-conservative?recipe_type=original | 71.6% top1 accuracy |
65-
| cv/classification/vgg-16/pytorch/sparseml/imagenet/pruned-moderate?recipe_type=original | 70.8% top1 accuracy |
66-
| cv/classification/vgg-19/pytorch/sparseml/imagenet/pruned-moderate?recipe_type=original | 71.7% top1 accuracy |
43+
<div>
44+
<iframe src="https://sparsezoo.neuralmagic.com/recipes/cv/classification" title="Image Classification Recipes" width="100%" height="500px"></iframe>
45+
</div>
46+
47+
Image classification table not loading? View full table [here](https://sparsezoo.neuralmagic.com/recipes/cv/classification).
6748

6849
### Object Detection
6950

70-
| Model Tag | Validation Baseline Metric |
71-
| ----------------------------------------------------------------------------------------------------------------- | -------------------------- |
72-
| cv/detection/ssd-resnet50_300/pytorch/sparseml/coco/pruned-moderate?recipe_type=original | 41.8 [email protected] |
73-
| cv/detection/ssd-resnet50_300/pytorch/sparseml/voc/pruned-moderate?recipe_type=original | 51.5 [email protected] |
74-
| cv/detection/yolo_v3-spp/pytorch/ultralytics/coco/pruned-aggressive?recipe_type=original | 62.1 [email protected] |
51+
<div>
52+
<iframe src="https://sparsezoo.neuralmagic.com/recipes/cv/detection" title="Object Detect Recipes" width="100%" height="500px"></iframe>
53+
</div>
54+
55+
Object detection table not loading? View full table [here](https://sparsezoo.neuralmagic.com/recipes/cv/detection).

src/ui/api/index.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ limitations under the License.
1616

1717
export * from "./auth";
1818
export * from "./models";
19+
export * from "./recipes";
1920
export * from "./utils";

src/ui/api/models.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { API_ROOT, validateAPIResponseJSON } from "./utils";
3333
* training_scheme: string,
3434
* sparse_name: string,
3535
* sparse_category: string,
36-
* sparse_target
36+
* sparse_target: string
3737
* }} requestBody.queries the additional queries for the search result
3838
* @returns {Promise<Array>}
3939
*/

src/ui/api/recipes.jsx

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
Copyright (c) 2021 - present / Neuralmagic, Inc. All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing,
11+
software distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import { API_ROOT, validateAPIResponseJSON } from "./utils";
18+
19+
/**
20+
* API action for searching for models in the model zoo
21+
* @param {object} requestBody the requestBody
22+
* @param {string} requestBody.domain the domain of the model search
23+
* @param {string} requestBody.subdomain the subdomain of the model search
24+
* @param {string} requestBody.token the token for the model search authentication
25+
* @param {string} requestBody.page the page of search results to return
26+
* @param {string} requestBody.page_legth the amount of search results to return
27+
* @param {{
28+
* architecture: string,
29+
* sub_architecture: string,
30+
* repo: string,
31+
* framework: string,
32+
* dataset: string,
33+
* training_scheme: string,
34+
* sparse_name: string,
35+
* sparse_category: string,
36+
* sparse_target: string,
37+
* recipe_type: string
38+
* }} requestBody.queries the additional queries for the search result
39+
* @returns {Promise<Array>}
40+
*/
41+
export function requestSearchRecipes({
42+
domain,
43+
subdomain,
44+
token,
45+
page = 1,
46+
page_length = 20,
47+
queries = {},
48+
}) {
49+
let url = `${API_ROOT}/recipes/search/${domain}/${subdomain}?page=${page}&page_length=${page_length}`;
50+
if (queries) {
51+
for (const [key, value] of Object.entries(queries)) {
52+
url = `${url}&${key}=${value}`;
53+
}
54+
}
55+
return validateAPIResponseJSON(
56+
fetch(url, {
57+
method: "GET",
58+
headers: {
59+
"Content-Type": "application/json",
60+
"nm-token-header": token,
61+
},
62+
})
63+
);
64+
}

src/ui/components/model-table/model-table.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ function ModelTable({ domain, subdomain, includePagination, includeHeader, queri
4040
const modelsState = useSelector(selectModelsState);
4141

4242
const results = useSelector(selectModelTable);
43-
4443
useEffect(() => {
4544
const status = lodash.get(modelsState.status, `${domain}.${subdomain}`, "idle");
4645
if (authState.token !== null && status === "idle") {
@@ -81,6 +80,7 @@ function ModelTable({ domain, subdomain, includePagination, includeHeader, queri
8180
copy={lodash.get(results, `${domain}.${subdomain}.copy`, false)}
8281
width={lodash.get(results, `${domain}.${subdomain}.width`)}
8382
includePagination={includePagination}
83+
loadingMessage="Loading models"
8484
/>
8585
</div>
8686
);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
Copyright (c) 2021 - present / Neuralmagic, Inc. All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing,
11+
software distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
export { default } from "./recipe-table";
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
Copyright (c) 2021 - present / Neuralmagic, Inc. All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing,
11+
software distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import { makeStyles } from "@material-ui/core/styles";
18+
19+
export default function makeRecipeTableStyles() {
20+
return makeStyles(
21+
(theme) => ({
22+
root: {
23+
padding: theme.spacing(0.5),
24+
},
25+
toolbar: {},
26+
}),
27+
{ name: "RecipeTable" }
28+
);
29+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/*
2+
Copyright (c) 2021 - present / Neuralmagic, Inc. All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing,
11+
software distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import React, { useEffect } from "react";
18+
import { useSelector, useDispatch } from "react-redux";
19+
import PropTypes from "prop-types";
20+
21+
import lodash from "lodash";
22+
23+
import Typography from "@material-ui/core/Typography";
24+
25+
import {
26+
selectAuthState,
27+
selectRecipesState,
28+
searchRecipesThunk,
29+
selectRecipesTable,
30+
} from "../../store";
31+
import makeStyles from "./recipe-table-styles";
32+
import ZooTable from "../zoo-table";
33+
34+
function RecipeTable({ domain, subdomain, includePagination, includeHeader, queries }) {
35+
const useStyles = makeStyles();
36+
const classes = useStyles();
37+
const dispatch = useDispatch();
38+
39+
const authState = useSelector(selectAuthState);
40+
const recipesState = useSelector(selectRecipesState);
41+
console.log(recipesState);
42+
const results = useSelector(selectRecipesTable);
43+
44+
useEffect(() => {
45+
const status = lodash.get(recipesState.status, `${domain}.${subdomain}`, "idle");
46+
if (authState.token !== null && status === "idle") {
47+
dispatch(
48+
searchRecipesThunk({
49+
domain,
50+
subdomain,
51+
token: authState.token,
52+
queries,
53+
})
54+
);
55+
}
56+
}, [authState.token, recipesState.status, dispatch, domain, subdomain, queries]);
57+
58+
const rows = lodash
59+
.get(results, `${domain}.${subdomain}.data`, [])
60+
.map((data) => data.row);
61+
const status = lodash.get(results, `${domain}.${subdomain}.status`, "idle");
62+
const loaded = status !== "idle" && status !== "loading";
63+
return (
64+
<div className={classes.root}>
65+
{loaded && includeHeader && (
66+
<Typography variant="h6">
67+
{lodash.get(
68+
results,
69+
`${domain}.${subdomain}.displayName`,
70+
`${domain} ${subdomain}`
71+
)}
72+
</Typography>
73+
)}
74+
<ZooTable
75+
ariaLabel={`${domain}.${subdomain}`}
76+
headers={lodash.get(results, `${domain}.${subdomain}.headers`, [])}
77+
rows={rows}
78+
status={status}
79+
error={authState.error || recipesState.error}
80+
aligns={lodash.get(results, `${domain}.${subdomain}.aligns`, "left")}
81+
copy={lodash.get(results, `${domain}.${subdomain}.copy`, false)}
82+
width={lodash.get(results, `${domain}.${subdomain}.width`)}
83+
includePagination={includePagination}
84+
loadingMessage="Loading recipes"
85+
/>
86+
</div>
87+
);
88+
}
89+
90+
RecipeTable.propTypes = {
91+
domain: PropTypes.string.isRequired,
92+
subdomain: PropTypes.string.isRequired,
93+
queries: PropTypes.object,
94+
includePagination: PropTypes.bool,
95+
includeHeader: PropTypes.bool,
96+
};
97+
98+
RecipeTable.defaultProps = {
99+
includePagination: false,
100+
includeHeader: false,
101+
queries: {},
102+
};
103+
104+
export default RecipeTable;

src/ui/components/zoo-table/zoo-table.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ function ZooTable({
3838
width,
3939
copy,
4040
includePagination,
41+
loadingMessage,
4142
}) {
4243
const useStyles = makeStyles();
4344
const classes = useStyles();
@@ -68,7 +69,7 @@ function ZooTable({
6869
loaderSize={150}
6970
loaderChildren={
7071
<Typography className={classes.loaderText}>
71-
{!error && "Loading models"}
72+
{!error && loadingMessage}
7273
</Typography>
7374
}
7475
></LoaderOverlay>
@@ -135,6 +136,7 @@ ZooTable.propTypes = {
135136
]),
136137
copy: PropTypes.oneOfType([PropTypes.bool, PropTypes.arrayOf(PropTypes.bool)]),
137138
includePagination: PropTypes.bool,
139+
loadingMessage: PropTypes.string,
138140
};
139141

140142
ZooTable.defaultProps = {
@@ -146,6 +148,7 @@ ZooTable.defaultProps = {
146148
paginationOptions: [10, 25, 100],
147149
includePagination: false,
148150
copy: false,
151+
loadingMessage: "Loading...",
149152
};
150153

151154
export default ZooTable;

src/ui/routes/paths.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ limitations under the License.
1616

1717
export const MODEL_TABLE_ROOT_PATH = "/models";
1818
export const MODEL_TABLE_PATH = "/models/:domain/:subdomain";
19+
export const RECIPE_TABLE_ROOT_PATH = "/recipes";
20+
export const RECIPE_TABLE_PATH = "/recipes/:domain/:subdomain";

src/ui/routes/recipes-root/index.jsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
Copyright (c) 2021 - present / Neuralmagic, Inc. All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing,
11+
software distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
export { default } from "./recipes-root";
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
Copyright (c) 2021 - present / Neuralmagic, Inc. All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing,
11+
software distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import { makeStyles } from "@material-ui/core/styles";
18+
19+
export default function makeRecipeTableRootStyles() {
20+
return makeStyles(
21+
(theme) => ({
22+
root: {},
23+
}),
24+
{ name: "RecipeTableRoot" }
25+
);
26+
}

0 commit comments

Comments
 (0)