Skip to content

Commit 13c7c3a

Browse files
committed
Remove watermark
Change-Id: Ie8f26fb7c4eb26c4cf7bdd746b608a652dfbd5a6
1 parent c72aa6b commit 13c7c3a

File tree

2 files changed

+2
-44
lines changed

2 files changed

+2
-44
lines changed

google/generativeai/types/image_types/_image_types.py

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from typing import Any, Dict, Optional, Union
99

1010
from google.generativeai import protos
11-
from google.generativeai import client
1211

1312
# pylint: disable=g-import-not-at-top
1413
if typing.TYPE_CHECKING:
@@ -38,7 +37,7 @@
3837
ImageType = Union["Image", "PIL.Image.Image", "IPython.display.Image"]
3938
# pylint: enable=g-import-not-at-top
4039

41-
__all__ = ["Image", "GeneratedImage", "check_watermark", "CheckWatermarkResult", "ImageType"]
40+
__all__ = ["Image", "GeneratedImage", "ImageType"]
4241

4342

4443
def _pil_to_blob(image: PIL.Image.Image) -> protos.Blob:
@@ -121,46 +120,6 @@ def __bool__(self):
121120
raise ValueError(f"Unrecognized result: {decision}")
122121

123122

124-
def check_watermark(
125-
img: Union[pathlib.Path, ImageType], model_id: str = "models/image-verification-001"
126-
) -> "CheckWatermarkResult":
127-
"""Checks if an image has a Google-AI watermark.
128-
129-
Args:
130-
img: can be a `pathlib.Path` or a `PIL.Image.Image`, `IPython.display.Image`, or `google.generativeai.Image`.
131-
model_id: Which version of the image-verification model to send the image to.
132-
133-
Returns:
134-
135-
"""
136-
if isinstance(img, Image):
137-
pass
138-
elif isinstance(img, pathlib.Path):
139-
img = Image.load_from_file(img)
140-
elif IPython.display is not None and isinstance(img, IPython.display.Image):
141-
img = Image(image_bytes=img.data)
142-
elif PIL.Image is not None and isinstance(img, PIL.Image.Image):
143-
blob = _pil_to_blob(img)
144-
img = Image(image_bytes=blob.data)
145-
elif isinstance(img, protos.Blob):
146-
img = Image(image_bytes=img.data)
147-
else:
148-
raise TypeError(
149-
f"Not implemented: Could not convert a {type(img)} into `Image`\n {img=}"
150-
)
151-
152-
prediction_client = client.get_default_prediction_client()
153-
if not model_id.startswith("models/"):
154-
model_id = f"models/{model_id}"
155-
156-
instance = {"image": {"bytesBase64Encoded": base64.b64encode(img._loaded_bytes).decode()}}
157-
parameters = {"watermarkVerification": True}
158-
159-
response = prediction_client.predict(
160-
model=model_id, instances=[instance], parameters=parameters
161-
)
162-
163-
return CheckWatermarkResult(response.predictions)
164123

165124

166125
class Image:

google/generativeai/vision_models/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@
1414
#
1515
"""Classes for working with vision models."""
1616

17-
from google.generativeai.types.image_types import check_watermark, Image, GeneratedImage
17+
from google.generativeai.types.image_types import Image, GeneratedImage
1818

1919
from google.generativeai.vision_models._vision_models import (
2020
ImageGenerationModel,
2121
ImageGenerationResponse,
2222
)
2323

2424
__all__ = [
25-
"check_watermark",
2625
"Image",
2726
"GeneratedImage",
2827
"ImageGenerationModel",

0 commit comments

Comments
 (0)