Spaces:
Running
Running
Belem Zhang
commited on
Commit
•
3c68b16
1
Parent(s):
6630a28
init commit
Browse files- .gitignore +2 -0
- README.md +2 -0
- assets/icon/article.svg +6 -0
- assets/icon/github.svg +5 -0
- assets/img/sd1.5.jpg +0 -0
- assets/samples.json +49 -0
- assets/script.js +13 -0
- assets/style.css +206 -0
- index.html +129 -17
- style.css +0 -28
.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
key.pem
|
2 |
+
cert.pem
|
README.md
CHANGED
@@ -9,3 +9,5 @@ license: mit
|
|
9 |
---
|
10 |
|
11 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
|
|
9 |
---
|
10 |
|
11 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
12 |
+
|
13 |
+
http-server -S -C cert.pem -o
|
assets/icon/article.svg
ADDED
assets/icon/github.svg
ADDED
assets/img/sd1.5.jpg
ADDED
assets/samples.json
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"samples": [
|
3 |
+
{
|
4 |
+
"id": "1",
|
5 |
+
"title": "Stable Diffusion",
|
6 |
+
"version": "1.5",
|
7 |
+
"description": "",
|
8 |
+
"image":"sd1.5.png",
|
9 |
+
"models": [
|
10 |
+
"Text Encoder",
|
11 |
+
"UNET",
|
12 |
+
"VAE Decoder"
|
13 |
+
],
|
14 |
+
"tags": [
|
15 |
+
"gpu"
|
16 |
+
]
|
17 |
+
},
|
18 |
+
{
|
19 |
+
"id": "2",
|
20 |
+
"title": "Stable Diffusion",
|
21 |
+
"version": "2.1",
|
22 |
+
"description": "",
|
23 |
+
"image":"sd2.1.png",
|
24 |
+
"models": [
|
25 |
+
"Text Encoder",
|
26 |
+
"UNET",
|
27 |
+
"VAE Decoder"
|
28 |
+
],
|
29 |
+
"tags": [
|
30 |
+
"gpu"
|
31 |
+
]
|
32 |
+
},
|
33 |
+
{
|
34 |
+
"id": "3",
|
35 |
+
"title": "Image Classification",
|
36 |
+
"version": "",
|
37 |
+
"description": "",
|
38 |
+
"image":"ic_mobilenet.png",
|
39 |
+
"models": [
|
40 |
+
"MobileNet v2"
|
41 |
+
],
|
42 |
+
"tags": [
|
43 |
+
"cpu",
|
44 |
+
"gpu",
|
45 |
+
"npu"
|
46 |
+
]
|
47 |
+
}
|
48 |
+
]
|
49 |
+
}
|
assets/script.js
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
let json = "";
|
2 |
+
if (location.hostname.toLowerCase().indexOf('huggingface.co') > -1) {
|
3 |
+
json = "https://huggingface.co/spaces/webml/webnn-samples/assets/samples.json";
|
4 |
+
} else {
|
5 |
+
json = "./assets/samples.json";
|
6 |
+
}
|
7 |
+
|
8 |
+
const init = async () => {
|
9 |
+
const response = await fetch(json);
|
10 |
+
const samples = await response.json();
|
11 |
+
console.log(samples);
|
12 |
+
}
|
13 |
+
document.addEventListener('DOMContentLoaded', init, false);
|
assets/style.css
ADDED
@@ -0,0 +1,206 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
body {
|
2 |
+
padding: 2rem;
|
3 |
+
font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
|
4 |
+
}
|
5 |
+
|
6 |
+
h1 {
|
7 |
+
font-size: 16px;
|
8 |
+
margin-top: 0;
|
9 |
+
}
|
10 |
+
|
11 |
+
p {
|
12 |
+
color: rgb(107, 114, 128);
|
13 |
+
font-size: 15px;
|
14 |
+
margin-bottom: 10px;
|
15 |
+
margin-top: 5px;
|
16 |
+
}
|
17 |
+
|
18 |
+
.card {
|
19 |
+
max-width: 620px;
|
20 |
+
margin: 0 auto;
|
21 |
+
padding: 10px;
|
22 |
+
border: 1px solid lightgray;
|
23 |
+
border-radius: 10px;
|
24 |
+
}
|
25 |
+
|
26 |
+
.card p:last-child {
|
27 |
+
margin-bottom: 0;
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
.card_4 {
|
32 |
+
margin-top: 1rem;
|
33 |
+
display: grid;
|
34 |
+
grid-template-columns: repeat(4, 1fr);
|
35 |
+
grid-column-gap: 10px;
|
36 |
+
grid-row-gap: 10px;
|
37 |
+
padding: 10px;
|
38 |
+
}
|
39 |
+
|
40 |
+
.g2 {
|
41 |
+
display: grid;
|
42 |
+
grid-template-columns: repeat(2, 1fr);
|
43 |
+
grid-column-gap: 10px;
|
44 |
+
grid-row-gap: 10px;
|
45 |
+
padding: 0 0;
|
46 |
+
}
|
47 |
+
|
48 |
+
a {
|
49 |
+
outline: none;
|
50 |
+
color: #000;
|
51 |
+
text-decoration: none;
|
52 |
+
font-weight: inherit;
|
53 |
+
}
|
54 |
+
|
55 |
+
a img {
|
56 |
+
border: none;
|
57 |
+
}
|
58 |
+
|
59 |
+
a:hover, a:focus {
|
60 |
+
color: rgba(39, 94, 254, 1);
|
61 |
+
}
|
62 |
+
|
63 |
+
.thumb {
|
64 |
+
max-width: 320px;
|
65 |
+
position: relative;
|
66 |
+
aspect-ratio: 800 / 600;
|
67 |
+
overflow: hidden;
|
68 |
+
border-radius: 10px;
|
69 |
+
}
|
70 |
+
|
71 |
+
.thumb .filled {
|
72 |
+
position: relative;
|
73 |
+
overflow: hidden;
|
74 |
+
height: 100%;
|
75 |
+
display: block;
|
76 |
+
background-color: transparent;
|
77 |
+
background-repeat: no-repeat;
|
78 |
+
background-position: 50% 50%;
|
79 |
+
background-size: 140px;
|
80 |
+
border-radius: 10px;
|
81 |
+
}
|
82 |
+
|
83 |
+
.thumb:hover {
|
84 |
+
box-shadow: 0 3px 15px -1px rgba(39, 94, 254, 0.5);
|
85 |
+
}
|
86 |
+
|
87 |
+
.thumb:hover .sample::after,
|
88 |
+
.thumb:focus .sample::after{
|
89 |
+
opacity: 1;
|
90 |
+
}
|
91 |
+
|
92 |
+
.thumb:hover .icon,
|
93 |
+
.thumb:focus .icon {
|
94 |
+
opacity: 1;
|
95 |
+
pointer-events: auto;
|
96 |
+
}
|
97 |
+
|
98 |
+
.thumb img {
|
99 |
+
display: block;
|
100 |
+
height: 100%;
|
101 |
+
width: auto;
|
102 |
+
max-width: none;
|
103 |
+
}
|
104 |
+
|
105 |
+
.thumb img {
|
106 |
+
display: block;
|
107 |
+
height: 100%;
|
108 |
+
width: auto;
|
109 |
+
max-width: none;
|
110 |
+
}
|
111 |
+
|
112 |
+
.sample::after {
|
113 |
+
content: "View sample \2197";
|
114 |
+
color: #fff;
|
115 |
+
position: absolute;
|
116 |
+
width: 100%;
|
117 |
+
height: 100%;
|
118 |
+
top: 0;
|
119 |
+
left: 0;
|
120 |
+
pointer-events: none;
|
121 |
+
display: grid;
|
122 |
+
font-size: 0.9rem;
|
123 |
+
font-weight: 500;
|
124 |
+
place-items: center;
|
125 |
+
background: rgba(0, 0, 0, 0.7);
|
126 |
+
opacity: 0;
|
127 |
+
transition: opacity 0.3s;
|
128 |
+
}
|
129 |
+
|
130 |
+
.archive {
|
131 |
+
margin: -2.5rem 12px 0 0;
|
132 |
+
position: relative;
|
133 |
+
z-index: 1000;
|
134 |
+
margin-top: -2.5rem;
|
135 |
+
display: flex;
|
136 |
+
align-items: flex-end;
|
137 |
+
justify-content: end;
|
138 |
+
pointer-events: none;
|
139 |
+
gap: 0.5rem;
|
140 |
+
}
|
141 |
+
|
142 |
+
.icon {
|
143 |
+
width: 30px;
|
144 |
+
height: 30px;
|
145 |
+
font-size: 0;
|
146 |
+
display: grid;
|
147 |
+
padding: 0;
|
148 |
+
border-radius: 50%;
|
149 |
+
background: #fff;
|
150 |
+
pointer-events: none;
|
151 |
+
opacity: 0;
|
152 |
+
transition: opacity 0.3s;
|
153 |
+
}
|
154 |
+
|
155 |
+
.github {
|
156 |
+
background: rgba(255, 255, 255, 0.2) url(./icon/github.svg) no-repeat 50% 50%;
|
157 |
+
background-size: 16px;
|
158 |
+
}
|
159 |
+
|
160 |
+
.github:hover {
|
161 |
+
background: rgba(39, 94, 254, 0.8) url(./icon/github.svg) no-repeat 50% 50%;
|
162 |
+
background-size: 16px;
|
163 |
+
}
|
164 |
+
|
165 |
+
.article {
|
166 |
+
background: rgba(255, 255, 255, 0.2) url(./icon/article.svg) no-repeat 50% 50%;
|
167 |
+
background-size: 16px;
|
168 |
+
}
|
169 |
+
|
170 |
+
.article:hover {
|
171 |
+
background: rgba(39, 94, 254, 0.8) url(./icon/article.svg) no-repeat 50% 50%;
|
172 |
+
background-size: 16px;
|
173 |
+
}
|
174 |
+
|
175 |
+
.description {
|
176 |
+
margin-top: 1rem;
|
177 |
+
flex-direction: column;
|
178 |
+
align-items: flex-start;
|
179 |
+
max-width: 320px;
|
180 |
+
}
|
181 |
+
|
182 |
+
.tags {
|
183 |
+
text-transform: lowercase;
|
184 |
+
text-overflow: ellipsis;
|
185 |
+
font-size: 12px;
|
186 |
+
}
|
187 |
+
|
188 |
+
.tags a, .tags span {
|
189 |
+
color: rgb(0 0 0 / 75%);
|
190 |
+
white-space: nowrap;
|
191 |
+
border: 1px solid;
|
192 |
+
border-radius: 3rem;
|
193 |
+
padding: 2px 0.35rem 4px 0.35rem;
|
194 |
+
margin: 0 4px;
|
195 |
+
}
|
196 |
+
|
197 |
+
.backend {
|
198 |
+
justify-self: right;
|
199 |
+
}
|
200 |
+
|
201 |
+
.tags a:hover, .tags span:hover {
|
202 |
+
border: 1px solid #184fee;
|
203 |
+
color: #fff;
|
204 |
+
background: linear-gradient(135deg, #184fee 0%, #144acc 40%, #144acc 100%);
|
205 |
+
box-shadow: 0 3px 15px -1px rgba(39, 94, 254, 0.5);
|
206 |
+
}
|
index.html
CHANGED
@@ -1,19 +1,131 @@
|
|
1 |
<!doctype html>
|
2 |
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
<
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
</p>
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<!doctype html>
|
2 |
<html>
|
3 |
+
|
4 |
+
<head>
|
5 |
+
<meta charset="utf-8" />
|
6 |
+
<meta name="viewport" content="width=device-width" />
|
7 |
+
<title>WebNN Samples</title>
|
8 |
+
<link rel="stylesheet" href="assets/style.css" />
|
9 |
+
<script src="assets/script.js"></script>
|
10 |
+
</head>
|
11 |
+
|
12 |
+
<body>
|
13 |
+
<div class="card">
|
14 |
+
<h1>WebNN Samples</h1>
|
15 |
+
<p>Samples built with WebNN API. The best and recommended way to leverage WebNN capabilities and performance for
|
16 |
+
your web applications is to use ONNX Runtime Web that integrates WebNN API directly. </p>
|
17 |
+
</div>
|
18 |
+
|
19 |
+
<div class="card_4">
|
20 |
+
<article id="">
|
21 |
+
<div class="thumb">
|
22 |
+
<a class="filled sample" href="">
|
23 |
+
<img src="assets/img/sd1.5.jpg">
|
24 |
+
</a>
|
25 |
+
<div class="archive">
|
26 |
+
<a class="icon article" title="Read the article" href=""></a>
|
27 |
+
<a class="icon github" title="Code on GitHub" href=""></a>
|
28 |
+
</div>
|
29 |
+
</div>
|
30 |
+
<div class="description">
|
31 |
+
<div class="g2">
|
32 |
+
<div class="tags"><a href="">Text Encoder</a><a href="">UNET</a><a href="">VAE</a></div>
|
33 |
+
<div class="tags backend"><a href="">WebNN GPU</a></div>
|
34 |
+
</div>
|
35 |
+
<h2 class="title"><a href="">Stable Diffusion 1.5</a></h2>
|
36 |
+
</div>
|
37 |
+
</article>
|
38 |
+
<article id="">
|
39 |
+
<div class="thumb">
|
40 |
+
<a class="filled sample" href="">
|
41 |
+
<img src="assets/img/sd1.5.jpg">
|
42 |
+
</a>
|
43 |
+
<div class="archive">
|
44 |
+
<a class="icon article" title="Read the article" href=""></a>
|
45 |
+
<a class="icon github" title="Code on GitHub" href=""></a>
|
46 |
+
</div>
|
47 |
+
</div>
|
48 |
+
<div class="description">
|
49 |
+
<div class="g2">
|
50 |
+
<div class="tags"><a href="">Text Encoder</a><a href="">UNET</a><a href="">VAE</a></div>
|
51 |
+
<div class="tags backend"><a href="">WebNN GPU</a></div>
|
52 |
+
</div>
|
53 |
+
<h2 class="title"><a href="">Stable Diffusion 1.5</a></h2>
|
54 |
+
</div>
|
55 |
+
</article>
|
56 |
+
<article id="">
|
57 |
+
<div class="thumb">
|
58 |
+
<a class="filled sample" href="">
|
59 |
+
<img src="assets/img/sd1.5.jpg">
|
60 |
+
</a>
|
61 |
+
<div class="archive">
|
62 |
+
<a class="icon article" title="Read the article" href=""></a>
|
63 |
+
<a class="icon github" title="Code on GitHub" href=""></a>
|
64 |
+
</div>
|
65 |
+
</div>
|
66 |
+
<div class="description">
|
67 |
+
<div class="g2">
|
68 |
+
<div class="tags"><a href="">Text Encoder</a><a href="">UNET</a><a href="">VAE</a></div>
|
69 |
+
<div class="tags backend"><a href="">WebNN GPU</a></div>
|
70 |
+
</div>
|
71 |
+
<h2 class="title"><a href="">Stable Diffusion 1.5</a></h2>
|
72 |
+
</div>
|
73 |
+
</article>
|
74 |
+
<article id="">
|
75 |
+
<div class="thumb">
|
76 |
+
<a class="filled sample" href="">
|
77 |
+
<img src="assets/img/sd1.5.jpg">
|
78 |
+
</a>
|
79 |
+
<div class="archive">
|
80 |
+
<a class="icon article" title="Read the article" href=""></a>
|
81 |
+
<a class="icon github" title="Code on GitHub" href=""></a>
|
82 |
+
</div>
|
83 |
+
</div>
|
84 |
+
<div class="description">
|
85 |
+
<div class="g2">
|
86 |
+
<div class="tags"><a href="">Text Encoder</a><a href="">UNET</a><a href="">VAE</a></div>
|
87 |
+
<div class="tags backend"><a href="">WebNN GPU</a></div>
|
88 |
+
</div>
|
89 |
+
<h2 class="title"><a href="">Stable Diffusion 1.5</a></h2>
|
90 |
+
</div>
|
91 |
+
</article>
|
92 |
+
<article id="">
|
93 |
+
<div class="thumb">
|
94 |
+
<a class="filled sample" href="">
|
95 |
+
<img src="assets/img/sd1.5.jpg">
|
96 |
+
</a>
|
97 |
+
<div class="archive">
|
98 |
+
<a class="icon article" title="Read the article" href=""></a>
|
99 |
+
<a class="icon github" title="Code on GitHub" href=""></a>
|
100 |
+
</div>
|
101 |
+
</div>
|
102 |
+
<div class="description">
|
103 |
+
<div class="g2">
|
104 |
+
<div class="tags"><a href="">Text Encoder</a><a href="">UNET</a><a href="">VAE</a></div>
|
105 |
+
<div class="tags backend"><a href="">WebNN GPU</a></div>
|
106 |
+
</div>
|
107 |
+
<h2 class="title"><a href="">Stable Diffusion 1.5</a></h2>
|
108 |
+
</div>
|
109 |
+
</article>
|
110 |
+
<article id="">
|
111 |
+
<div class="thumb">
|
112 |
+
<a class="filled sample" href="">
|
113 |
+
<img src="assets/img/sd1.5.jpg">
|
114 |
+
</a>
|
115 |
+
<div class="archive">
|
116 |
+
<a class="icon article" title="Read the article" href=""></a>
|
117 |
+
<a class="icon github" title="Code on GitHub" href=""></a>
|
118 |
+
</div>
|
119 |
+
</div>
|
120 |
+
<div class="description">
|
121 |
+
<div class="g2">
|
122 |
+
<div class="tags"><a href="">Text Encoder</a><a href="">UNET</a><a href="">VAE</a></div>
|
123 |
+
<div class="tags backend"><a href="">WebNN GPU</a></div>
|
124 |
+
</div>
|
125 |
+
<h2 class="title"><a href="">Stable Diffusion 1.5</a></h2>
|
126 |
+
</div>
|
127 |
+
</article>
|
128 |
+
</div>
|
129 |
+
</body>
|
130 |
+
|
131 |
+
</html>
|
style.css
DELETED
@@ -1,28 +0,0 @@
|
|
1 |
-
body {
|
2 |
-
padding: 2rem;
|
3 |
-
font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
|
4 |
-
}
|
5 |
-
|
6 |
-
h1 {
|
7 |
-
font-size: 16px;
|
8 |
-
margin-top: 0;
|
9 |
-
}
|
10 |
-
|
11 |
-
p {
|
12 |
-
color: rgb(107, 114, 128);
|
13 |
-
font-size: 15px;
|
14 |
-
margin-bottom: 10px;
|
15 |
-
margin-top: 5px;
|
16 |
-
}
|
17 |
-
|
18 |
-
.card {
|
19 |
-
max-width: 620px;
|
20 |
-
margin: 0 auto;
|
21 |
-
padding: 16px;
|
22 |
-
border: 1px solid lightgray;
|
23 |
-
border-radius: 16px;
|
24 |
-
}
|
25 |
-
|
26 |
-
.card p:last-child {
|
27 |
-
margin-bottom: 0;
|
28 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|