vuer 0.0.4__py3-none-any.whl → 0.0.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of vuer might be problematic. Click here for more details.

@@ -335,6 +335,10 @@ def collector(
335
335
  data={**flow},
336
336
  )
337
337
 
338
+ # holds the current pipe.
339
+ render_event._pipeline = pipe
340
+ render_event._channels = channels
341
+
338
342
  return render_event
339
343
 
340
344
  return decorator
@@ -129,6 +129,16 @@ class RGBA(Singleton):
129
129
  **pipeline,
130
130
  }
131
131
 
132
+ def cache_depth(self, raw_depth, raw_accumulation, **pipeline):
133
+ depth_a = torch.cat([raw_depth, 255 * raw_accumulation], dim=-1).clip(0, 255).cpu().numpy().astype(np.uint8)
134
+ self.append(depth_a)
135
+
136
+ return {
137
+ "raw_depth": raw_depth,
138
+ "raw_accumulation": raw_accumulation,
139
+ **pipeline,
140
+ }
141
+
132
142
 
133
143
  def _get_colormap(colormap, invert=False, useClip=True, clip: tuple = None, gain=1.0, offset=0.0, normalize=False, **_):
134
144
  """
@@ -233,6 +243,9 @@ class FeatA(Singleton):
233
243
  **pipeline,
234
244
  }
235
245
 
246
+ def probe_feature(self, raw_features, **pipeline):
247
+ return {"raw_features": raw_features, **pipeline}
248
+
236
249
  def features_heatmap(self, raw_features, raw_accumulation, settings, **pipeline):
237
250
 
238
251
  print("raw_features.shape:", raw_features.shape)
vuer/base.py CHANGED
@@ -65,6 +65,7 @@ class Server:
65
65
  default = aiohttp_cors.ResourceOptions(
66
66
  allow_credentials=True,
67
67
  expose_headers="*",
68
+ allow_headers="*",
68
69
  allow_methods="*",
69
70
  )
70
71
  cors_config = {k: default for k in self.cors.split(",")}
@@ -82,8 +83,7 @@ class Server:
82
83
 
83
84
  def _socket(self, path: str, handler: callable):
84
85
  ws_handler = partial(websocket_handler, handler=handler, max_msg_size=self.WEBSOCKET_MAX_SIZE)
85
- route = self.app.router.add_resource(path).add_route("GET", ws_handler)
86
- self.cors_context.add(route)
86
+ self._route(path, ws_handler, method="GET")
87
87
 
88
88
  def _add_task(self, fn):
89
89
  loop = asyncio.get_event_loop()
@@ -91,7 +91,7 @@ class Server:
91
91
 
92
92
  def _static(self, path, root):
93
93
  _fn = partial(handle_file_request, root=root)
94
- self.app.add_routes([web.get(f"/{path}/{{filename}}", _fn)])
94
+ self._route(f"{path}/{{filename}}", _fn, method="GET")
95
95
 
96
96
  def run(self):
97
97
  async def init_server():
@@ -111,5 +111,5 @@ class Server:
111
111
  if __name__ == "__main__":
112
112
  app = Server()
113
113
  app._route("", websocket_handler)
114
- app._static("static", handle_file_request, root=".")
114
+ app._static("/static", handle_file_request, root=".")
115
115
  app.run()
vuer/events.py CHANGED
@@ -1,4 +1,5 @@
1
1
  from vuer.schemas import Element
2
+ from vuer.serdes import serializer
2
3
 
3
4
 
4
5
  class Event:
@@ -54,27 +55,6 @@ NULL = NullEvent()
54
55
  # instance = cls.__new__(cls)
55
56
  # return cls.__init__(instance, data)
56
57
 
57
- from typing import Sequence
58
-
59
-
60
- def serializer(data):
61
- if hasattr(data, "serialize"):
62
- return data.serialize()
63
-
64
- if isinstance(data, str):
65
- # return Text(data)
66
- return data
67
-
68
- # this could be dangerous.
69
- if isinstance(data, Sequence):
70
- return [serializer(d) for d in data]
71
-
72
- # this could be dangerous
73
- if isinstance(data, dict):
74
- return {k: serializer(v) for k, v in data.items()}
75
-
76
- NotImplementedError(f"Cannot serialize {data}")
77
-
78
58
 
79
59
  class ServerEvent(Event): # , metaclass=Meta):
80
60
  def __init__(self, data, etype=None, **kwargs):
vuer/schemas.py CHANGED
@@ -3,6 +3,8 @@ from typing import Union
3
3
  import numpy as np
4
4
  import PIL.Image as pil_image
5
5
 
6
+ # from msgpack_numpy import pack, packb
7
+
6
8
  element_count = 0
7
9
 
8
10
 
@@ -31,7 +33,16 @@ class Element:
31
33
  :return: Dictionary representing the element.
32
34
  """
