stability-sdk icon indicating copy to clipboard operation
stability-sdk copied to clipboard

Example in notebook throws INVALID_ARGUMENT error

Open knitlybak opened this issue 3 years ago • 3 comments

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 main() File "/Users/blackbak/Github/Suede/Exploratory/stabilityapi.py", line 23, in main for resp in answers: File "/opt/anaconda3/envs/suede/lib/python3.9/site-packages/stability_sdk/client.py", line 300, in generate for answer in self.stub.Generate(rq, **self.grpc_args): File "/opt/anaconda3/envs/suede/lib/python3.9/site-packages/grpc/_channel.py", line 426, in next return self._next() File "/opt/anaconda3/envs/suede/lib/python3.9/site-packages/grpc/_channel.py", line 826, in _next raise self grpc._channel._MultiThreadedRendezvous: <_MultiThreadedRendezvous of RPC that terminated with: status = StatusCode.INVALID_ARGUMENT details = "Must provide image parameters." debug_error_string = "UNKNOWN:Error received from peer ipv4:104.18.21.212:443 {created_time:"2022-10-21T13:21:01.529499-04:00", grpc_status:3, grpc_message:"Must provide image parameters."}"

knitlybak avatar Oct 21 '22 17:10 knitlybak

I downgraded Python to 3.8 and it works. Are newer python versions not supported?

knitlybak avatar Oct 21 '22 18:10 knitlybak

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.

Vivihung avatar Nov 11 '22 21:11 Vivihung

facing similar issues recently

Garinmckayl avatar Nov 22 '22 20:11 Garinmckayl