Spaces:
Running
Running
Commit
·
3f03acf
1
Parent(s):
e9ab8e4
improve
Browse files- 32.pth +3 -0
- 64-guardado.pth +3 -0
- 64.pth +2 -2
- app.ipynb +112 -308
- app.py +49 -24
- meshSubplot.py +111 -0
- modelo-best-nueva.pth +3 -0
- modelo-best-nuevacc.pth +3 -0
- output.obj +0 -0
- sinsub.obj +14 -62
32.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4aee59c935e5203ff354f7a34a9e1ea99a4ee7f43a2bcd028d84335bba312f2f
|
3 |
+
size 6713611
|
64-guardado.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d6b832725a9ac119612e7e578c9c32d93c9c90edad65ec1c7a88f0da44f90207
|
3 |
+
size 10202443
|
64.pth
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:37f658c9e5db8fc3340a133ef1be94c3b1127d2eb74a6d7f94ab812e989c2dff
|
3 |
+
size 6713611
|
app.ipynb
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
-
"execution_count":
|
6 |
"metadata": {},
|
7 |
"outputs": [],
|
8 |
"source": [
|
@@ -20,14 +20,13 @@
|
|
20 |
"import os\n",
|
21 |
"from resamplear import *\n",
|
22 |
"import open3d as o3d\n",
|
23 |
-
"from
|
24 |
-
"
|
25 |
-
"from vedo import *"
|
26 |
]
|
27 |
},
|
28 |
{
|
29 |
"cell_type": "code",
|
30 |
-
"execution_count":
|
31 |
"metadata": {},
|
32 |
"outputs": [],
|
33 |
"source": [
|
@@ -139,7 +138,7 @@
|
|
139 |
},
|
140 |
{
|
141 |
"cell_type": "code",
|
142 |
-
"execution_count":
|
143 |
"metadata": {},
|
144 |
"outputs": [],
|
145 |
"source": [
|
@@ -204,23 +203,20 @@
|
|
204 |
"\n",
|
205 |
"def prepararAristas( grafo ):\n",
|
206 |
" for arista in grafo.edges():\n",
|
207 |
-
" nx.set_edge_attributes( grafo, {arista : {'procesada':False}})\n"
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
"t_list = os.listdir(\"./nuevostrees/\" )\n",
|
217 |
-
"dataset = tDataset(t_list, \"./nuevostrees/\")\n",
|
218 |
-
"data_loader = DataLoader(dataset, batch_size = batch_size, shuffle=True, collate_fn=my_collate)"
|
219 |
]
|
220 |
},
|
221 |
{
|
222 |
"cell_type": "code",
|
223 |
-
"execution_count":
|
224 |
"metadata": {},
|
225 |
"outputs": [],
|
226 |
"source": [
|
@@ -232,371 +228,194 @@
|
|
232 |
" \n",
|
233 |
" z = torch.randn(1, latent_size)\n",
|
234 |
" generated_images = decode_testing(z, 100, Grassdecoder, mult, 1)\n",
|
235 |
-
" print(\"generated images\", generated_images)\n",
|
236 |
" count = []\n",
|
237 |
" numerar_nodos(generated_images, count)\n",
|
|
|
238 |
" #tr(generated_images)\n",
|
239 |
" generated_images.toGraph( G, 0, True, flag = 0)\n",
|
240 |
-
"\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
" \n",
|
242 |
" #nx.write_gpickle(graph, \"grafo0.gpickle\" )\n",
|
243 |
" for arista in G.edges():\n",
|
244 |
" nx.set_edge_attributes( G, {arista : {'procesada':False}})\n",
|
245 |
-
" #graph_resampled = resamplear(G, puntosPorUnidad=
|
246 |
" graph_resampled = G\n",
|
247 |
" prepararAristas(graph_resampled)\n",
|
248 |
" graphOfCenters = GrafoCentros(graph_resampled)\n",
|
249 |
" \n",
|
250 |
-
"
|
251 |
-
"
|
252 |
-
"
|
253 |
-
"
|
254 |
-
"
|
255 |
-
"
|
256 |
-
"
|
257 |
-
"
|
258 |
" \n",
|
259 |
-
"
|
260 |
-
"
|
261 |
-
"
|
262 |
-
"
|
263 |
-
"
|
264 |
" \n",
|
265 |
-
"
|
266 |
-
"
|
267 |
-
"
|
|
|
|
|
268 |
" pass\n",
|
269 |
-
"
|
270 |
-
"
|
271 |
-
"
|
272 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
273 |
" fig = go.Figure(go.Mesh3d(\n",
|
274 |
-
" x=
|
275 |
" i=f_matrix[:,0], j=f_matrix[:,1], k=f_matrix[:,2], \n",
|
276 |
" color='red'))\n",
|
|
|
|
|
|
|
|
|
|
|
277 |
" \n",
|
278 |
" fig.update_layout(\n",
|
279 |
-
"
|
280 |
-
"
|
281 |
-
"
|
282 |
-
"
|
283 |
-
"
|
284 |
-
"
|
285 |
-
"
|
|
|
|
|
286 |
" fig2 = go.Figure(go.Mesh3d(\n",
|
287 |
" x=v_matrix_2[:,0], y=v_matrix_2[:,1], z=v_matrix_2[:,2], \n",
|
288 |
" i=f_matrix_2[:,0], j=f_matrix_2[:,1], k=f_matrix_2[:,2], \n",
|
289 |
" color='red'))\n",
|
290 |
" \n",
|
291 |
-
" fig2.update_layout(\n",
|
292 |
-
" scene = dict(\n",
|
293 |
-
" xaxis = dict(visible=False),\n",
|
294 |
-
" yaxis = dict(visible=False),\n",
|
295 |
-
" zaxis =dict(visible=False)\n",
|
296 |
-
" )\n",
|
297 |
-
" )\n",
|
298 |
-
" o3d.io.write_triangle_mesh(\"output.obj\", mesh_o3d)\n",
|
299 |
-
" plotTree(generated_images, True)\n",
|
300 |
"\n",
|
|
|
301 |
" #o3d.io.write_triangle_mesh(\"generadas/\"+filename.split(\"_\")[0]+\".obj\", mesh_o3d)\n",
|
302 |
-
" return fig"
|
303 |
]
|
304 |
},
|
305 |
{
|
306 |
"cell_type": "code",
|
307 |
-
"execution_count":
|
308 |
"metadata": {},
|
309 |
"outputs": [
|
310 |
{
|
311 |
"name": "stdout",
|
312 |
"output_type": "stream",
|
313 |
"text": [
|
314 |
-
"Running on local URL: http://127.0.0.1:
|
315 |
-
"
|
316 |
-
|
317 |
-
},
|
318 |
-
{
|
319 |
-
"data": {
|
320 |
-
"application/vnd.jupyter.widget-view+json": {
|
321 |
-
"model_id": "a7c9d42f5242485e92437771b60ab88c",
|
322 |
-
"version_major": 2,
|
323 |
-
"version_minor": 0
|
324 |
-
},
|
325 |
-
"text/plain": [
|
326 |
-
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(-0.003762…"
|
327 |
-
]
|
328 |
-
},
|
329 |
-
"metadata": {},
|
330 |
-
"output_type": "display_data"
|
331 |
-
},
|
332 |
-
{
|
333 |
-
"name": "stdout",
|
334 |
-
"output_type": "stream",
|
335 |
-
"text": [
|
336 |
-
"generated images <modelovae.Node object at 0x000001F3B5E47130>\n"
|
337 |
-
]
|
338 |
-
},
|
339 |
-
{
|
340 |
-
"data": {
|
341 |
-
"application/vnd.jupyter.widget-view+json": {
|
342 |
-
"model_id": "0beb7306167340709957143fe3d8412d",
|
343 |
-
"version_major": 2,
|
344 |
-
"version_minor": 0
|
345 |
-
},
|
346 |
-
"text/plain": [
|
347 |
-
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(0.4200476…"
|
348 |
-
]
|
349 |
-
},
|
350 |
-
"metadata": {},
|
351 |
-
"output_type": "display_data"
|
352 |
-
},
|
353 |
-
{
|
354 |
-
"name": "stdout",
|
355 |
-
"output_type": "stream",
|
356 |
-
"text": [
|
357 |
-
"generated images <modelovae.Node object at 0x000001F3B5E47820>\n"
|
358 |
-
]
|
359 |
-
},
|
360 |
-
{
|
361 |
-
"data": {
|
362 |
-
"application/vnd.jupyter.widget-view+json": {
|
363 |
-
"model_id": "15699e29642b4c969757709a93569c09",
|
364 |
-
"version_major": 2,
|
365 |
-
"version_minor": 0
|
366 |
-
},
|
367 |
-
"text/plain": [
|
368 |
-
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(-0.002811…"
|
369 |
-
]
|
370 |
-
},
|
371 |
-
"metadata": {},
|
372 |
-
"output_type": "display_data"
|
373 |
-
},
|
374 |
-
{
|
375 |
-
"name": "stdout",
|
376 |
-
"output_type": "stream",
|
377 |
-
"text": [
|
378 |
-
"generated images <modelovae.Node object at 0x000001F3B8AA2F50>\n"
|
379 |
-
]
|
380 |
-
},
|
381 |
-
{
|
382 |
-
"data": {
|
383 |
-
"application/vnd.jupyter.widget-view+json": {
|
384 |
-
"model_id": "e8f7321033e74f2cb61d0830f179ce4a",
|
385 |
-
"version_major": 2,
|
386 |
-
"version_minor": 0
|
387 |
-
},
|
388 |
-
"text/plain": [
|
389 |
-
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(0.4228083…"
|
390 |
-
]
|
391 |
-
},
|
392 |
-
"metadata": {},
|
393 |
-
"output_type": "display_data"
|
394 |
-
},
|
395 |
-
{
|
396 |
-
"name": "stdout",
|
397 |
-
"output_type": "stream",
|
398 |
-
"text": [
|
399 |
-
"generated images <modelovae.Node object at 0x000001F3B8AF30D0>\n"
|
400 |
-
]
|
401 |
-
},
|
402 |
-
{
|
403 |
-
"data": {
|
404 |
-
"application/vnd.jupyter.widget-view+json": {
|
405 |
-
"model_id": "e45f9cfb42a742928111bd96c0bea6c8",
|
406 |
-
"version_major": 2,
|
407 |
-
"version_minor": 0
|
408 |
-
},
|
409 |
-
"text/plain": [
|
410 |
-
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(0.2544228…"
|
411 |
-
]
|
412 |
-
},
|
413 |
-
"metadata": {},
|
414 |
-
"output_type": "display_data"
|
415 |
-
},
|
416 |
-
{
|
417 |
-
"name": "stdout",
|
418 |
-
"output_type": "stream",
|
419 |
-
"text": [
|
420 |
-
"generated images <modelovae.Node object at 0x000001F3B8AA35B0>\n"
|
421 |
-
]
|
422 |
-
},
|
423 |
-
{
|
424 |
-
"data": {
|
425 |
-
"application/vnd.jupyter.widget-view+json": {
|
426 |
-
"model_id": "e8b93804c83f437ba86dfb28fc839eda",
|
427 |
-
"version_major": 2,
|
428 |
-
"version_minor": 0
|
429 |
-
},
|
430 |
-
"text/plain": [
|
431 |
-
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(0.2635734…"
|
432 |
-
]
|
433 |
-
},
|
434 |
-
"metadata": {},
|
435 |
-
"output_type": "display_data"
|
436 |
-
},
|
437 |
-
{
|
438 |
-
"name": "stdout",
|
439 |
-
"output_type": "stream",
|
440 |
-
"text": [
|
441 |
-
"generated images <modelovae.Node object at 0x000001F3B8AF09A0>\n"
|
442 |
-
]
|
443 |
-
},
|
444 |
-
{
|
445 |
-
"data": {
|
446 |
-
"application/vnd.jupyter.widget-view+json": {
|
447 |
-
"model_id": "7a670daef41b4e1a8aad5cab83ac220c",
|
448 |
-
"version_major": 2,
|
449 |
-
"version_minor": 0
|
450 |
-
},
|
451 |
-
"text/plain": [
|
452 |
-
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(0.5811820…"
|
453 |
-
]
|
454 |
-
},
|
455 |
-
"metadata": {},
|
456 |
-
"output_type": "display_data"
|
457 |
-
},
|
458 |
-
{
|
459 |
-
"name": "stdout",
|
460 |
-
"output_type": "stream",
|
461 |
-
"text": [
|
462 |
-
"generated images <modelovae.Node object at 0x000001F3B8AF07F0>\n"
|
463 |
-
]
|
464 |
-
},
|
465 |
-
{
|
466 |
-
"data": {
|
467 |
-
"application/vnd.jupyter.widget-view+json": {
|
468 |
-
"model_id": "4a0fa599af6846d299e6868130c17a2b",
|
469 |
-
"version_major": 2,
|
470 |
-
"version_minor": 0
|
471 |
-
},
|
472 |
-
"text/plain": [
|
473 |
-
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(0.3441835…"
|
474 |
-
]
|
475 |
-
},
|
476 |
-
"metadata": {},
|
477 |
-
"output_type": "display_data"
|
478 |
-
},
|
479 |
-
{
|
480 |
-
"name": "stdout",
|
481 |
-
"output_type": "stream",
|
482 |
-
"text": [
|
483 |
-
"generated images <modelovae.Node object at 0x000001F3B8AA2F50>\n"
|
484 |
]
|
485 |
},
|
486 |
{
|
487 |
"data": {
|
488 |
-
"
|
489 |
-
"
|
490 |
-
|
491 |
-
"version_minor": 0
|
492 |
-
},
|
493 |
"text/plain": [
|
494 |
-
"
|
495 |
]
|
496 |
},
|
497 |
"metadata": {},
|
498 |
"output_type": "display_data"
|
499 |
},
|
500 |
-
{
|
501 |
-
"name": "stdout",
|
502 |
-
"output_type": "stream",
|
503 |
-
"text": [
|
504 |
-
"generated images <modelovae.Node object at 0x000001F3B8A18F10>\n"
|
505 |
-
]
|
506 |
-
},
|
507 |
{
|
508 |
"data": {
|
509 |
-
"
|
510 |
-
"model_id": "2f112a2375f74531954a5bc3d4de338e",
|
511 |
-
"version_major": 2,
|
512 |
-
"version_minor": 0
|
513 |
-
},
|
514 |
-
"text/plain": [
|
515 |
-
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(0.3513652…"
|
516 |
-
]
|
517 |
},
|
|
|
518 |
"metadata": {},
|
519 |
-
"output_type": "
|
520 |
-
},
|
521 |
-
{
|
522 |
-
"name": "stdout",
|
523 |
-
"output_type": "stream",
|
524 |
-
"text": [
|
525 |
-
"generated images <modelovae.Node object at 0x000001F3B8C315A0>\n"
|
526 |
-
]
|
527 |
},
|
528 |
{
|
529 |
"data": {
|
530 |
"application/vnd.jupyter.widget-view+json": {
|
531 |
-
"model_id": "
|
532 |
"version_major": 2,
|
533 |
"version_minor": 0
|
534 |
},
|
535 |
"text/plain": [
|
536 |
-
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(0.
|
537 |
]
|
538 |
},
|
539 |
"metadata": {},
|
540 |
"output_type": "display_data"
|
541 |
},
|
542 |
-
{
|
543 |
-
"name": "stdout",
|
544 |
-
"output_type": "stream",
|
545 |
-
"text": [
|
546 |
-
"generated images <modelovae.Node object at 0x000001F3B8C566E0>\n"
|
547 |
-
]
|
548 |
-
},
|
549 |
{
|
550 |
"data": {
|
551 |
"application/vnd.jupyter.widget-view+json": {
|
552 |
-
"model_id": "
|
553 |
"version_major": 2,
|
554 |
"version_minor": 0
|
555 |
},
|
556 |
"text/plain": [
|
557 |
-
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(0.
|
558 |
]
|
559 |
},
|
560 |
"metadata": {},
|
561 |
"output_type": "display_data"
|
562 |
},
|
563 |
-
{
|
564 |
-
"name": "stdout",
|
565 |
-
"output_type": "stream",
|
566 |
-
"text": [
|
567 |
-
"generated images <modelovae.Node object at 0x000001F3B8A70B20>\n"
|
568 |
-
]
|
569 |
-
},
|
570 |
{
|
571 |
"data": {
|
572 |
"application/vnd.jupyter.widget-view+json": {
|
573 |
-
"model_id": "
|
574 |
"version_major": 2,
|
575 |
"version_minor": 0
|
576 |
},
|
577 |
"text/plain": [
|
578 |
-
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(0.
|
579 |
]
|
580 |
},
|
581 |
"metadata": {},
|
582 |
"output_type": "display_data"
|
583 |
},
|
584 |
-
{
|
585 |
-
"name": "stdout",
|
586 |
-
"output_type": "stream",
|
587 |
-
"text": [
|
588 |
-
"generated images <modelovae.Node object at 0x000001F3B8CE1270>\n"
|
589 |
-
]
|
590 |
-
},
|
591 |
{
|
592 |
"data": {
|
593 |
"application/vnd.jupyter.widget-view+json": {
|
594 |
-
"model_id": "
|
595 |
"version_major": 2,
|
596 |
"version_minor": 0
|
597 |
},
|
598 |
"text/plain": [
|
599 |
-
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(0.
|
600 |
]
|
601 |
},
|
602 |
"metadata": {},
|
@@ -606,37 +425,22 @@
|
|
606 |
"name": "stdout",
|
607 |
"output_type": "stream",
|
608 |
"text": [
|
609 |
-
"
|
610 |
]
|
611 |
},
|
612 |
{
|
613 |
"data": {
|
614 |
"application/vnd.jupyter.widget-view+json": {
|
615 |
-
"model_id": "
|
616 |
"version_major": 2,
|
617 |
"version_minor": 0
|
618 |
},
|
619 |
"text/plain": [
|
620 |
-
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(0.
|
621 |
]
|
622 |
},
|
623 |
"metadata": {},
|
624 |
"output_type": "display_data"
|
625 |
-
},
|
626 |
-
{
|
627 |
-
"ename": "KeyboardInterrupt",
|
628 |
-
"evalue": "",
|
629 |
-
"output_type": "error",
|
630 |
-
"traceback": [
|
631 |
-
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
632 |
-
"\u001b[1;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
|
633 |
-
"Cell \u001b[1;32mIn[17], line 12\u001b[0m\n\u001b[0;32m 9\u001b[0m checkpoint \u001b[39m=\u001b[39m torch\u001b[39m.\u001b[39mload(\u001b[39m\"\u001b[39m\u001b[39m64.pth\u001b[39m\u001b[39m\"\u001b[39m, map_location\u001b[39m=\u001b[39mtorch\u001b[39m.\u001b[39mdevice(\u001b[39m'\u001b[39m\u001b[39mcpu\u001b[39m\u001b[39m'\u001b[39m))\n\u001b[0;32m 10\u001b[0m Grassdecoder\u001b[39m.\u001b[39mload_state_dict(checkpoint[\u001b[39m'\u001b[39m\u001b[39mdecoder_state_dict\u001b[39m\u001b[39m'\u001b[39m])\n\u001b[1;32m---> 12\u001b[0m gr\u001b[39m.\u001b[39;49mInterface( predict, \n\u001b[0;32m 13\u001b[0m inputs\u001b[39m=\u001b[39;49m\u001b[39mNone\u001b[39;49;00m,\n\u001b[0;32m 14\u001b[0m outputs\u001b[39m=\u001b[39;49mgr\u001b[39m.\u001b[39;49mPlot()\n\u001b[0;32m 15\u001b[0m )\u001b[39m.\u001b[39;49mlaunch(share \u001b[39m=\u001b[39;49m \u001b[39mTrue\u001b[39;49;00m)\n",
|
634 |
-
"File \u001b[1;32mc:\\Users\\User\\anaconda3\\envs\\py_torch\\lib\\site-packages\\gradio\\blocks.py:2005\u001b[0m, in \u001b[0;36mBlocks.launch\u001b[1;34m(self, inline, inbrowser, share, debug, enable_queue, max_threads, auth, auth_message, prevent_thread_lock, show_error, server_name, server_port, show_tips, height, width, encrypt, favicon_path, ssl_keyfile, ssl_certfile, ssl_keyfile_password, ssl_verify, quiet, show_api, file_directories, allowed_paths, blocked_paths, root_path, _frontend, app_kwargs)\u001b[0m\n\u001b[0;32m 2003\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m 2004\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mshare_url \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[1;32m-> 2005\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mshare_url \u001b[39m=\u001b[39m networking\u001b[39m.\u001b[39;49msetup_tunnel(\n\u001b[0;32m 2006\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mserver_name, \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mserver_port, \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mshare_token\n\u001b[0;32m 2007\u001b[0m )\n\u001b[0;32m 2008\u001b[0m \u001b[39mprint\u001b[39m(strings\u001b[39m.\u001b[39men[\u001b[39m\"\u001b[39m\u001b[39mSHARE_LINK_DISPLAY\u001b[39m\u001b[39m\"\u001b[39m]\u001b[39m.\u001b[39mformat(\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mshare_url))\n\u001b[0;32m 2009\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mnot\u001b[39;00m (quiet):\n",
|
635 |
-
"File \u001b[1;32mc:\\Users\\User\\anaconda3\\envs\\py_torch\\lib\\site-packages\\gradio\\networking.py:228\u001b[0m, in \u001b[0;36msetup_tunnel\u001b[1;34m(local_host, local_port, share_token)\u001b[0m\n\u001b[0;32m 224\u001b[0m remote_host, remote_port \u001b[39m=\u001b[39m payload[\u001b[39m\"\u001b[39m\u001b[39mhost\u001b[39m\u001b[39m\"\u001b[39m], \u001b[39mint\u001b[39m(payload[\u001b[39m\"\u001b[39m\u001b[39mport\u001b[39m\u001b[39m\"\u001b[39m])\n\u001b[0;32m 225\u001b[0m tunnel \u001b[39m=\u001b[39m Tunnel(\n\u001b[0;32m 226\u001b[0m remote_host, remote_port, local_host, local_port, share_token\n\u001b[0;32m 227\u001b[0m )\n\u001b[1;32m--> 228\u001b[0m address \u001b[39m=\u001b[39m tunnel\u001b[39m.\u001b[39;49mstart_tunnel()\n\u001b[0;32m 229\u001b[0m \u001b[39mreturn\u001b[39;00m address\n\u001b[0;32m 230\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mException\u001b[39;00m \u001b[39mas\u001b[39;00m e:\n",
|
636 |
-
"File \u001b[1;32mc:\\Users\\User\\anaconda3\\envs\\py_torch\\lib\\site-packages\\gradio\\tunneling.py:59\u001b[0m, in \u001b[0;36mTunnel.start_tunnel\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 57\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mstart_tunnel\u001b[39m(\u001b[39mself\u001b[39m) \u001b[39m-\u001b[39m\u001b[39m>\u001b[39m \u001b[39mstr\u001b[39m:\n\u001b[0;32m 58\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mdownload_binary()\n\u001b[1;32m---> 59\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39murl \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_start_tunnel(BINARY_PATH)\n\u001b[0;32m 60\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39murl\n",
|
637 |
-
"File \u001b[1;32mc:\\Users\\User\\anaconda3\\envs\\py_torch\\lib\\site-packages\\gradio\\tunneling.py:95\u001b[0m, in \u001b[0;36mTunnel._start_tunnel\u001b[1;34m(self, binary)\u001b[0m\n\u001b[0;32m 93\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mproc\u001b[39m.\u001b[39mstdout \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[0;32m 94\u001b[0m \u001b[39mcontinue\u001b[39;00m\n\u001b[1;32m---> 95\u001b[0m line \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mproc\u001b[39m.\u001b[39;49mstdout\u001b[39m.\u001b[39;49mreadline()\n\u001b[0;32m 96\u001b[0m line \u001b[39m=\u001b[39m line\u001b[39m.\u001b[39mdecode(\u001b[39m\"\u001b[39m\u001b[39mutf-8\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[0;32m 97\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39m\"\u001b[39m\u001b[39mstart proxy success\u001b[39m\u001b[39m\"\u001b[39m \u001b[39min\u001b[39;00m line:\n",
|
638 |
-
"\u001b[1;31mKeyboardInterrupt\u001b[0m: "
|
639 |
-
]
|
640 |
}
|
641 |
],
|
642 |
"source": [
|
@@ -648,7 +452,7 @@
|
|
648 |
"\n",
|
649 |
"Grassdecoder.eval()\n",
|
650 |
"\n",
|
651 |
-
"checkpoint = torch.load(\"
|
652 |
"Grassdecoder.load_state_dict(checkpoint['decoder_state_dict'])\n",
|
653 |
"\n",
|
654 |
"gr.Interface( predict, \n",
|
|
|
2 |
"cells": [
|
3 |
{
|
4 |
"cell_type": "code",
|
5 |
+
"execution_count": 6,
|
6 |
"metadata": {},
|
7 |
"outputs": [],
|
8 |
"source": [
|
|
|
20 |
"import os\n",
|
21 |
"from resamplear import *\n",
|
22 |
"import open3d as o3d\n",
|
23 |
+
"from vedo import *\n",
|
24 |
+
"from meshSubplot import plotTree"
|
|
|
25 |
]
|
26 |
},
|
27 |
{
|
28 |
"cell_type": "code",
|
29 |
+
"execution_count": 7,
|
30 |
"metadata": {},
|
31 |
"outputs": [],
|
32 |
"source": [
|
|
|
138 |
},
|
139 |
{
|
140 |
"cell_type": "code",
|
141 |
+
"execution_count": 8,
|
142 |
"metadata": {},
|
143 |
"outputs": [],
|
144 |
"source": [
|
|
|
203 |
"\n",
|
204 |
"def prepararAristas( grafo ):\n",
|
205 |
" for arista in grafo.edges():\n",
|
206 |
+
" nx.set_edge_attributes( grafo, {arista : {'procesada':False}})\n",
|
207 |
+
"\n",
|
208 |
+
"def traversefeatures(root, features):\n",
|
209 |
+
" \n",
|
210 |
+
" if root is not None:\n",
|
211 |
+
" traversefeatures(root.left, features)\n",
|
212 |
+
" features.append(root.radius.tolist()[0][3])\n",
|
213 |
+
" traversefeatures(root.right, features)\n",
|
214 |
+
" return features\n"
|
|
|
|
|
|
|
215 |
]
|
216 |
},
|
217 |
{
|
218 |
"cell_type": "code",
|
219 |
+
"execution_count": 9,
|
220 |
"metadata": {},
|
221 |
"outputs": [],
|
222 |
"source": [
|
|
|
228 |
" \n",
|
229 |
" z = torch.randn(1, latent_size)\n",
|
230 |
" generated_images = decode_testing(z, 100, Grassdecoder, mult, 1)\n",
|
|
|
231 |
" count = []\n",
|
232 |
" numerar_nodos(generated_images, count)\n",
|
233 |
+
" plotTree(generated_images, True)\n",
|
234 |
" #tr(generated_images)\n",
|
235 |
" generated_images.toGraph( G, 0, True, flag = 0)\n",
|
236 |
+
" r_list = []\n",
|
237 |
+
" r_list = traversefeatures(generated_images, r_list)\n",
|
238 |
+
" max_radius = max(r_list)\n",
|
239 |
+
" min_radius = min(r_list)\n",
|
240 |
+
" \n",
|
241 |
+
" '''\n",
|
242 |
+
" #generated_images = iter(data_loader).next()[0]\n",
|
243 |
+
" generated_images = next(iter(data_loader))[0]\n",
|
244 |
+
" filename = generated_images[1]\n",
|
245 |
+
" print(\"filename\", filename)\n",
|
246 |
+
" bifurcation_nodes = []\n",
|
247 |
+
" leaf_nodes = []\n",
|
248 |
+
" \n",
|
249 |
+
" generated_images[0].toGraph( G, 0, False, 0)\n",
|
250 |
+
" \n",
|
251 |
+
" \n",
|
252 |
+
" generated_images = generated_images[0]\n",
|
253 |
+
" original_mesh = load(\"mallas/\"+filename.split(\"_\")[0]+\".obj\")\n",
|
254 |
+
" write(original_mesh, \"original.obj\")\n",
|
255 |
+
" #generated_images.toGraph( graph, 0, False, flag = 0)\n",
|
256 |
+
" #tr2(generated_images)\n",
|
257 |
+
" '''\n",
|
258 |
" \n",
|
259 |
" #nx.write_gpickle(graph, \"grafo0.gpickle\" )\n",
|
260 |
" for arista in G.edges():\n",
|
261 |
" nx.set_edge_attributes( G, {arista : {'procesada':False}})\n",
|
262 |
+
" #graph_resampled = resamplear(G, puntosPorUnidad=5)\n",
|
263 |
" graph_resampled = G\n",
|
264 |
" prepararAristas(graph_resampled)\n",
|
265 |
" graphOfCenters = GrafoCentros(graph_resampled)\n",
|
266 |
" \n",
|
267 |
+
" if abs(max_radius/min_radius)<10:\n",
|
268 |
+
" try:\n",
|
269 |
+
" graphOfCenters.tile()\n",
|
270 |
+
" mesh = tm.Trimesh( graphOfCenters.getVertices(), graphOfCenters.getCaras() )\n",
|
271 |
+
" mesh_o3d = mesh.as_open3d\n",
|
272 |
+
" m2 = mesh_o3d \n",
|
273 |
+
" o3d.io.write_triangle_mesh(\"sinsub.obj\", m2)\n",
|
274 |
+
" mesh_o3d = mesh_o3d.subdivide_loop(3)\n",
|
275 |
" \n",
|
276 |
+
" v_matrix = np.asarray(mesh_o3d.vertices )\n",
|
277 |
+
" f_matrix = np.asarray(mesh_o3d.triangles )\n",
|
278 |
+
" v_matrix_2 = np.asarray(m2.vertices )\n",
|
279 |
+
" f_matrix_2 = np.asarray(m2.triangles )\n",
|
280 |
+
" success = True\n",
|
281 |
" \n",
|
282 |
+
" except Exception as e:\n",
|
283 |
+
" print(\"No se pudo generar\")\n",
|
284 |
+
" pass\n",
|
285 |
+
" else:\n",
|
286 |
+
" print(\"ratio\", max_radius/min_radius)\n",
|
287 |
" pass\n",
|
288 |
+
" '''\n",
|
289 |
+
" M = max((max(v_matrix[:,0]) - min(v_matrix[:,0])), (max(v_matrix[:,1]) - min(v_matrix[:,1])), (max(v_matrix[:,2]) - min(v_matrix[:,2])))\n",
|
290 |
+
" x = (v_matrix[:,0] - min(v_matrix[:,0]))/M\n",
|
291 |
+
" y = (v_matrix[:,1] - min(v_matrix[:,1]))/ M\n",
|
292 |
+
" z = (v_matrix[:,2] - min(v_matrix[:,2]))/M\n",
|
293 |
+
" '''\n",
|
294 |
+
"\n",
|
295 |
+
" M = max((max(v_matrix[:,0]) - min(v_matrix[:,0])), (max(v_matrix[:,1]) - min(v_matrix[:,1])), (max(v_matrix[:,2]) - min(v_matrix[:,2])))\n",
|
296 |
+
" x = (v_matrix[:,0] - np.mean(v_matrix[:,0]))/M\n",
|
297 |
+
" y = (v_matrix[:,1] - np.mean(v_matrix[:,1]))/ M\n",
|
298 |
+
" z = (v_matrix[:,2] - np.mean(v_matrix[:,2]))/M\n",
|
299 |
+
"\n",
|
300 |
+
" minimo = min(min(x), min(y), min(z))\n",
|
301 |
+
" maximo = max(max(x), max(y), max(z))\n",
|
302 |
+
" \n",
|
303 |
" fig = go.Figure(go.Mesh3d(\n",
|
304 |
+
" x=x, y=y, z=z, \n",
|
305 |
" i=f_matrix[:,0], j=f_matrix[:,1], k=f_matrix[:,2], \n",
|
306 |
" color='red'))\n",
|
307 |
+
"\n",
|
308 |
+
" m = go.Mesh3d(\n",
|
309 |
+
" x=v_matrix[:,0], y=v_matrix[:,1], z=v_matrix[:,2], \n",
|
310 |
+
" i=f_matrix[:,0], j=f_matrix[:,1], k=f_matrix[:,2], \n",
|
311 |
+
" color='red')\n",
|
312 |
" \n",
|
313 |
" fig.update_layout(\n",
|
314 |
+
" scene = dict(\n",
|
315 |
+
" xaxis_range=[minimo, maximo],\n",
|
316 |
+
" yaxis_range=[minimo, maximo],\n",
|
317 |
+
" zaxis_range=[minimo, maximo],\n",
|
318 |
+
" aspectratio=dict(x = 1, y = 1, z = 1),\n",
|
319 |
+
" xaxis = dict(visible=False),\n",
|
320 |
+
" yaxis = dict(visible=False),\n",
|
321 |
+
" zaxis =dict(visible=False),\n",
|
322 |
+
" ))\n",
|
323 |
" fig2 = go.Figure(go.Mesh3d(\n",
|
324 |
" x=v_matrix_2[:,0], y=v_matrix_2[:,1], z=v_matrix_2[:,2], \n",
|
325 |
" i=f_matrix_2[:,0], j=f_matrix_2[:,1], k=f_matrix_2[:,2], \n",
|
326 |
" color='red'))\n",
|
327 |
" \n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
328 |
"\n",
|
329 |
+
" o3d.io.write_triangle_mesh(\"output.obj\", mesh_o3d)\n",
|
330 |
" #o3d.io.write_triangle_mesh(\"generadas/\"+filename.split(\"_\")[0]+\".obj\", mesh_o3d)\n",
|
331 |
+
" return fig\n"
|
332 |
]
|
333 |
},
|
334 |
{
|
335 |
"cell_type": "code",
|
336 |
+
"execution_count": 10,
|
337 |
"metadata": {},
|
338 |
"outputs": [
|
339 |
{
|
340 |
"name": "stdout",
|
341 |
"output_type": "stream",
|
342 |
"text": [
|
343 |
+
"Running on local URL: http://127.0.0.1:7861\n",
|
344 |
+
"\n",
|
345 |
+
"To create a public link, set `share=True` in `launch()`.\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
346 |
]
|
347 |
},
|
348 |
{
|
349 |
"data": {
|
350 |
+
"text/html": [
|
351 |
+
"<div><iframe src=\"http://127.0.0.1:7861/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
|
352 |
+
],
|
|
|
|
|
353 |
"text/plain": [
|
354 |
+
"<IPython.core.display.HTML object>"
|
355 |
]
|
356 |
},
|
357 |
"metadata": {},
|
358 |
"output_type": "display_data"
|
359 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
360 |
{
|
361 |
"data": {
|
362 |
+
"text/plain": []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
363 |
},
|
364 |
+
"execution_count": 10,
|
365 |
"metadata": {},
|
366 |
+
"output_type": "execute_result"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
367 |
},
|
368 |
{
|
369 |
"data": {
|
370 |
"application/vnd.jupyter.widget-view+json": {
|
371 |
+
"model_id": "65a760af40bf45d587e9431bfb1a1bb3",
|
372 |
"version_major": 2,
|
373 |
"version_minor": 0
|
374 |
},
|
375 |
"text/plain": [
|
376 |
+
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(0.4971382…"
|
377 |
]
|
378 |
},
|
379 |
"metadata": {},
|
380 |
"output_type": "display_data"
|
381 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
382 |
{
|
383 |
"data": {
|
384 |
"application/vnd.jupyter.widget-view+json": {
|
385 |
+
"model_id": "4d4cd747115c4c67924a26739200aae7",
|
386 |
"version_major": 2,
|
387 |
"version_minor": 0
|
388 |
},
|
389 |
"text/plain": [
|
390 |
+
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(-0.000256…"
|
391 |
]
|
392 |
},
|
393 |
"metadata": {},
|
394 |
"output_type": "display_data"
|
395 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
396 |
{
|
397 |
"data": {
|
398 |
"application/vnd.jupyter.widget-view+json": {
|
399 |
+
"model_id": "48ea3f83128d4a6da225a5c9e53fcee6",
|
400 |
"version_major": 2,
|
401 |
"version_minor": 0
|
402 |
},
|
403 |
"text/plain": [
|
404 |
+
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(0.7299671…"
|
405 |
]
|
406 |
},
|
407 |
"metadata": {},
|
408 |
"output_type": "display_data"
|
409 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
410 |
{
|
411 |
"data": {
|
412 |
"application/vnd.jupyter.widget-view+json": {
|
413 |
+
"model_id": "e0634d6c173b40959725335707e53957",
|
414 |
"version_major": 2,
|
415 |
"version_minor": 0
|
416 |
},
|
417 |
"text/plain": [
|
418 |
+
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(0.9065635…"
|
419 |
]
|
420 |
},
|
421 |
"metadata": {},
|
|
|
425 |
"name": "stdout",
|
426 |
"output_type": "stream",
|
427 |
"text": [
|
428 |
+
"ratio 13.516594372719945\n"
|
429 |
]
|
430 |
},
|
431 |
{
|
432 |
"data": {
|
433 |
"application/vnd.jupyter.widget-view+json": {
|
434 |
+
"model_id": "d63e52ba4fc4439b8a0e4ecad9be258e",
|
435 |
"version_major": 2,
|
436 |
"version_minor": 0
|
437 |
},
|
438 |
"text/plain": [
|
439 |
+
"Renderer(camera=PerspectiveCamera(children=(DirectionalLight(color='white', intensity=0.6, position=(0.0338801…"
|
440 |
]
|
441 |
},
|
442 |
"metadata": {},
|
443 |
"output_type": "display_data"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
444 |
}
|
445 |
],
|
446 |
"source": [
|
|
|
452 |
"\n",
|
453 |
"Grassdecoder.eval()\n",
|
454 |
"\n",
|
455 |
+
"checkpoint = torch.load(\"modelo-bet-nuevacc.pth\", map_location=torch.device('cpu'))\n",
|
456 |
"Grassdecoder.load_state_dict(checkpoint['decoder_state_dict'])\n",
|
457 |
"\n",
|
458 |
"gr.Interface( predict, \n",
|
app.py
CHANGED
@@ -119,6 +119,14 @@ def tr2(root):
|
|
119 |
use_gpu = True
|
120 |
device = torch.device("cuda:0" if use_gpu and torch.cuda.is_available() else "cpu")
|
121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
def my_collate(batch):
|
123 |
return batch
|
124 |
|
@@ -194,12 +202,16 @@ def predict():
|
|
194 |
|
195 |
z = torch.randn(1, latent_size)
|
196 |
generated_images = decode_testing(z, 100, Grassdecoder, mult, 1)
|
197 |
-
print("generated images", generated_images)
|
198 |
count = []
|
199 |
numerar_nodos(generated_images, count)
|
|
|
200 |
#tr(generated_images)
|
201 |
generated_images.toGraph( G, 0, True, flag = 0)
|
202 |
-
|
|
|
|
|
|
|
|
|
203 |
'''
|
204 |
#generated_images = iter(data_loader).next()[0]
|
205 |
generated_images = next(iter(data_loader))[0]
|
@@ -221,36 +233,48 @@ def predict():
|
|
221 |
#nx.write_gpickle(graph, "grafo0.gpickle" )
|
222 |
for arista in G.edges():
|
223 |
nx.set_edge_attributes( G, {arista : {'procesada':False}})
|
224 |
-
graph_resampled = resamplear(G, puntosPorUnidad=5)
|
225 |
graph_resampled = G
|
226 |
prepararAristas(graph_resampled)
|
227 |
graphOfCenters = GrafoCentros(graph_resampled)
|
228 |
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
|
244 |
-
|
245 |
-
|
246 |
-
|
|
|
|
|
|
|
247 |
pass
|
248 |
-
|
249 |
M = max((max(v_matrix[:,0]) - min(v_matrix[:,0])), (max(v_matrix[:,1]) - min(v_matrix[:,1])), (max(v_matrix[:,2]) - min(v_matrix[:,2])))
|
250 |
x = (v_matrix[:,0] - min(v_matrix[:,0]))/M
|
251 |
y = (v_matrix[:,1] - min(v_matrix[:,1]))/ M
|
252 |
z = (v_matrix[:,2] - min(v_matrix[:,2]))/M
|
|
|
253 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
fig = go.Figure(go.Mesh3d(
|
255 |
x=x, y=y, z=z,
|
256 |
i=f_matrix[:,0], j=f_matrix[:,1], k=f_matrix[:,2],
|
@@ -263,9 +287,9 @@ def predict():
|
|
263 |
|
264 |
fig.update_layout(
|
265 |
scene = dict(
|
266 |
-
xaxis_range=[
|
267 |
-
yaxis_range=[
|
268 |
-
zaxis_range=[
|
269 |
aspectratio=dict(x = 1, y = 1, z = 1),
|
270 |
xaxis = dict(visible=False),
|
271 |
yaxis = dict(visible=False),
|
@@ -281,9 +305,10 @@ def predict():
|
|
281 |
#o3d.io.write_triangle_mesh("generadas/"+filename.split("_")[0]+".obj", mesh_o3d)
|
282 |
return fig
|
283 |
|
|
|
284 |
a = [1.,1.,1.]
|
285 |
mult = torch.Tensor(a)
|
286 |
-
latent_size =
|
287 |
Grassdecoder = GRASSDecoder(latent_size=latent_size, hidden_size=256, mult = mult)
|
288 |
Grassdecoder = Grassdecoder
|
289 |
|
|
|
119 |
use_gpu = True
|
120 |
device = torch.device("cuda:0" if use_gpu and torch.cuda.is_available() else "cpu")
|
121 |
|
122 |
+
def traversefeatures(root, features):
|
123 |
+
|
124 |
+
if root is not None:
|
125 |
+
traversefeatures(root.left, features)
|
126 |
+
features.append(root.radius.tolist()[0][3])
|
127 |
+
traversefeatures(root.right, features)
|
128 |
+
return features
|
129 |
+
|
130 |
def my_collate(batch):
|
131 |
return batch
|
132 |
|
|
|
202 |
|
203 |
z = torch.randn(1, latent_size)
|
204 |
generated_images = decode_testing(z, 100, Grassdecoder, mult, 1)
|
|
|
205 |
count = []
|
206 |
numerar_nodos(generated_images, count)
|
207 |
+
plotTree(generated_images, True)
|
208 |
#tr(generated_images)
|
209 |
generated_images.toGraph( G, 0, True, flag = 0)
|
210 |
+
r_list = []
|
211 |
+
r_list = traversefeatures(generated_images, r_list)
|
212 |
+
max_radius = max(r_list)
|
213 |
+
min_radius = min(r_list)
|
214 |
+
|
215 |
'''
|
216 |
#generated_images = iter(data_loader).next()[0]
|
217 |
generated_images = next(iter(data_loader))[0]
|
|
|
233 |
#nx.write_gpickle(graph, "grafo0.gpickle" )
|
234 |
for arista in G.edges():
|
235 |
nx.set_edge_attributes( G, {arista : {'procesada':False}})
|
236 |
+
#graph_resampled = resamplear(G, puntosPorUnidad=5)
|
237 |
graph_resampled = G
|
238 |
prepararAristas(graph_resampled)
|
239 |
graphOfCenters = GrafoCentros(graph_resampled)
|
240 |
|
241 |
+
if abs(max_radius/min_radius)<10:
|
242 |
+
try:
|
243 |
+
graphOfCenters.tile()
|
244 |
+
mesh = tm.Trimesh( graphOfCenters.getVertices(), graphOfCenters.getCaras() )
|
245 |
+
mesh_o3d = mesh.as_open3d
|
246 |
+
m2 = mesh_o3d
|
247 |
+
o3d.io.write_triangle_mesh("sinsub.obj", m2)
|
248 |
+
mesh_o3d = mesh_o3d.subdivide_loop(3)
|
249 |
|
250 |
+
v_matrix = np.asarray(mesh_o3d.vertices )
|
251 |
+
f_matrix = np.asarray(mesh_o3d.triangles )
|
252 |
+
v_matrix_2 = np.asarray(m2.vertices )
|
253 |
+
f_matrix_2 = np.asarray(m2.triangles )
|
254 |
+
success = True
|
255 |
|
256 |
+
except Exception as e:
|
257 |
+
print("No se pudo generar")
|
258 |
+
print(str(e))
|
259 |
+
pass
|
260 |
+
else:
|
261 |
+
print("ratio", max_radius/min_radius)
|
262 |
pass
|
263 |
+
'''
|
264 |
M = max((max(v_matrix[:,0]) - min(v_matrix[:,0])), (max(v_matrix[:,1]) - min(v_matrix[:,1])), (max(v_matrix[:,2]) - min(v_matrix[:,2])))
|
265 |
x = (v_matrix[:,0] - min(v_matrix[:,0]))/M
|
266 |
y = (v_matrix[:,1] - min(v_matrix[:,1]))/ M
|
267 |
z = (v_matrix[:,2] - min(v_matrix[:,2]))/M
|
268 |
+
'''
|
269 |
|
270 |
+
M = max((max(v_matrix[:,0]) - min(v_matrix[:,0])), (max(v_matrix[:,1]) - min(v_matrix[:,1])), (max(v_matrix[:,2]) - min(v_matrix[:,2])))
|
271 |
+
x = (v_matrix[:,0] - np.mean(v_matrix[:,0]))/M
|
272 |
+
y = (v_matrix[:,1] - np.mean(v_matrix[:,1]))/ M
|
273 |
+
z = (v_matrix[:,2] - np.mean(v_matrix[:,2]))/M
|
274 |
+
|
275 |
+
minimo = min(min(x), min(y), min(z))
|
276 |
+
maximo = max(max(x), max(y), max(z))
|
277 |
+
|
278 |
fig = go.Figure(go.Mesh3d(
|
279 |
x=x, y=y, z=z,
|
280 |
i=f_matrix[:,0], j=f_matrix[:,1], k=f_matrix[:,2],
|
|
|
287 |
|
288 |
fig.update_layout(
|
289 |
scene = dict(
|
290 |
+
xaxis_range=[minimo, maximo],
|
291 |
+
yaxis_range=[minimo, maximo],
|
292 |
+
zaxis_range=[minimo, maximo],
|
293 |
aspectratio=dict(x = 1, y = 1, z = 1),
|
294 |
xaxis = dict(visible=False),
|
295 |
yaxis = dict(visible=False),
|
|
|
305 |
#o3d.io.write_triangle_mesh("generadas/"+filename.split("_")[0]+".obj", mesh_o3d)
|
306 |
return fig
|
307 |
|
308 |
+
|
309 |
a = [1.,1.,1.]
|
310 |
mult = torch.Tensor(a)
|
311 |
+
latent_size = 32
|
312 |
Grassdecoder = GRASSDecoder(latent_size=latent_size, hidden_size=256, mult = mult)
|
313 |
Grassdecoder = Grassdecoder
|
314 |
|
meshSubplot.py
ADDED
@@ -0,0 +1,111 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import uuid
|
2 |
+
from ipywidgets import Output, HBox
|
3 |
+
import meshplot as mp
|
4 |
+
rendertype = 'JUPYTER'
|
5 |
+
import numpy as np
|
6 |
+
import networkx as nx
|
7 |
+
|
8 |
+
class Subplot():
|
9 |
+
def __init__(self, data, view, s):
|
10 |
+
if data == None:
|
11 |
+
self.rows = []
|
12 |
+
self.hboxes = []
|
13 |
+
else:
|
14 |
+
self.rows = data.rows
|
15 |
+
if s[0] != 1 or s[1] != 1:
|
16 |
+
if data == None: # Intialize subplot array
|
17 |
+
cnt = 0
|
18 |
+
for r in range(s[0]):
|
19 |
+
row = []
|
20 |
+
for c in range(s[1]):
|
21 |
+
row.append(Output())
|
22 |
+
cnt += 1
|
23 |
+
self.rows.append(row)
|
24 |
+
|
25 |
+
for r in self.rows:
|
26 |
+
hbox = HBox(r)
|
27 |
+
if rendertype == "JUPYTER":
|
28 |
+
display(hbox)
|
29 |
+
self.hboxes.append(hbox)
|
30 |
+
|
31 |
+
out = self.rows[int(s[2]/s[1])][s[2]%s[1]]
|
32 |
+
if rendertype == "JUPYTER":
|
33 |
+
with out:
|
34 |
+
display(view._renderer)
|
35 |
+
self.rows[int(s[2]/s[1])][s[2]%s[1]] = view
|
36 |
+
|
37 |
+
def save(self, filename=""):
|
38 |
+
if filename == "":
|
39 |
+
uid = str(uuid.uuid4()) + ".html"
|
40 |
+
else:
|
41 |
+
filename = filename.replace(".html", "")
|
42 |
+
uid = filename + '.html'
|
43 |
+
|
44 |
+
s = ""
|
45 |
+
imports = True
|
46 |
+
for r in self.rows:
|
47 |
+
for v in r:
|
48 |
+
s1 = v.to_html(imports=imports, html_frame=False)
|
49 |
+
s = s + s1
|
50 |
+
imports = False
|
51 |
+
|
52 |
+
s = "<html>\n<body>\n" + s + "\n</body>\n</html>"
|
53 |
+
with open(uid, "w") as f:
|
54 |
+
f.write(s)
|
55 |
+
print("Plot saved to file %s."%uid)
|
56 |
+
|
57 |
+
def to_html(self, imports=True, html_frame=True):
|
58 |
+
s = ""
|
59 |
+
for r in self.rows:
|
60 |
+
for v in r:
|
61 |
+
s1 = v.to_html(imports=imports, html_frame=html_frame)
|
62 |
+
s = s + s1
|
63 |
+
imports = False
|
64 |
+
|
65 |
+
return s
|
66 |
+
|
67 |
+
def subplot(f, c = 'red', uv=None, n=None, shading={}, s=[1, 1, 0], data=None, **kwargs):
|
68 |
+
|
69 |
+
shading={'point_size':0.05, "point_color": c, "line_color": c, "width":400, "height":400}
|
70 |
+
view = mp.Viewer(settings = {"width": 500, "height": 500, "antialias": True, "scale": 1.5, "background": "#ffffff",
|
71 |
+
"fov": 30})
|
72 |
+
|
73 |
+
#obj = view.add_points(np.array([ f.nodes[v]['posicion'] for v in f.nodes]), shading=shading)
|
74 |
+
obj = view.add_points( np.array([f.nodes[v]['posicion'] for v in f.nodes if f.nodes[v]['root'] == True]), shading={'point_size':.02, 'point_color':'red'})
|
75 |
+
if len(np.array([ f.nodes[v]['posicion'] for v in f.nodes if f.nodes[v]['root'] == False])) != 0:
|
76 |
+
obj = view.add_points( np.array([f.nodes[v]['posicion'] for v in f.nodes if f.nodes[v]['root'] == False]), shading={'point_size':.02, 'point_color':'black'})
|
77 |
+
for arista in f.edges:
|
78 |
+
obj = view.add_lines( f.nodes[arista[0]]['posicion'], f.nodes[arista[1]]['posicion'], shading = shading)
|
79 |
+
|
80 |
+
subplot = Subplot(data, view, s)
|
81 |
+
return subplot
|
82 |
+
|
83 |
+
def plotTree( root, dec ):
|
84 |
+
graph = nx.Graph()
|
85 |
+
root.toGraph( graph, 0, dec, 0)
|
86 |
+
edges=nx.get_edge_attributes(graph,'procesada')
|
87 |
+
|
88 |
+
p = mp.plot( np.array([ graph.nodes[v]['posicion'] for v in graph.nodes if graph.nodes[v]['root'] == True]), shading={'point_size':0.05, 'point_color':'red'}, return_plot=True)
|
89 |
+
if len(np.array([ graph.nodes[v]['posicion'] for v in graph.nodes if graph.nodes[v]['root'] == False])) != 0:
|
90 |
+
p.add_points( np.array([graph.nodes[v]['posicion'] for v in graph.nodes if graph.nodes[v]['root'] == False]), shading={'point_size':.05, 'point_color':'black'})
|
91 |
+
for arista in graph.edges:
|
92 |
+
p.add_lines( graph.nodes[arista[0]]['posicion'], graph.nodes[arista[1]]['posicion'])
|
93 |
+
|
94 |
+
return
|
95 |
+
|
96 |
+
|
97 |
+
def sTree( root, dec, s, c, d=None):
|
98 |
+
"plot trees next to each other"
|
99 |
+
graph = nx.Graph()
|
100 |
+
root.toGraph( graph, 0, dec, 0)
|
101 |
+
|
102 |
+
if d:
|
103 |
+
subplot(graph, c=c, s=s, data = d)
|
104 |
+
else:
|
105 |
+
|
106 |
+
d = subplot(graph, c=c, s=s)
|
107 |
+
|
108 |
+
return d
|
109 |
+
|
110 |
+
|
111 |
+
|
modelo-best-nueva.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9287134af35df22f84fb65f5b6ec96ea8ed6cfc5bbb48a823524cc85a09bda97
|
3 |
+
size 17540213
|
modelo-best-nuevacc.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1ca26f006816c788f1aa282341630318dfac93953e1f0608d15ee837efc6afa7
|
3 |
+
size 6730273
|
output.obj
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
sinsub.obj
CHANGED
@@ -1,35 +1,19 @@
|
|
1 |
# Created by Open3D
|
2 |
# object name: sinsub
|
3 |
-
# number of vertices:
|
4 |
-
# number of triangles:
|
5 |
-
v 0.
|
6 |
-
v 0.
|
7 |
-
v 0.
|
8 |
-
v 0.
|
9 |
-
v 0.
|
10 |
-
v 0.
|
11 |
-
v 0.
|
12 |
-
v 0.
|
13 |
-
v 0.
|
14 |
-
v 0.
|
15 |
-
v 0.
|
16 |
-
v 0.
|
17 |
-
v 0.0874069 0.321796 0.429109
|
18 |
-
v 0.0589153 0.30421 0.465712
|
19 |
-
v 0.0862486 0.328973 0.498885
|
20 |
-
v 0.11474 0.346559 0.462283
|
21 |
-
v 0.0626304 0.383599 0.434658
|
22 |
-
v 0.0311964 0.366872 0.468706
|
23 |
-
v 0.0673745 0.366957 0.502148
|
24 |
-
v 0.0988085 0.383684 0.4681
|
25 |
-
v 0.0594784 0.458841 0.463877
|
26 |
-
v 0.0233739 0.439053 0.49896
|
27 |
-
v 0.0635398 0.41784 0.52833
|
28 |
-
v 0.0996443 0.437628 0.493247
|
29 |
-
v 0.0771643 0.546611 0.530904
|
30 |
-
v 0.0343078 0.521689 0.570211
|
31 |
-
v 0.0797324 0.487653 0.598157
|
32 |
-
v 0.122589 0.512575 0.558851
|
33 |
f 5 1 2
|
34 |
f 6 2 3
|
35 |
f 7 3 4
|
@@ -38,22 +22,6 @@ f 9 5 6
|
|
38 |
f 10 6 7
|
39 |
f 11 7 8
|
40 |
f 12 8 5
|
41 |
-
f 13 9 10
|
42 |
-
f 14 10 11
|
43 |
-
f 15 11 12
|
44 |
-
f 16 12 9
|
45 |
-
f 17 13 14
|
46 |
-
f 18 14 15
|
47 |
-
f 19 15 16
|
48 |
-
f 20 16 13
|
49 |
-
f 21 17 18
|
50 |
-
f 22 18 19
|
51 |
-
f 23 19 20
|
52 |
-
f 24 20 17
|
53 |
-
f 25 21 22
|
54 |
-
f 26 22 23
|
55 |
-
f 27 23 24
|
56 |
-
f 28 24 21
|
57 |
f 2 6 5
|
58 |
f 3 7 6
|
59 |
f 4 8 7
|
@@ -62,19 +30,3 @@ f 6 10 9
|
|
62 |
f 7 11 10
|
63 |
f 8 12 11
|
64 |
f 5 9 12
|
65 |
-
f 10 14 13
|
66 |
-
f 11 15 14
|
67 |
-
f 12 16 15
|
68 |
-
f 9 13 16
|
69 |
-
f 14 18 17
|
70 |
-
f 15 19 18
|
71 |
-
f 16 20 19
|
72 |
-
f 13 17 20
|
73 |
-
f 18 22 21
|
74 |
-
f 19 23 22
|
75 |
-
f 20 24 23
|
76 |
-
f 17 21 24
|
77 |
-
f 22 26 25
|
78 |
-
f 23 27 26
|
79 |
-
f 24 28 27
|
80 |
-
f 21 25 28
|
|
|
1 |
# Created by Open3D
|
2 |
# object name: sinsub
|
3 |
+
# number of vertices: 12
|
4 |
+
# number of triangles: 16
|
5 |
+
v 0.449378 0.00737204 0.0931694
|
6 |
+
v 0.453679 -0.00822981 0.0918463
|
7 |
+
v 0.443061 -0.0101272 0.0797087
|
8 |
+
v 0.43876 0.00547462 0.0810317
|
9 |
+
v 0.540627 0.0390201 0.0148946
|
10 |
+
v 0.554566 0.0244183 0.00205357
|
11 |
+
v 0.538313 0.0243431 -0.0155028
|
12 |
+
v 0.524375 0.0389449 -0.00266178
|
13 |
+
v 0.539596 0.11558 0.00564692
|
14 |
+
v 0.54497 0.11561 -0.000638385
|
15 |
+
v 0.538685 0.115594 -0.00601316
|
16 |
+
v 0.53331 0.115563 0.000272139
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
f 5 1 2
|
18 |
f 6 2 3
|
19 |
f 7 3 4
|
|
|
22 |
f 10 6 7
|
23 |
f 11 7 8
|
24 |
f 12 8 5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
f 2 6 5
|
26 |
f 3 7 6
|
27 |
f 4 8 7
|
|
|
30 |
f 7 11 10
|
31 |
f 8 12 11
|
32 |
f 5 9 12
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|