33
35
  # note: only return the non-private attributes, allow bypass.
34
- return {k: v for k, v in self.__dict__.items() if not k.startswith("_")}
36
+ output = {}
37
+ for k, v in self.__dict__.items():
38
+ if k.startswith('_'):
39
+ continue
40
+ if hasattr(v, "tolist"):
41
+ output[k] = v.tolist()
42
+ else:
43
+ output[k] = v
44
+
45
+ return output
35
46
 
36
47
 
37
48
  class BlockElement(Element):
@@ -247,12 +258,12 @@ class Scene(BlockElement):
247
258
  tag = "Scene"
248
259
 
249
260
  def __init__(
250
- self,
251
- *children,
252
- rawChildren=None,
253
- htmlChildren=None,
254
- backgroundChildren=None,
255
- **kwargs,
261
+ self,
262
+ *children,
263
+ rawChildren=None,
264
+ htmlChildren=None,
265
+ backgroundChildren=None,
266
+ **kwargs,
256
267
  ):
257
268
  super().__init__(*children, **kwargs)
258
269
  self.rawChildren = rawChildren or []
@@ -270,6 +281,21 @@ class Scene(BlockElement):
270
281
  return obj
271
282
 
272
283
 
284
+ class DefaultScene(Scene):
285
+ def __init__(
286
+ self,
287
+ *children,
288
+ rawChildren=None,
289
+ htmlChildren=None,
290
+ backgroundChildren=None,
291
+ **kwargs,
292
+ ):
293
+ super().__init__(
294
+ AmbientLight(intensity=0.5, key="default_ambient_light"),
295
+ DirectionalLight(intensity=1, key="default_directional_light"),
296
+ *children, **kwargs)
297
+
298
+
273
299
  class SceneElement(BlockElement):
274
300
  pass
275
301
 
@@ -287,6 +313,46 @@ class group(SceneElement):
287
313
  children = []
288
314
 
289
315
 
316
+ class mesh(SceneElement):
317
+ tag = "mesh"
318
+ children = []
319
+
320
+
321
+ class TriMesh(SceneElement):
322
+ tag = "TriMesh"
323
+ children = []
324
+ vertices = None
325
+ faces = None
326
+ colors = None
327
+
328
+ def __post_init__(self, **kwargs):
329
+ self.vertices = self.vertices.flatten()
330
+ if hasattr(self.faces, "flatten"):
331
+ self.faces = self.faces.flatten()
332
+ if hasattr(self.colors, "flatten"):
333
+ if self.colors.shape[-1] == 4:
334
+ self.colors = self.colors[:, :3]
335
+ if self.colors.dtype == np.uint8:
336
+ self.colors = self.colors.astype(np.float32) / 255.
337
+ self.colors = self.colors.flatten().astype(np.float32)
338
+
339
+
340
+ class PointCloud(SceneElement):
341
+ tag = "PointCloud"
342
+ children = []
343
+ vertices = None
344
+ colors = None
345
+
346
+ def __post_init__(self, **kwargs):
347
+ self.vertices = self.vertices.flatten()
348
+ if hasattr(self.colors, "flatten"):
349
+ if self.colors.shape[-1] == 4:
350
+ self.colors = self.colors[:, :3]
351
+ if self.colors.dtype == np.uint8:
352
+ self.colors = self.colors.astype(np.float32) / 255.
353
+ self.colors = self.colors.flatten()
354
+
355
+
290
356
  class Box(SceneElement):
