forked from PaddlePaddle/FastDeploy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
740 lines (577 loc) · 32.4 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import
from typing import Union, List
import logging
from .... import FastDeployModel, ModelFormat
from .... import c_lib_wrap as C
class PaddleDetPreprocessor:
def __init__(self, config_file):
"""Create a preprocessor for PaddleDetection Model from configuration file
:param config_file: (str)Path of configuration file, e.g ppyoloe/infer_cfg.yml
"""
self._preprocessor = C.vision.detection.PaddleDetPreprocessor(
config_file)
def run(self, input_ims):
"""Preprocess input images for PaddleDetection Model
:param: input_ims: (list of numpy.ndarray)The input image
:return: list of FDTensor, include image, scale_factor, im_shape
"""
return self._preprocessor.run(input_ims)
def disable_normalize(self):
"""
This function will disable normalize in preprocessing step.
"""
self._preprocessor.disable_normalize()
def disable_permute(self):
"""
This function will disable hwc2chw in preprocessing step.
"""
self._preprocessor.disable_permute()
class PaddleDetPostprocessor:
def __init__(self):
"""Create a postprocessor for PaddleDetection Model
"""
self._postprocessor = C.vision.detection.PaddleDetPostprocessor()
def run(self, runtime_results):
"""Postprocess the runtime results for PaddleDetection Model
:param: runtime_results: (list of FDTensor)The output FDTensor results from runtime
:return: list of ClassifyResult(If the runtime_results is predict by batched samples, the length of this list equals to the batch size)
"""
return self._postprocessor.run(runtime_results)
def apply_decode_and_nms(self):
"""This function will enable decode and nms in postprocess step.
"""
return self._postprocessor.apply_decode_and_nms()
class PPYOLOE(FastDeployModel):
def __init__(self,
model_file,
params_file,
config_file,
runtime_option=None,
model_format=ModelFormat.PADDLE):
"""Load a PPYOLOE model exported by PaddleDetection.
:param model_file: (str)Path of model file, e.g ppyoloe/model.pdmodel
:param params_file: (str)Path of parameters file, e.g ppyoloe/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
:param config_file: (str)Path of configuration file for deployment, e.g ppyoloe/infer_cfg.yml
:param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU
:param model_format: (fastdeploy.ModelForamt)Model format of the loaded model
"""
super(PPYOLOE, self).__init__(runtime_option)
self._model = C.vision.detection.PPYOLOE(
model_file, params_file, config_file, self._runtime_option,
model_format)
assert self.initialized, "PPYOLOE model initialize failed."
def predict(self, im):
"""Detect an input image
:param im: (numpy.ndarray)The input image data, 3-D array with layout HWC, BGR format
:return: DetectionResult
"""
assert im is not None, "The input image data is None."
return self._model.predict(im)
def batch_predict(self, images):
"""Detect a batch of input image list
:param im: (list of numpy.ndarray) The input image list, each element is a 3-D array with layout HWC, BGR format
:return list of DetectionResult
"""
return self._model.batch_predict(images)
def clone(self):
"""Clone PPYOLOE object
:return: a new PPYOLOE object
"""
class PPYOLOEClone(PPYOLOE):
def __init__(self, model):
self._model = model
clone_model = PPYOLOEClone(self._model.clone())
return clone_model
@property
def preprocessor(self):
"""Get PaddleDetPreprocessor object of the loaded model
:return PaddleDetPreprocessor
"""
return self._model.preprocessor
@property
def postprocessor(self):
"""Get PaddleDetPostprocessor object of the loaded model
:return PaddleDetPostprocessor
"""
return self._model.postprocessor
class PPYOLO(PPYOLOE):
def __init__(self,
model_file,
params_file,
config_file,
runtime_option=None,
model_format=ModelFormat.PADDLE):
"""Load a PPYOLO model exported by PaddleDetection.
:param model_file: (str)Path of model file, e.g ppyolo/model.pdmodel
:param params_file: (str)Path of parameters file, e.g ppyolo/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
:param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU
:param model_format: (fastdeploy.ModelForamt)Model format of the loaded model
"""
super(PPYOLOE, self).__init__(runtime_option)
assert model_format == ModelFormat.PADDLE, "PPYOLO model only support model format of ModelFormat.Paddle now."
self._model = C.vision.detection.PPYOLO(
model_file, params_file, config_file, self._runtime_option,
model_format)
assert self.initialized, "PPYOLO model initialize failed."
def clone(self):
"""Clone PPYOLO object
:return: a new PPYOLO object
"""
class PPYOLOClone(PPYOLO):
def __init__(self, model):
self._model = model
clone_model = PPYOLOClone(self._model.clone())
return clone_model
class PaddleYOLOX(PPYOLOE):
def __init__(self,
model_file,
params_file,
config_file,
runtime_option=None,
model_format=ModelFormat.PADDLE):
"""Load a YOLOX model exported by PaddleDetection.
:param model_file: (str)Path of model file, e.g yolox/model.pdmodel
:param params_file: (str)Path of parameters file, e.g yolox/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
:param config_file: (str)Path of configuration file for deployment, e.g ppyoloe/infer_cfg.yml
:param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU
:param model_format: (fastdeploy.ModelForamt)Model format of the loaded model
"""
super(PPYOLOE, self).__init__(runtime_option)
assert model_format == ModelFormat.PADDLE, "PaddleYOLOX model only support model format of ModelFormat.Paddle now."
self._model = C.vision.detection.PaddleYOLOX(
model_file, params_file, config_file, self._runtime_option,
model_format)
assert self.initialized, "PaddleYOLOX model initialize failed."
def clone(self):
"""Clone PaddleYOLOX object
:return: a new PaddleYOLOX object
"""
class PaddleYOLOXClone(PaddleYOLOX):
def __init__(self, model):
self._model = model
clone_model = PaddleYOLOXClone(self._model.clone())
return clone_model
class PicoDet(PPYOLOE):
def __init__(self,
model_file,
params_file,
config_file,
runtime_option=None,
model_format=ModelFormat.PADDLE):
"""Load a PicoDet model exported by PaddleDetection.
:param model_file: (str)Path of model file, e.g picodet/model.pdmodel
:param params_file: (str)Path of parameters file, e.g picodet/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
:param config_file: (str)Path of configuration file for deployment, e.g ppyoloe/infer_cfg.yml
:param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU
:param model_format: (fastdeploy.ModelForamt)Model format of the loaded model
"""
super(PPYOLOE, self).__init__(runtime_option)
self._model = C.vision.detection.PicoDet(
model_file, params_file, config_file, self._runtime_option,
model_format)
assert self.initialized, "PicoDet model initialize failed."
def clone(self):
"""Clone PicoDet object
:return: a new PicoDet object
"""
class PicoDetClone(PicoDet):
def __init__(self, model):
self._model = model
clone_model = PicoDetClone(self._model.clone())
return clone_model
class FasterRCNN(PPYOLOE):
def __init__(self,
model_file,
params_file,
config_file,
runtime_option=None,
model_format=ModelFormat.PADDLE):
"""Load a FasterRCNN model exported by PaddleDetection.
:param model_file: (str)Path of model file, e.g fasterrcnn/model.pdmodel
:param params_file: (str)Path of parameters file, e.g fasterrcnn/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
:param config_file: (str)Path of configuration file for deployment, e.g ppyoloe/infer_cfg.yml
:param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU
:param model_format: (fastdeploy.ModelForamt)Model format of the loaded model
"""
super(PPYOLOE, self).__init__(runtime_option)
assert model_format == ModelFormat.PADDLE, "FasterRCNN model only support model format of ModelFormat.Paddle now."
self._model = C.vision.detection.FasterRCNN(
model_file, params_file, config_file, self._runtime_option,
model_format)
assert self.initialized, "FasterRCNN model initialize failed."
def clone(self):
"""Clone FasterRCNN object
:return: a new FasterRCNN object
"""
class FasterRCNNClone(FasterRCNN):
def __init__(self, model):
self._model = model
clone_model = FasterRCNNClone(self._model.clone())
return clone_model
class YOLOv3(PPYOLOE):
def __init__(self,
model_file,
params_file,
config_file,
runtime_option=None,
model_format=ModelFormat.PADDLE):
"""Load a YOLOv3 model exported by PaddleDetection.
:param model_file: (str)Path of model file, e.g yolov3/model.pdmodel
:param params_file: (str)Path of parameters file, e.g yolov3/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
:param config_file: (str)Path of configuration file for deployment, e.g ppyoloe/infer_cfg.yml
:param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU
:param model_format: (fastdeploy.ModelForamt)Model format of the loaded model
"""
super(PPYOLOE, self).__init__(runtime_option)
assert model_format == ModelFormat.PADDLE, "YOLOv3 model only support model format of ModelFormat.Paddle now."
self._model = C.vision.detection.YOLOv3(
model_file, params_file, config_file, self._runtime_option,
model_format)
assert self.initialized, "YOLOv3 model initialize failed."
def clone(self):
"""Clone YOLOv3 object
:return: a new YOLOv3 object
"""
class YOLOv3Clone(YOLOv3):
def __init__(self, model):
self._model = model
clone_model = YOLOv3Clone(self._model.clone())
return clone_model
class MaskRCNN(PPYOLOE):
def __init__(self,
model_file,
params_file,
config_file,
runtime_option=None,
model_format=ModelFormat.PADDLE):
"""Load a MaskRCNN model exported by PaddleDetection.
:param model_file: (str)Path of model file, e.g fasterrcnn/model.pdmodel
:param params_file: (str)Path of parameters file, e.g fasterrcnn/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
:param config_file: (str)Path of configuration file for deployment, e.g ppyoloe/infer_cfg.yml
:param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU
:param model_format: (fastdeploy.ModelForamt)Model format of the loaded model
"""
super(PPYOLOE, self).__init__(runtime_option)
assert model_format == ModelFormat.PADDLE, "MaskRCNN model only support model format of ModelFormat.Paddle now."
self._model = C.vision.detection.MaskRCNN(
model_file, params_file, config_file, self._runtime_option,
model_format)
assert self.initialized, "MaskRCNN model initialize failed."
def batch_predict(self, images):
"""Detect a batch of input image list, batch_predict is not supported for maskrcnn now.
:param im: (list of numpy.ndarray) The input image list, each element is a 3-D array with layout HWC, BGR format
:return list of DetectionResult
"""
raise Exception(
"batch_predict is not supported for MaskRCNN model now.")
def clone(self):
"""Clone MaskRCNN object
:return: a new MaskRCNN object
"""
class MaskRCNNClone(MaskRCNN):
def __init__(self, model):
self._model = model
clone_model = MaskRCNNClone(self._model.clone())
return clone_model
class SSD(PPYOLOE):
def __init__(self,
model_file,
params_file,
config_file,
runtime_option=None,
model_format=ModelFormat.PADDLE):
"""Load a SSD model exported by PaddleDetection.
:param model_file: (str)Path of model file, e.g ssd/model.pdmodel
:param params_file: (str)Path of parameters file, e.g ssd/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
:param config_file: (str)Path of configuration file for deployment, e.g ppyoloe/infer_cfg.yml
:param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU
:param model_format: (fastdeploy.ModelForamt)Model format of the loaded model
"""
super(PPYOLOE, self).__init__(runtime_option)
assert model_format == ModelFormat.PADDLE, "SSD model only support model format of ModelFormat.Paddle now."
self._model = C.vision.detection.SSD(model_file, params_file,
config_file, self._runtime_option,
model_format)
assert self.initialized, "SSD model initialize failed."
def clone(self):
"""Clone SSD object
:return: a new SSD object
"""
class SSDClone(SSD):
def __init__(self, model):
self._model = model
clone_model = SSDClone(self._model.clone())
return clone_model
class PaddleYOLOv5(PPYOLOE):
def __init__(self,
model_file,
params_file,
config_file,
runtime_option=None,
model_format=ModelFormat.PADDLE):
"""Load a YOLOv5 model exported by PaddleDetection.
:param model_file: (str)Path of model file, e.g yolov5/model.pdmodel
:param params_file: (str)Path of parameters file, e.g yolov5/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
:param config_file: (str)Path of configuration file for deployment, e.g ppyoloe/infer_cfg.yml
:param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU
:param model_format: (fastdeploy.ModelForamt)Model format of the loaded model
"""
super(PPYOLOE, self).__init__(runtime_option)
assert model_format == ModelFormat.PADDLE, "PaddleYOLOv5 model only support model format of ModelFormat.Paddle now."
self._model = C.vision.detection.PaddleYOLOv5(
model_file, params_file, config_file, self._runtime_option,
model_format)
assert self.initialized, "PaddleYOLOv5 model initialize failed."
class PaddleYOLOv6(PPYOLOE):
def __init__(self,
model_file,
params_file,
config_file,
runtime_option=None,
model_format=ModelFormat.PADDLE):
"""Load a YOLOv6 model exported by PaddleDetection.
:param model_file: (str)Path of model file, e.g yolov6/model.pdmodel
:param params_file: (str)Path of parameters file, e.g yolov6/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
:param config_file: (str)Path of configuration file for deployment, e.g ppyoloe/infer_cfg.yml
:param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU
:param model_format: (fastdeploy.ModelForamt)Model format of the loaded model
"""
super(PPYOLOE, self).__init__(runtime_option)
assert model_format == ModelFormat.PADDLE, "PaddleYOLOv6 model only support model format of ModelFormat.Paddle now."
self._model = C.vision.detection.PaddleYOLOv6(
model_file, params_file, config_file, self._runtime_option,
model_format)
assert self.initialized, "PaddleYOLOv6 model initialize failed."
class PaddleYOLOv7(PPYOLOE):
def __init__(self,
model_file,
params_file,
config_file,
runtime_option=None,
model_format=ModelFormat.PADDLE):
"""Load a YOLOv7 model exported by PaddleDetection.
:param model_file: (str)Path of model file, e.g yolov7/model.pdmodel
:param params_file: (str)Path of parameters file, e.g yolov7/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
:param config_file: (str)Path of configuration file for deployment, e.g ppyoloe/infer_cfg.yml
:param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU
:param model_format: (fastdeploy.ModelForamt)Model format of the loaded model
"""
super(PPYOLOE, self).__init__(runtime_option)
assert model_format == ModelFormat.PADDLE, "PaddleYOLOv7 model only support model format of ModelFormat.Paddle now."
self._model = C.vision.detection.PaddleYOLOv7(
model_file, params_file, config_file, self._runtime_option,
model_format)
assert self.initialized, "PaddleYOLOv7 model initialize failed."
class PaddleYOLOv8(PPYOLOE):
def __init__(self,
model_file,
params_file,
config_file,
runtime_option=None,
model_format=ModelFormat.PADDLE):
"""Load a YOLOv8 model exported by PaddleDetection.
:param model_file: (str)Path of model file, e.g yolov8/model.pdmodel
:param params_file: (str)Path of parameters file, e.g yolov8/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
:param config_file: (str)Path of configuration file for deployment, e.g yolov8/infer_cfg.yml
:param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU
:param model_format: (fastdeploy.ModelForamt)Model format of the loaded model
"""
super(PPYOLOE, self).__init__(runtime_option)
assert model_format == ModelFormat.PADDLE, "PaddleYOLOv8 model only support model format of ModelFormat.Paddle now."
self._model = C.vision.detection.PaddleYOLOv8(
model_file, params_file, config_file, self._runtime_option,
model_format)
assert self.initialized, "PaddleYOLOv8 model initialize failed."
class RTMDet(PPYOLOE):
def __init__(self,
model_file,
params_file,
config_file,
runtime_option=None,
model_format=ModelFormat.PADDLE):
"""Load a RTMDet model exported by PaddleDetection.
:param model_file: (str)Path of model file, e.g rtmdet/model.pdmodel
:param params_file: (str)Path of parameters file, e.g rtmdet/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
:param config_file: (str)Path of configuration file for deployment, e.g ppyoloe/infer_cfg.yml
:param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU
:param model_format: (fastdeploy.ModelForamt)Model format of the loaded model
"""
super(PPYOLOE, self).__init__(runtime_option)
assert model_format == ModelFormat.PADDLE, "RTMDet model only support model format of ModelFormat.Paddle now."
self._model = C.vision.detection.RTMDet(
model_file, params_file, config_file, self._runtime_option,
model_format)
assert self.initialized, "RTMDet model initialize failed."
class CascadeRCNN(PPYOLOE):
def __init__(self,
model_file,
params_file,
config_file,
runtime_option=None,
model_format=ModelFormat.PADDLE):
"""Load a CascadeRCNN model exported by PaddleDetection.
:param model_file: (str)Path of model file, e.g cascadercnn/model.pdmodel
:param params_file: (str)Path of parameters file, e.g cascadercnn/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
:param config_file: (str)Path of configuration file for deployment, e.g ppyoloe/infer_cfg.yml
:param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU
:param model_format: (fastdeploy.ModelForamt)Model format of the loaded model
"""
super(PPYOLOE, self).__init__(runtime_option)
assert model_format == ModelFormat.PADDLE, "CascadeRCNN model only support model format of ModelFormat.Paddle now."
self._model = C.vision.detection.CascadeRCNN(
model_file, params_file, config_file, self._runtime_option,
model_format)
assert self.initialized, "CascadeRCNN model initialize failed."
class PSSDet(PPYOLOE):
def __init__(self,
model_file,
params_file,
config_file,
runtime_option=None,
model_format=ModelFormat.PADDLE):
"""Load a PSSDet model exported by PaddleDetection.
:param model_file: (str)Path of model file, e.g pssdet/model.pdmodel
:param params_file: (str)Path of parameters file, e.g pssdet/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
:param config_file: (str)Path of configuration file for deployment, e.g ppyoloe/infer_cfg.yml
:param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU
:param model_format: (fastdeploy.ModelForamt)Model format of the loaded model
"""
super(PPYOLOE, self).__init__(runtime_option)
assert model_format == ModelFormat.PADDLE, "PSSDet model only support model format of ModelFormat.Paddle now."
self._model = C.vision.detection.PSSDet(
model_file, params_file, config_file, self._runtime_option,
model_format)
assert self.initialized, "PSSDet model initialize failed."
class RetinaNet(PPYOLOE):
def __init__(self,
model_file,
params_file,
config_file,
runtime_option=None,
model_format=ModelFormat.PADDLE):
"""Load a RetinaNet model exported by PaddleDetection.
:param model_file: (str)Path of model file, e.g retinanet/model.pdmodel
:param params_file: (str)Path of parameters file, e.g retinanet/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
:param config_file: (str)Path of configuration file for deployment, e.g ppyoloe/infer_cfg.yml
:param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU
:param model_format: (fastdeploy.ModelForamt)Model format of the loaded model
"""
super(PPYOLOE, self).__init__(runtime_option)
assert model_format == ModelFormat.PADDLE, "RetinaNet model only support model format of ModelFormat.Paddle now."
self._model = C.vision.detection.RetinaNet(
model_file, params_file, config_file, self._runtime_option,
model_format)
assert self.initialized, "RetinaNet model initialize failed."
class PPYOLOESOD(PPYOLOE):
def __init__(self,
model_file,
params_file,
config_file,
runtime_option=None,
model_format=ModelFormat.PADDLE):
"""Load a PPYOLOESOD model exported by PaddleDetection.
:param model_file: (str)Path of model file, e.g ppyoloesod/model.pdmodel
:param params_file: (str)Path of parameters file, e.g ppyoloesod/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
:param config_file: (str)Path of configuration file for deployment, e.g ppyoloe/infer_cfg.yml
:param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU
:param model_format: (fastdeploy.ModelForamt)Model format of the loaded model
"""
super(PPYOLOE, self).__init__(runtime_option)
assert model_format == ModelFormat.PADDLE, "PPYOLOESOD model only support model format of ModelFormat.Paddle now."
self._model = C.vision.detection.PPYOLOESOD(
model_file, params_file, config_file, self._runtime_option,
model_format)
assert self.initialized, "PPYOLOESOD model initialize failed."
class FCOS(PPYOLOE):
def __init__(self,
model_file,
params_file,
config_file,
runtime_option=None,
model_format=ModelFormat.PADDLE):
"""Load a FCOS model exported by PaddleDetection.
:param model_file: (str)Path of model file, e.g fcos/model.pdmodel
:param params_file: (str)Path of parameters file, e.g fcos/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
:param config_file: (str)Path of configuration file for deployment, e.g ppyoloe/infer_cfg.yml
:param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU
:param model_format: (fastdeploy.ModelForamt)Model format of the loaded model
"""
super(PPYOLOE, self).__init__(runtime_option)
assert model_format == ModelFormat.PADDLE, "FCOS model only support model format of ModelFormat.Paddle now."
self._model = C.vision.detection.FCOS(
model_file, params_file, config_file, self._runtime_option,
model_format)
assert self.initialized, "FCOS model initialize failed."
class TTFNet(PPYOLOE):
def __init__(self,
model_file,
params_file,
config_file,
runtime_option=None,
model_format=ModelFormat.PADDLE):
"""Load a TTFNet model exported by PaddleDetection.
:param model_file: (str)Path of model file, e.g ttfnet/model.pdmodel
:param params_file: (str)Path of parameters file, e.g ttfnet/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
:param config_file: (str)Path of configuration file for deployment, e.g ppyoloe/infer_cfg.yml
:param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU
:param model_format: (fastdeploy.ModelForamt)Model format of the loaded model
"""
super(PPYOLOE, self).__init__(runtime_option)
assert model_format == ModelFormat.PADDLE, "TTFNet model only support model format of ModelFormat.Paddle now."
self._model = C.vision.detection.TTFNet(
model_file, params_file, config_file, self._runtime_option,
model_format)
assert self.initialized, "TTFNet model initialize failed."
class TOOD(PPYOLOE):
def __init__(self,
model_file,
params_file,
config_file,
runtime_option=None,
model_format=ModelFormat.PADDLE):
"""Load a TOOD model exported by PaddleDetection.
:param model_file: (str)Path of model file, e.g tood/model.pdmodel
:param params_file: (str)Path of parameters file, e.g tood/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
:param config_file: (str)Path of configuration file for deployment, e.g ppyoloe/infer_cfg.yml
:param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU
:param model_format: (fastdeploy.ModelForamt)Model format of the loaded model
"""
super(PPYOLOE, self).__init__(runtime_option)
assert model_format == ModelFormat.PADDLE, "TOOD model only support model format of ModelFormat.Paddle now."
self._model = C.vision.detection.TOOD(
model_file, params_file, config_file, self._runtime_option,
model_format)
assert self.initialized, "TOOD model initialize failed."
class GFL(PPYOLOE):
def __init__(self,
model_file,
params_file,
config_file,
runtime_option=None,
model_format=ModelFormat.PADDLE):
"""Load a GFL model exported by PaddleDetection.
:param model_file: (str)Path of model file, e.g gfl/model.pdmodel
:param params_file: (str)Path of parameters file, e.g gfl/model.pdiparams, if the model_fomat is ModelFormat.ONNX, this param will be ignored, can be set as empty string
:param config_file: (str)Path of configuration file for deployment, e.g ppyoloe/infer_cfg.yml
:param runtime_option: (fastdeploy.RuntimeOption)RuntimeOption for inference this model, if it's None, will use the default backend on CPU
:param model_format: (fastdeploy.ModelForamt)Model format of the loaded model
"""
super(PPYOLOE, self).__init__(runtime_option)
assert model_format == ModelFormat.PADDLE, "GFL model only support model format of ModelFormat.Paddle now."
self._model = C.vision.detection.GFL(
model_file, params_file, config_file, self._runtime_option,
model_format)
assert self.initialized, "GFL model initialize failed."