Stability-AI / stability-sdk

SDK for interacting with stability.ai APIs (e.g. stable diffusion inference)
https://platform.stability.ai/
MIT License
2.43k stars 339 forks source link

Bug - Enum ArtifactType has no name defined for value 8 #149

Closed ulysses-potiguara closed 1 year ago

ulysses-potiguara commented 1 year ago

I'm getting the error "Enum ArtifactType has no name defined for value 8" when running the sample code for Text-to-Image.

stability_api = client.StabilityInference(
    key=os.environ['STABILITY_KEY'],
    verbose=True
)
answers = stability_api.generate(
    prompt="a humble house, photorealistic",
    steps=100,
    width=512,
    height=512,
    samples=4
)

for resp in answers:
    for artifact in resp.artifacts:
        if artifact.finish_reason == generation.FILTER:
            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:
            img = Image.open(io.BytesIO(artifact.binary))
            img.save(str(artifact.seed)+ ".png")

The error appears when trying to get artifacts at for artifact in resp.artifacts:. for resp in answers performs the loop just fine.

Although no images is returned, the credits are still consumed.

eshunevych commented 1 year ago

Facing the same issue here on 0.2.7, but an update to the latest version 0.3.0 fixed this error.

ulysses-potiguara commented 1 year ago

Facing the same issue here on 0.2.7, but an update to the latest version 0.3.0 fixed this error.

Thanks for bringing that up. That solved. I noticed stability-sdk version on Poetry was locked.

Anyway, I believe this kind of updates shouldn't have to break the API.

sanealytics commented 1 year ago

+1 agree... should have been in the release notes