Example in notebook throws INVALID_ARGUMENT error
Hello,
The code snippet that I was using was working up to 2 weeks ago that I checked and it is almost identical with the example notebook.
import os
import io
import warnings
from PIL import Image
from stability_sdk import client
import stability_sdk.interfaces.gooseai.generation.generation_pb2 as generation
from dotenv import load_dotenv
load_dotenv()
def main():
stability_api = client.StabilityInference(
key=os.environ["STABILITY_KEY"],
verbose=True,
)
answers = stability_api.generate(
prompt="houston, we are a 'go' for launch!",
seed=34567, # if provided, specifying a random seed makes results deterministic
steps=30, # defaults to 50 if not specified
)
for resp in answers:
for artifact in resp.artifacts:
if artifact.finish_reason == generation.FILTER:
return warnings.warn(
"Your request activated the API's safety filters and \
could not be processed."
"Please modify the prompt and try again."
)
if artifact.type == generation.ARTIFACT_IMAGE:
image_name = "rocket"
path = os.environ("IMAGE_DIR") + image_name + ".png"
img = Image.open(io.BytesIO(artifact.binary))
img.save(path)
print("done")
if __name__ == "__main__":
main()
I believed that the only parameter that you need to input is the prompt. It throws the error:
Traceback (most recent call last):
File "/Users/blackbak/Github/Suede/Exploratory/stabilityapi.py", line 42, in
I downgraded Python to 3.8 and it works. Are newer python versions not supported?
I hit the same error from python pkg (stability_sdk) started this week (Nov 7th). It seems a breaking change in the package/API. :( Downgrade Python doesn't seem a good long term solution.
facing similar issues recently