Skip to content

Commit

Permalink
feat(model): use latest whisper with turbo
Browse files Browse the repository at this point in the history
  • Loading branch information
eoinsha committed Oct 3, 2024
1 parent 982fc4f commit aca95f6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 9 additions & 8 deletions whisper-image/app/predictor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
app = flask.Flask(__name__)

s3_client = boto3.client("s3")
model_name = "medium.en"
default_model_name = "turbo"


@app.route("/ping", methods=["GET"])
def ping():
Expand All @@ -32,10 +33,10 @@ def execution_parameters():
status = 200
return flask.Response(response="{}", status=status, mimetype="application/json")


@app.route("/invocations", methods=["POST"])
def transformation():
"""Do an inference on a single batch of data.
"""
"""Do an inference on a single batch of data."""
content_type = flask.request.content_type
request_data = flask.request.data
logger.info(f"transformation: {content_type} {request_data}")
Expand All @@ -47,11 +48,14 @@ def transformation():
input_dict = json.loads(data)
else:
return flask.Response(
response="The predictor only supports application/json content type", status=415, mimetype="text/plain"
response="The predictor only supports application/json content type",
status=415,
mimetype="text/plain",
)

bucket_name = input_dict["bucket_name"]
object_key = input_dict["object_key"]
model_name = input_dict.get("model_name", default_model_name)
fd, filename = tempfile.mkstemp()
try:
os.close(fd)
Expand All @@ -66,9 +70,6 @@ def transformation():
finally:
os.unlink(filename)

payload = {
**input_dict,
"result": result
}
payload = {**input_dict, "result": result}
response = json.dumps(payload)
return flask.Response(response=response, status=200, mimetype="application/json")
4 changes: 2 additions & 2 deletions whisper-image/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
boto3==1.24.96
Flask==3.0.1
gunicorn==21.2.0
openai-whisper==20230918
gunicorn==21.2.0
openai-whisper==20240930

0 comments on commit aca95f6

Please sign in to comment.