| 43 | |
| 44 | |
| 45 | class PaddleXPredictor(Predictor): |
| 46 | def __init__(self, config_path): |
| 47 | from paddlex import create_pipeline |
| 48 | |
| 49 | super().__init__() |
| 50 | self.pipeline = create_pipeline(config_path) |
| 51 | |
| 52 | def _predict(self, batch_data): |
| 53 | results = list(self.pipeline.predict(batch_data)) |
| 54 | return "\n\n".join(res._to_markdown(pretty=False)["markdown_texts"] for res in results), len(results) |
| 55 | |
| 56 | def close(self): |
| 57 | self.pipeline.close() |
| 58 | |
| 59 | |
| 60 | def monitor_device(gpu_ids, gpu_metrics_list): |