Skip to content

Commit

Permalink
get mimetype from buffer with no descriptor - issue Stability-AI#125
Browse files Browse the repository at this point in the history
  • Loading branch information
gacogo committed Nov 19, 2022
1 parent 67b5cf2 commit 72882fa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/stability_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import logging
import time
import mimetypes
import magic

import grpc
from argparse import ArgumentParser, Namespace
Expand Down Expand Up @@ -86,7 +87,8 @@ def process_artifacts_from_answers(
for artifact in resp.artifacts:
artifact_start = time.time()
if artifact.type == generation.ARTIFACT_IMAGE:
ext = mimetypes.guess_extension(artifact.mime)
mime_type = magic.from_buffer(artifact.binary, mime=True)
ext = mime_type.split("/")[1]
contents = artifact.binary
elif artifact.type == generation.ARTIFACT_CLASSIFICATIONS:
ext = ".pb.json"
Expand Down

0 comments on commit 72882fa

Please sign in to comment.