Download task/segmentation_task.py from ryali93/hf_segm_test: direct link, hf CLI and curl.
- Browser
- Download file 468 Bytes
-
https://huggingface.co/ryali93/hf_segm_test/resolve/main/task/segmentation_task.py
- Command line
-
hf download hf://ryali93/hf_segm_test/task/segmentation_task.py
-
curl -L -o segmentation_task.py https://huggingface.co/ryali93/hf_segm_test/resolve/main/task/segmentation_task.py
468 Bytes
| # task/segmentation_task.py | |
| from model.lightning_unet import LightningUNet | |
| import torch | |
| class SegmentationTask: | |
| def __init__(self, model_path: str): | |
| self.model = LightningUNet() | |
| self.model.load_state_dict(torch.load(model_path)) | |
| self.model.eval() | |
| def predict(self, image): | |
| with torch.no_grad(): | |
| output = self.model(image) | |
| # Aquí puedes agregar post-procesamiento si es necesario | |
| return output | |