repo_description: Official implementation of "OpenPifPaf: Composite Fields for Semantic Keypoint Detection and Spatio-Temporal Association" in PyTorch.
repo_topics: composite-fields computer-vision deep-learning human-pose-estimation keypoint-estimation pose-estimation
code: from collections import defaultdict
  import logging
  
  LOG = logging.getLogger(__name__)
  
  
  class Signal:
      """In-process Signal infrastructure.
  
      Objects can subscribe to 'events'. Events are triggered with the emit()
      function and are fanned out to all subscribers.
      """
  
      subscribers = defaultdict(list)
  
      @classmethod
      def emit(cls, name, *args, **kwargs):
          subscribers = cls.subscribers.get(name, [])
          LOG.debug('emit %s to %d subscribers', name, len(subscribers))
          for subscriber in subscribers:
              subscriber(*args, **kwargs)
  
      @classmethod
      def subscribe(cls, name, subscriber):
          LOG.debug('subscribe to %s', name)
          cls.subscribers[name].append(subscriber)
  