291
357
  tag = "Box"
292
358
 
@@ -422,10 +488,6 @@ class Html(SceneElement):
422
488
  tag = "Html"
423
489
 
424
490
 
425
- class Ply(SceneElement):
426
- tag = "Ply"
427
-
428
-
429
491
  class Pivot(SceneElement):
430
492
  tag = "Pivot"
431
493
 
@@ -434,6 +496,14 @@ class Movable(SceneElement):
434
496
  tag = "Movable"
435
497
 
436
498
 
499
+ class Obj(SceneElement):
500
+ tag = "Obj"
501
+
502
+
503
+ class Ply(SceneElement):
504
+ tag = "Ply"
505
+
506
+
437
507
  class Glb(SceneElement):
438
508
  tag = "Glb"
439
509
 
@@ -442,10 +512,6 @@ class Urdf(SceneElement):
442
512
  tag = "Urdf"
443
513
 
444
514
 
445
- class PointCloud(SceneElement):
446
- tag = "PointCloud"
447
-
448
-
449
515
  class Gripper(SceneElement):
450
516
  tag = "Gripper"
451
517
 
vuer/serdes.py ADDED
@@ -0,0 +1,20 @@
1
+ from typing import Sequence
2
+
3
+
4
+ def serializer(data):
5
+ if hasattr(data, "serialize"):
6
+ return data.serialize()
7
+
8
+ if isinstance(data, str):
9
+ # return Text(data)
10
+ return data
11
+
12
+ # this could be dangerous.
13
+ if isinstance(data, Sequence):
14
+ return [serializer(d) for d in data]
15
+
16
+ # this could be dangerous
17
+ if isinstance(data, dict):
18
+ return {k: serializer(v) for k, v in data.items()}
19
+
20
+ NotImplementedError(f"Cannot serialize {data}")
vuer/server.py CHANGED
@@ -6,6 +6,7 @@ from functools import partial
6
6
  from typing import cast
7
7
  from uuid import uuid4
8
8
 
9
+ from msgpack import packb
9
10
  from params_proto import Proto, PrefixProto
10
11
  from websockets import ConnectionClosedError
11
12
 
@@ -30,12 +31,12 @@ class Vuer(PrefixProto, Server):
30
31
  name = "vuer"
31
32
  uri = "ws://localhost:8012"
32
33
  # change to vuer.dash.ml
33
- domain = "https://dash.ml/demos/vqn-dash/three"
34
+ domain = "https://dash.ml/vuer"
34
35
  port = 8012
35
36
  free_port = True
36
37
  static_root = "."
37
38
  queue_len = None
38
- cors_origin = "https://dash.ml,*"
39
+ # cors = "https://dash.ml,http://localhost:8000,http://127.0.0.1:8000,*"
39
40
  queries = Proto({}, help="query parameters to pass")
40
41
 
41
42
  WEBSOCKET_MAX_SIZE = 2 ** 28
@@ -171,9 +172,11 @@ class Vuer(PrefixProto, Server):
171
172
  async def send(self, ws_id, event: ServerEvent):
172
173
  ws = self.ws[ws_id]
173
174
  assert isinstance(event, ServerEvent), "event must be a ServerEvent type object."
174
- res_str = event.serialize()
175
- res_json_str = json.dumps(res_str)
176
- return await ws.send_str(res_json_str)
175
+ res_obj = event.serialize()
176
+ res_bytes = packb(res_obj, use_bin_type=True)
177
+ return await ws.send_bytes(res_bytes)
178
+ # res_json_str = json.dumps(res_str)
179
+ # return await ws.send_str(res_json_str)
177
180
 
178
181
  async def close_ws(self, ws_id):
