i-dont-hug-face
commited on
Commit
•
af679a9
1
Parent(s):
47d7b51
Update inference.py
Browse files- inference.py +1 -6
inference.py
CHANGED
@@ -14,7 +14,6 @@ def model_fn(model_dir, context=None):
|
|
14 |
|
15 |
def input_fn(input_data, content_type, context=None):
|
16 |
"""Deserialize the input data."""
|
17 |
-
logging.info("Entering input_fn")
|
18 |
if content_type == 'application/x-image' or content_type == 'application/octet-stream':
|
19 |
image = Image.open(io.BytesIO(input_data))
|
20 |
return image
|
@@ -23,7 +22,6 @@ def input_fn(input_data, content_type, context=None):
|
|
23 |
|
24 |
def predict_fn(data, model_data, context=None):
|
25 |
"""Apply the model to the input data."""
|
26 |
-
logging.info("Entering predict_fn")
|
27 |
model, processor, device = model_data
|
28 |
|
29 |
# Preprocess the image
|
@@ -55,10 +53,7 @@ def predict_fn(data, model_data, context=None):
|
|
55 |
|
56 |
def output_fn(prediction, accept):
|
57 |
"""Serialize the prediction output."""
|
58 |
-
logging.info("Entering output_fn")
|
59 |
if accept == 'application/json':
|
60 |
return json.dumps(prediction), 'application/json'
|
61 |
else:
|
62 |
-
raise ValueError(f"Unsupported response content type: {accept}")
|
63 |
-
|
64 |
-
|
|
|
14 |
|
15 |
def input_fn(input_data, content_type, context=None):
|
16 |
"""Deserialize the input data."""
|
|
|
17 |
if content_type == 'application/x-image' or content_type == 'application/octet-stream':
|
18 |
image = Image.open(io.BytesIO(input_data))
|
19 |
return image
|
|
|
22 |
|
23 |
def predict_fn(data, model_data, context=None):
|
24 |
"""Apply the model to the input data."""
|
|
|
25 |
model, processor, device = model_data
|
26 |
|
27 |
# Preprocess the image
|
|
|
53 |
|
54 |
def output_fn(prediction, accept):
|
55 |
"""Serialize the prediction output."""
|
|
|
56 |
if accept == 'application/json':
|
57 |
return json.dumps(prediction), 'application/json'
|
58 |
else:
|
59 |
+
raise ValueError(f"Unsupported response content type: {accept}")
|
|
|
|