Skip to content

Commit e920d0e

Browse files
author
Divyashree Sreepathihalli
committed
fix nlp import
1 parent 1b4e2ab commit e920d0e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

keras_cv/models/feature_extractor/clip/clip_processor.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
from keras_nlp.layers import StartEndPacker
1514

15+
try:
16+
from keras_nlp.layers import StartEndPacker
17+
except ImportError:
18+
keras_nlp = None
1619
from keras_cv.api_export import keras_cv_export
1720
from keras_cv.backend import keras
1821
from keras_cv.backend import ops
@@ -45,6 +48,11 @@ class CLIPProcessor:
4548
"""
4649

4750
def __init__(self, input_resolution, vocabulary, merges, **kwargs):
51+
if keras_nlp is None:
52+
raise ValueError(
53+
"ClipTokenizer requires keras-nlp. Please install "
54+
"using pip `pip install -U keras-nlp && pip install -U keras`"
55+
)
4856
self.input_resolution = input_resolution
4957
self.vocabulary = vocabulary
5058
self.merges = merges

0 commit comments

Comments
 (0)