179
182
  self.uplink_queue.pop(ws_id)
@@ -297,8 +300,9 @@ class Vuer(PrefixProto, Server):
297
300
  # host = host[2:]
298
301
 
299
302
  self._socket("", self.downlink)
300
- # serve local files via /local endpoint
301
- self._static("/local", self.static_root)
303
+ # serve local files via /static endpoint
304
+ self._static("/static", self.static_root)
305
+ print("serving static files from", self.static_root, "at", "/static")
302
306
  self._route("/relay", self.relay, method="POST")
303
307
  # self._socket()
304
308
  super().run()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: vuer
3
- Version: 0.0.4
3
+ Version: 0.0.5
4
4
  Home-page: https://github.com/geyang/vuer
5
5
  Author: Ge Yang<ge.ike.yang@gmail.com>
6
6
  Author-email: ge.ike.yang@gmail.com
@@ -13,10 +13,12 @@ License-File: LICENSE
13
13
  Requires-Dist: tqdm
14
14
  Requires-Dist: termcolor
15
15
  Requires-Dist: params-proto
16
+ Requires-Dist: killport
17
+ Requires-Dist: msgpack
16
18
  Provides-Extra: dev
17
- Requires-Dist: black (==22.3.0) ; extra == 'dev'
18
- Requires-Dist: pylint (==2.13.4) ; extra == 'dev'
19
- Requires-Dist: pytest (==7.1.2) ; extra == 'dev'
19
+ Requires-Dist: black ==22.3.0 ; extra == 'dev'
20
+ Requires-Dist: pylint ==2.13.4 ; extra == 'dev'
21
+ Requires-Dist: pytest ==7.1.2 ; extra == 'dev'
20
22
 
21
23
  # Vuer: A modern 3D Visualizer for Robotics and VR
22
24
 
