Spaces:
Running
Running
Commit
·
1d9a73d
1
Parent(s):
5fa7853
Update index.html
Browse files- index.html +144 -102
index.html
CHANGED
@@ -24,8 +24,6 @@
|
|
24 |
style: {},
|
25 |
},
|
26 |
},
|
27 |
-
|
28 |
-
|
29 |
{
|
30 |
id: 4,
|
31 |
type: "group",
|
@@ -81,7 +79,7 @@
|
|
81 |
name: "gallery",
|
82 |
visible: true,
|
83 |
elem_id: "gallery",
|
84 |
-
style: { grid: [3], height: "auto" },
|
85 |
},
|
86 |
},
|
87 |
{
|
@@ -106,9 +104,6 @@
|
|
106 |
style: { full_width: true },
|
107 |
},
|
108 |
},
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
],
|
113 |
theme: "default",
|
114 |
css: ".container { max-width: 800px; margin: auto; }",
|
@@ -145,99 +140,146 @@
|
|
145 |
inputs: [7],
|
146 |
outputs: [9],
|
147 |
backend_fn: false,
|
148 |
-
js:
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
style: {},
|
25 |
},
|
26 |
},
|
|
|
|
|
27 |
{
|
28 |
id: 4,
|
29 |
type: "group",
|
|
|
79 |
name: "gallery",
|
80 |
visible: true,
|
81 |
elem_id: "gallery",
|
82 |
+
style: { grid: [3, 2], height: "auto" }, // Ajusta las dimensiones de la cuadrícula
|
83 |
},
|
84 |
},
|
85 |
{
|
|
|
104 |
style: { full_width: true },
|
105 |
},
|
106 |
},
|
|
|
|
|
|
|
107 |
],
|
108 |
theme: "default",
|
109 |
css: ".container { max-width: 800px; margin: auto; }",
|
|
|
140 |
inputs: [7],
|
141 |
outputs: [9],
|
142 |
backend_fn: false,
|
143 |
+
js: `
|
144 |
+
async (text) => {
|
145 |
+
try {
|
146 |
+
document.querySelector('#screenshot').style.display = 'none';
|
147 |
+
response = await fetch('https://bf.dallemini.ai/generate', {
|
148 |
+
method: 'POST',
|
149 |
+
headers: {
|
150 |
+
'Accept': 'application/json',
|
151 |
+
'Content-Type': 'application/json'
|
152 |
+
},
|
153 |
+
body: JSON.stringify({
|
154 |
+
prompt: text
|
155 |
+
})
|
156 |
+
});
|
157 |
+
response = await response.json();
|
158 |
+
let imgs = response.images.map(r => "data:image/png;base64," + r);
|
159 |
+
document.querySelector('#screenshot').style.display = 'block';
|
160 |
+
return imgs;
|
161 |
+
} catch (e) {
|
162 |
+
alert("Too much traffic, please try again.");
|
163 |
+
IMG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAOVBMVEXg4OB1dXXX19fd3d2EhIR9fX14eHjJycm2trbb29uurq6goKCZmZmIiIiBgYHNzc2np6e8vLySkpKXK8HrAAABuUlEQVR4nO3Z0bKCIBCAYQNFVCzr/R/2nHU6k8KpJi6wZf7vLu1id9gFhKYBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAb249h7pzr5jD29uhospnlfNo4L+boiLKYyZ0iblKYiu/iNER3PTquD9npPgbB98Za0/twH59JVasMtzXo1m+iHny7PrwpysSuebgxCtmOTlkma121l/TFZR2UqXxEebxEO/87QZlZ3inpeCPzVftkojUyJp2OWVgKy23qSsbg8evitBSXkUjHzYN9Is0oeWoYkkUKazsxRYlYKa6ldFSfs7K/8tsnUSLrXHAuG1SOXpp5t1LEiQxSe33ZqDJIC4TdkziRJkRN9J1CXFlpIj7J9RvNSd0kiUj1zSVjyiKr4X5yTRIx0kYlY8oinbzfFSaJWFlJSsaUpZpEqimttNkTOpo9nX4TOqbfdEFM6FgQpW7c8OofSrYo1Wwaq9nG1/NhVc2nbj2HD821kuOgeg7o3hyZBj1Hpo9D7M3K+HeIrSmPeq4Vfl3ruOhpnly9vdyEfa1KLkPF7nr66GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPjcD13rCcC3ILx/AAAAAElFTkSuQmCC"
|
164 |
+
document.querySelector('#screenshot').style.display = 'block';
|
165 |
+
return Array(9).fill(IMG);
|
166 |
+
}
|
167 |
+
}
|
168 |
+
`,
|
169 |
+
status_tracker: null,
|
170 |
+
queue: null,
|
171 |
+
api_name: null,
|
172 |
+
scroll_to_output: false,
|
173 |
+
show_progress: true,
|
174 |
+
},
|
175 |
+
{
|
176 |
+
targets: [11],
|
177 |
+
trigger: "click",
|
178 |
+
inputs: [],
|
179 |
+
outputs: [],
|
180 |
+
backend_fn: false,
|
181 |
+
js: `
|
182 |
+
() => {
|
183 |
+
const captureElement = document.getElementById(1);
|
184 |
+
let bg_color = getComputedStyle(document.querySelector("#root .container"))["background-color"];
|
185 |
+
captureElement.style.backgroundColor = bg_color;
|
186 |
+
html2canvas(captureElement)
|
187 |
+
.then(canvas => {
|
188 |
+
canvas.style.display = 'none';
|
189 |
+
document.body.appendChild(canvas);
|
190 |
+
return canvas;
|
191 |
+
})
|
192 |
+
.then(canvas => {
|
193 |
+
const image = canvas.toDataURL('image/png').replace('image/png', 'image/octet-stream');
|
194 |
+
const a = document.createElement('a');
|
195 |
+
const date = new Date();
|
196 |
+
const filename = \`dallemini_\${date.getFullYear()}-\${date.getMonth() + 1}-\${date.getDate()}_\${date.getHours()}-\${date.getMinutes()}-\${date.getSeconds()}.png\`;
|
197 |
+
a.setAttribute('download', filename);
|
198 |
+
a.setAttribute('href', image);
|
199 |
+
a.click();
|
200 |
+
canvas.remove();
|
201 |
+
});
|
202 |
+
}
|
203 |
+
`,
|
204 |
+
status_tracker: null,
|
205 |
+
queue: null,
|
206 |
+
api_name: null,
|
207 |
+
scroll_to_output: false,
|
208 |
+
show_progress: true,
|
209 |
+
},
|
210 |
+
],
|
211 |
+
};
|
212 |
+
</script>
|
213 |
+
|
214 |
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
215 |
+
<link
|
216 |
+
rel="preconnect"
|
217 |
+
href="https://fonts.gstatic.com"
|
218 |
+
crossorigin="anonymous"
|
219 |
+
/>
|
220 |
+
<link
|
221 |
+
href="https://fonts.googleapis.com/css?family=Source Sans Pro"
|
222 |
+
rel="stylesheet"
|
223 |
+
/>
|
224 |
+
<link
|
225 |
+
href="https://fonts.googleapis.com/css?family=IBM Plex Mono"
|
226 |
+
rel="stylesheet"
|
227 |
+
/>
|
228 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.1/iframeResizer.contentWindow.min.js"></script>
|
229 |
+
<script
|
230 |
+
type="module"
|
231 |
+
crossorigin
|
232 |
+
src="https://gradio.s3-us-west-2.amazonaws.com/3.0.9b12/assets/index.8eca4ae7.js"
|
233 |
+
></script>
|
234 |
+
<link
|
235 |
+
rel="stylesheet"
|
236 |
+
href="https://gradio.s3-us-west-2.amazonaws.com/3.0.9b12/assets/index.cbea297d.css"
|
237 |
+
/>
|
238 |
+
<style>
|
239 |
+
#screenshot {
|
240 |
+
display: none;
|
241 |
+
}
|
242 |
+
.container > div > div {
|
243 |
+
padding: 0.5rem;
|
244 |
+
}
|
245 |
+
footer a {
|
246 |
+
color: rgb(156 163 175) !important;
|
247 |
+
}
|
248 |
+
footer img {
|
249 |
+
display: none !important;
|
250 |
+
}
|
251 |
+
</style>
|
252 |
+
<style id="mofo">
|
253 |
+
body {
|
254 |
+
display: none !important;
|
255 |
+
}
|
256 |
+
</style>
|
257 |
+
<script type="text/javascript">
|
258 |
+
if (
|
259 |
+
self === top ||
|
260 |
+
window.location.ancestorOrigins[0] === "https://huggingface.co"
|
261 |
+
) {
|
262 |
+
var mofo = document.getElementById("mofo");
|
263 |
+
mofo.parentNode.removeChild(mofo);
|
264 |
+
} else {
|
265 |
+
top.location = self.location;
|
266 |
+
}
|
267 |
+
</script>
|
268 |
+
</head>
|
269 |
+
|
270 |
+
<body
|
271 |
+
style="
|
272 |
+
margin: 0;
|
273 |
+
padding: 0;
|
274 |
+
display: flex;
|
275 |
+
flex-direction: column;
|
276 |
+
flex-grow: 1;
|
277 |
+
"
|
278 |
+
>
|
279 |
+
<div
|
280 |
+
id="root"
|
281 |
+
style="display: flex; flex-direction: column; flex-grow: 1"
|
282 |
+
></div>
|
283 |
+
<script src="html2canvas.js"></script>
|
284 |
+
</body>
|
285 |
+
</html>
|