Unverified Commit 9e138cb0 authored by Kiersten Stokes's avatar Kiersten Stokes Committed by GitHub
Browse files

[Misc][Build] Lazy load cv2 in nemotron_parse.py (#33189)


Signed-off-by: default avatarkiersten-stokes <kierstenstokes@gmail.com>
parent f9d03599
...@@ -11,7 +11,6 @@ import math ...@@ -11,7 +11,6 @@ import math
from collections.abc import Iterable, Mapping, Sequence from collections.abc import Iterable, Mapping, Sequence
from typing import Annotated, Literal from typing import Annotated, Literal
import cv2
import numpy as np import numpy as np
import torch import torch
import torch.nn as nn import torch.nn as nn
...@@ -416,6 +415,8 @@ class NemotronParseImageProcessor: ...@@ -416,6 +415,8 @@ class NemotronParseImageProcessor:
else: else:
self.target_height = self.target_width = int(self.final_size) self.target_height = self.target_width = int(self.final_size)
import cv2
self.transform = A.Compose( self.transform = A.Compose(
[ [
A.PadIfNeeded( A.PadIfNeeded(
...@@ -457,6 +458,8 @@ class NemotronParseImageProcessor: ...@@ -457,6 +458,8 @@ class NemotronParseImageProcessor:
new_height = int(new_width / aspect_ratio) new_height = int(new_width / aspect_ratio)
# Use cv2.INTER_LINEAR like the original # Use cv2.INTER_LINEAR like the original
import cv2
return cv2.resize( return cv2.resize(
image, (new_width, new_height), interpolation=cv2.INTER_LINEAR image, (new_width, new_height), interpolation=cv2.INTER_LINEAR
) )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment