From 70761d384d580b04c2154d85dd3291876469b8f0 Mon Sep 17 00:00:00 2001 From: Siarhei Siniak Date: Tue, 20 Jul 2021 09:52:45 +0300 Subject: [PATCH] [~] Refactor --- python/tasks/mlb_player.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/python/tasks/mlb_player.py b/python/tasks/mlb_player.py index f864263..596a295 100644 --- a/python/tasks/mlb_player.py +++ b/python/tasks/mlb_player.py @@ -843,3 +843,41 @@ def kernel_9_benchmark( pprint.pprint( ['kernel_9_benchmark', dict(t4=t4, t5=t5)] ) + +def kernel_10(): + import torch + + # Model + model = torch.hub.load('ultralytics/yolov5', 'yolov5s') # or yolov5m, yolov5x, custom + + # Images + img = 'https://ultralytics.com/images/zidane.jpg' # or file, PIL, OpenCV, numpy, multiple + + # Inference + results = model(img) + + # Results + results.print() # or .show(), .save(), .crop(), .pandas(), etc. + + return dict( + model=model, + ) + +def kernel_11_benchmark( + o_7, + o_10, +): + import datetime + + t1 = o_7['cv2'].imread('../input/indonesian-traditional-dance/tgagrakanyar/tga_0000.jpg') + t5 = 10 + t2 = datetime.datetime.now() + for k in range(t5): + t6 = o_10['model'](img_ori) + t7 = t6.pandas().xywhn + + t3 = datetime.datetime.now() + t4 = (t3 - t2).total_seconds() / t5 + pprint.pprint( + ['kernel_11_benchmark', dict(t4=t4, t5=t5)] + )