@@ -0,0 +1,22 @@
1
+ vuer/__init__.py,sha256=x2ZqgbBIDHQr7UvdkKhVdtYToIZdhXw4XTRnfrQiBos,28
2
+ vuer/base.py,sha256=LHGqz_067HTWDuL2JLuC_W25rKikBdrT4unF5nUi3tY,3035
3
+ vuer/events.py,sha256=5gyYXz0XZVAMU2xyKYJmpkhIWoGGSgcrUFy8h37AoM8,3676
4
+ vuer/schemas.py,sha256=LWY79JiN3Iwf_O8xv94LBAA8drwGjMVCC9v1Cr9byhI,12245
5
+ vuer/serdes.py,sha256=dlnLcISXoXv7X6lk6DKYUksQSX3wjQ8YFa4FUZel6Ds,484
6
+ vuer/server.py,sha256=ynXs4euJrLvdjsopDhZcs0QdMwTNh3Farl5PbcvZKsM,9234
7
+ vuer/types.py,sha256=4jVXsuLjaQwmnCrK9j9G6vSVbmb8cq72WhptZg3qOuU,681
8
+ vuer/addons/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ vuer/addons/nerf_vuer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ vuer/addons/nerf_vuer/control_components.py,sha256=K4PU0nD572L4J7lLFfShWficWZQnH4t-x6WWMrAVw8g,290
11
+ vuer/addons/nerf_vuer/mixins.py,sha256=fQuW3adf6X2xw_PSfS145TNfbQ9OoTKuv8mYEo6Pt6A,12966
12
+ vuer/addons/nerf_vuer/nerf_vuer.py,sha256=0iIbrQK939wwlkJOIfdOIswRKTXOKh-0TpNM5NU2ESw,5196
13
+ vuer/addons/nerf_vuer/render_components.py,sha256=KbClUsbKUWweUXZzh1SMlJS1wilj-VaQOQHVShircaw,3854
14
+ vuer/addons/nerf_vuer/render_nodes.py,sha256=5TKqIbMPiOtBxfF4FQI6uB0w_9FTfGiwS8xRbhPa0_g,14441
15
+ vuer/addons/nerfuer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ vuer/addons/nerfuer/render_nodes.py,sha256=ekrF93o3Q5cE2GKoYYvt7l7Nva_i8r6AFw29xHzx0wA,4478
17
+ vuer-0.0.5.dist-info/LICENSE,sha256=MGF-inVBUaGe2mEjqT0g6XsHIXwoNXgNHqD7Z1MzR0k,1063
18
+ vuer-0.0.5.dist-info/METADATA,sha256=UqgVZUQ4uVYVAnlB-AIr6nBHV9XUARkaZKEW1oOCVc4,805
19
+ vuer-0.0.5.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
20
+ vuer-0.0.5.dist-info/entry_points.txt,sha256=J_NM6fbpipmD9oP7cdxd1UyBR8mVEQVx0xjlE_56yss,41
21
+ vuer-0.0.5.dist-info/top_level.txt,sha256=ermmVkwvGFAK4gfSgDIwOmKpxwpqNt-oo7gVQQUSHok,5
22
+ vuer-0.0.5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.38.4)
2
+ Generator: bdist_wheel (0.41.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,21 +0,0 @@
1
- vuer/__init__.py,sha256=x2ZqgbBIDHQr7UvdkKhVdtYToIZdhXw4XTRnfrQiBos,28
2
- vuer/base.py,sha256=P64wGxQzk3VOic9hWJRSqHvlzjo5XKqrQplX6-tLgu8,3074
3
- vuer/events.py,sha256=pJIdD5F-SqXJ_maowRiDgssnbRgP23dEsOKfXSxVE2o,4126
4
- vuer/schemas.py,sha256=CxSy1WvVS_JWtADf8L0pdBvub4ZQMGRtYOno0mVW-60,10406
5
- vuer/server.py,sha256=kSdB5kWxHeDxly51XHvo0Wgk-TZ3zD-ZuisMG70sYYs,9001
6
- vuer/types.py,sha256=4jVXsuLjaQwmnCrK9j9G6vSVbmb8cq72WhptZg3qOuU,681
7
- vuer/addons/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
- vuer/addons/nerf_vuer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- vuer/addons/nerf_vuer/control_components.py,sha256=K4PU0nD572L4J7lLFfShWficWZQnH4t-x6WWMrAVw8g,290
10
- vuer/addons/nerf_vuer/mixins.py,sha256=jh-fD5wRe1rHjODFbQQqjQmvH5rT1rdqrU0HF-LaA3U,12851
11
- vuer/addons/nerf_vuer/nerf_vuer.py,sha256=0iIbrQK939wwlkJOIfdOIswRKTXOKh-0TpNM5NU2ESw,5196
12
- vuer/addons/nerf_vuer/render_components.py,sha256=KbClUsbKUWweUXZzh1SMlJS1wilj-VaQOQHVShircaw,3854
13
- vuer/addons/nerf_vuer/render_nodes.py,sha256=GbTCoVTzszijduQUmjdjrBFZW1ttGAb5AV5p4P6nPM4,13974
14
- vuer/addons/nerfuer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- vuer/addons/nerfuer/render_nodes.py,sha256=ekrF93o3Q5cE2GKoYYvt7l7Nva_i8r6AFw29xHzx0wA,4478
16
- vuer-0.0.4.dist-info/LICENSE,sha256=MGF-inVBUaGe2mEjqT0g6XsHIXwoNXgNHqD7Z1MzR0k,1063
17
- vuer-0.0.4.dist-info/METADATA,sha256=KQMq_t1yeq0-YNjGjn9oNwgKD-O9bM39GbZMnr6bZAs,764
18
- vuer-0.0.4.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
19
- vuer-0.0.4.dist-info/entry_points.txt,sha256=J_NM6fbpipmD9oP7cdxd1UyBR8mVEQVx0xjlE_56yss,41
20
- vuer-0.0.4.dist-info/top_level.txt,sha256=ermmVkwvGFAK4gfSgDIwOmKpxwpqNt-oo7gVQQUSHok,5
21
- vuer-0.0.4.dist-info/RECORD,,
File without changes