def main(): global PROCESSOR_SINGLETON # pylint: disable=global-statement parser = argparse.ArgumentParser() openpifpaf.decoder.cli(parser, force_complete_pose=False, instance_threshold=0.05) openpifpaf.network.nets.cli(parser) parser.add_argument('--disable-cuda', action='store_true', help='disable CUDA') parser.add_argument('--figure-width', default=10.0, type=float, help='figure width') args = parser.parse_args() # add args.device args.device = torch.device('cpu') if not args.disable_cuda and torch.cuda.is_available(): args.device = torch.device('cuda') PROCESSOR_SINGLETON = Processor(args) databench.run(Demo, __file__, info={'title': 'OpenPifPaf Demo'}, static={r'(analysis\.js)': '.'}, extra_routes=[('process', PostHandler, None)])
def test_static_file_serving(self): ioloop = tornado.ioloop.IOLoop.current() def test_and_stop(): ioloop.stop() ioloop.call_later(2.0, test_and_stop) databench.run(DummyPi, __file__, static={'(analysis\.js)': '.'})
def main(): global PROCESSOR_SINGLETON # pylint: disable=global-statement parser = argparse.ArgumentParser() openpifpaf.decoder.cli(parser, force_complete_pose=False, instance_threshold=0.05) openpifpaf.network.nets.cli(parser) parser.add_argument('--disable-cuda', action='store_true', help='disable CUDA') parser.add_argument('--resolution', default=0.4, type=float) parser.add_argument('--grep-static', default=False, action='store_true') parser.add_argument('--google-analytics') args = parser.parse_args() # add args.device args.device = torch.device('cpu') if not args.disable_cuda and torch.cuda.is_available(): args.device = torch.device('cuda') PROCESSOR_SINGLETON = Processor(args) if args.grep_static: tornado.ioloop.IOLoop.current().call_later(1.0, grep_static) tornado.autoreload.watch('openpifpafwebdemo/index.html') tornado.autoreload.watch('openpifpafwebdemo/analysis.js') databench.run(Demo, __file__, info={ 'title': 'OpenPifPafWebDemo', 'google_analytics': args.google_analytics, 'version': VERSION, 'resolution': args.resolution }, static={ r'(analysis\.js.*)': '.', r'static/(.*)': 'openpifpafwebdemo/static' }, extra_routes=[('process', PostHandler, None)])
# debug yield self.emit('log', {'draws': draws, 'inside': inside}) # calculate pi and its uncertainty given the current draws p = inside / draws pi = { 'estimate': 4.0 * p, 'uncertainty': 4.0 * math.sqrt(draws * p * (1.0 - p)) / draws, } # send status to frontend yield self.set_state(pi=pi) yield self.emit('log', {'action': 'done'}) @databench.on def samples(self, value): yield self.set_state(samples=value) class Example(tornado.testing.AsyncTestCase): @tornado.testing.gen_test def test_data(self): test = AnalysisTest(DummyPi) yield test.trigger('run') self.assertIn(('log', {'action': 'done'}), test.emitted_messages) if __name__ == '__main__': databench.run(DummyPi, __file__)
def test_run(self): ioloop = tornado.ioloop.IOLoop.current() ioloop.call_later(2.0, ioloop.stop) databench.run(DummyPi, __file__)
@databench.on def samples(self, value): yield self.set_state(samples=value) class Example(tornado.testing.AsyncTestCase): @tornado.testing.gen_test def test_data(self): test = AnalysisTest(DummyPi) yield test.trigger('run') self.assertIn(('log', {'action': 'done'}), test.emitted_messages) def test_run(self): ioloop = tornado.ioloop.IOLoop.current() ioloop.call_later(2.0, ioloop.stop) databench.run(DummyPi, __file__) def test_static_file_serving(self): ioloop = tornado.ioloop.IOLoop.current() def test_and_stop(): ioloop.stop() ioloop.call_later(2.0, test_and_stop) databench.run(DummyPi, __file__, static={'(analysis\.js)': '.'}) if __name__ == '__main__': databench.run(DummyPi, __file__, static={'special/(analysis\.js)': '.'})