mirror of
https://github.com/DS4SD/docling.git
synced 2025-07-27 04:24:45 +00:00
Update base_pipeline.py
Signed-off-by: jane-temcious <jane.temcious@iterate.ai>
This commit is contained in:
parent
5ab8792697
commit
1fdfb2bc50
@ -93,7 +93,8 @@ class BasePipeline(ABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def _unload(self, conv_res: ConversionResult):
|
def _unload(self, conv_res: ConversionResult):
|
||||||
pass
|
# Clear GPU memory after processingAdd commentMore actions
|
||||||
|
clear_gpu_memory()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
@ -196,13 +197,18 @@ class PaginatedPipeline(BasePipeline): # TODO this is a bad name.
|
|||||||
return conv_res
|
return conv_res
|
||||||
|
|
||||||
def _unload(self, conv_res: ConversionResult) -> ConversionResult:
|
def _unload(self, conv_res: ConversionResult) -> ConversionResult:
|
||||||
|
# Unload page backends
|
||||||
for page in conv_res.pages:
|
for page in conv_res.pages:
|
||||||
if page._backend is not None:
|
if page._backend is not None:
|
||||||
page._backend.unload()
|
page._backend.unload()
|
||||||
|
|
||||||
|
# Unload input backend
|
||||||
if conv_res.input._backend:
|
if conv_res.input._backend:
|
||||||
conv_res.input._backend.unload()
|
conv_res.input._backend.unload()
|
||||||
|
|
||||||
|
# Call parent _unload to clean up GPU memory
|
||||||
|
super()._unload(conv_res)
|
||||||
|
|
||||||
return conv_res
|
return conv_res
|
||||||
|
|
||||||
def _determine_status(self, conv_res: ConversionResult) -> ConversionStatus:
|
def _determine_status(self, conv_res: ConversionResult) -> ConversionStatus:
|
||||||
|
Loading…
Reference in New Issue
Block a user