This file contains hidden or 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 fastapi import FastAPI, Request, Body | |
| import joblib | |
| import numpy as np | |
| import json | |
| app = FastAPI() | |
| @app.get("/") | |
| async def read_main(): |
This file contains hidden or 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 locust import HttpUser, between, task | |
| class Prediction(HttpUser): | |
| wait_time = between(1, 1) | |
| @task | |
| def health(self): | |
| self.client.get("/health") |
This file contains hidden or 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 fastapi import FastAPI, Request, Body | |
| import joblib | |
| import numpy as np | |
| from pydantic import BaseModel | |
| class User(BaseModel): | |
| age: int | |
| bmi: float |
This file contains hidden or 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
| 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} |
This file contains hidden or 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 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) |
This file contains hidden or 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 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 |
This file contains hidden or 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
| SELECT customer_id, | |
| COUNT(payment_id) count_trans, | |
| SUM(amount) total_amount | |
| FROM payment | |
| GROUP by 1 |
This file contains hidden or 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
| 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.
NewerOlder