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
# pip install fastapi uvicorn httpx | |
import asyncio | |
import httpx | |
from fastapi import FastAPI | |
app = FastAPI() | |
async def fetch_data(url: str): |
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
<script> | |
const message = function() { | |
console.log("This message is shown after 3 seconds"); | |
alert(1); | |
} | |
setTimeout(message, 3000); | |
</script> |
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
type Category = { | |
name: string | |
tags: string[] | |
} | |
type Product = { | |
name: string | |
description: string | |
} | |
let products: Array<Product> =[ |
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
const sort = <Element extends {name: string}>(array: Array<Element>) => { | |
return array.sort((a: Element, b: Element) => { | |
if (a.name < b.name){ | |
return -1; | |
} | |
if (a.name > b.name){ | |
return 1; | |
} | |
return 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
type Category = { | |
name: string | |
} | |
const categories:Array<Category> = [ | |
{ | |
name: "Travel" | |
}, | |
{ | |
name: "Electronics" |
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
- kind: deployment | |
name: boston-housing | |
- kind: api | |
name: linear-regression | |
model: s3://cortex-07af1aa182/boston_housing/linear_regression.onnx | |
request_handler: boston_handler.py |
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 pydantic import BaseModel | |
import numpy as np | |
class HousingFeatures(BaseModel): | |
CRIM: float | |
ZN: float | |
INDUS: float | |
CHAS: float |
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
# Download | |
curl -O https://raw.githubusercontent.com/cortexlabs/cortex/0.8/cortex.sh | |
# Change permissions | |
chmod +x cortex.sh | |
# Install the Cortex CLI on your machine | |
./cortex.sh install cli | |
# Set AWS credentials | |
export AWS_ACCESS_KEY_ID=*** | |
export AWS_SECRET_ACCESS_KEY=*** | |
# Configure AWS instance settings (at least 4GB memory) |
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
{ | |
"apiVersion": "machinelearning.seldon.io/v1alpha2", | |
"kind": "SeldonDeployment", | |
"metadata": { | |
"labels": { | |
"app": "seldon" | |
}, | |
"name": "seldon-emotion" | |
}, | |
"spec": { |
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 PIL import Image | |
import numpy as np | |
import requests | |
path_to_image = "images/smile.jpg" | |
image = Image.open(path_to_image).convert('L') | |
resized = image.resize((64, 64)) | |
values = np.array(resized).reshape(1, 1, 64, 64) | |
req = requests.post("http://localhost:5000/predict", json={"data":{"ndarray": values.tolist()}}) |
NewerOlder