This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"transcript": "How much do you get paid? Don't answer that out loud. But put a number in your head. Now, how much do you think the person sitting next to you gets paid? It turns out that pay transparency, sharing salaries openly across a company, makes for a better workplace for both the employee and for the organization. You see, keeping salary secret leads to what economists call information asymmetry. This is a situation where in a negotiation, one party has loads more information than the other. And in hiring or promotion or annual raise discussions, an employer can use that secrecy to save a lot of money. Imagine how much better you could negotiate for a raise if you knew everybody's salary. Now, I realized that letting people know what you make might feel uncomfortable, but isn't it less uncomfortable than always wondering if you're being discriminated against, or if your wife or your daughter or your sister is being paid unfairly? Openness remains the best way to ensure fairness. And pay transparen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import PIL.Image | |
import bentoml | |
from bentoml.io import Image, Text | |
preprocess_runner = bentoml.Runner(MyPreprocessRunnable) | |
model_a_runner = bentoml.xgboost.get('model_a:latest').to_runner() | |
model_b_runner = bentoml.pytorch.get('model_b:latest').to_runner() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bentoml.pytorch.save_model( | |
name="mnist", | |
model=model, | |
signature={ | |
"__call__": { | |
"batchable": True, | |
"batch_dim": (0, 0), | |
}, | |
}, | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import bentoml | |
import PIL.Image | |
import bentoml | |
from bentoml.io import Image, Text | |
transformers_runner = bentoml.transformers.get("sentiment_model:latest").to_runner() | |
ocr_runner = bentoml.easyocr.get("ocr_model:latest").to_runner() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service: "service:svc" # Same as the argument passed to `bentoml serve` | |
labels: | |
owner: bentoml-team | |
stage: dev | |
include: | |
- "*.py" # A pattern for matching which files to include in the bento | |
python: | |
packages: # Additional pip packages required by the service | |
- scikit-learn | |
- pandas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
requests.post( | |
"http://127.0.0.1:3000/classify", | |
headers={"content-type": "application/json"}, | |
data="[[5.9, 3, 5.1, 1.8]]" | |
).text | |
'[2]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import bentoml | |
from bentoml.io import NumpyNdarray | |
iris_clf_runner = bentoml.sklearn.get("iris_clf:latest").to_runner() | |
svc = bentoml.Service("iris_classifier", runners=[iris_clf_runner]) | |
@svc.api(input=NumpyNdarray(), output=NumpyNdarray()) | |
def classify(input_series: np.ndarray) -> np.ndarray: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Optional | |
def foo(format_layout: Optional[bool] = True): | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def load_model(filename: str, cache_folder: Union[str, Path]): | |
if isinstance(cache_folder, Path): | |
cache_folder = str(cache_folder) | |
model_path = os.join(filename, cache_folder) | |
model = torch.load(model_path) | |
return model |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Tuple | |
# Fails the type check ❌ | |
t: Tuple[int] = [1, 2, 3] | |
# Ok ✅ | |
t: Tuple[int, int, int] = [1, 2, 3] |
NewerOlder