Skip to content

Instantly share code, notes, and snippets.

from fastapi import FastAPI, Request, Body
import joblib
import numpy as np
import json
app = FastAPI()
@app.get("/")
async def read_main():
from locust import HttpUser, between, task
class Prediction(HttpUser):
wait_time = between(1, 1)
@task
def health(self):
self.client.get("/health")
from fastapi import FastAPI, Request, Body
import joblib
import numpy as np
from pydantic import BaseModel
class User(BaseModel):
age: int
bmi: float
version: '3.5'
services:
db:
restart: always
image: postgres:13.5-alpine
container_name: postgres_container
environment:
POSTGRES_USER: ${POSTGRES_USER:-postgres}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-pass12345}
from annoy import AnnoyIndex
f = len(img_array_resut[0])
t = AnnoyIndex(f, 'euclidean')
print(f"Number of features {f}")
print("Append the item vectors")
i = 0
for v in tqdm(img_array_resut):
t.add_item(i, v)
def open_image(path):
im = Image.open(path)
X = preprocess(im, model.input_shape[1:3])
X = reshape([X])
return X
def preprocess(img,input_size):
nimg = img.convert('RGB').resize(input_size, resample= 0)
img_arr = (np.array(nimg))/255
return img_arr
SELECT customer_id,
COUNT(payment_id) count_trans,
SUM(amount) total_amount
FROM payment
GROUP by 1
SELECT customer_id, payment_date as last_payment_date
FROM (
SELECT customer_id,
payment_date,
DENSE_RANK() over(PARTITION by customer_id ORDER BY payment_date DESC) as rnk_
FROM payment) as lpd
WHERE rnk_ = 1
ORDER BY random();
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.