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 locust import HttpUser, task, between | |
from src.app.app import Img | |
import json | |
class PerformanceTests(HttpUser): | |
wait_time = between(1, 3) | |
@task(1) | |
def test_tf_predict(self): | |
sample = Img(img_url="https://raw.githubusercontent.com/pytorch/hub/master/images/dog.jpg") |
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 uvicorn | |
if __name__ == "__main__": | |
uvicorn.run("app.app:app", host="0.0.0.0", port=8000, log_level="debug", | |
proxy_headers=True, reload=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
from src.pred.models.tf_pred import * | |
from typing import Any | |
def tf_run_classifier(image: str) -> Any: | |
img = load_image(image) | |
if img is None: | |
return None | |
pred_results = tf_predict(img) | |
return pred_results |
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 fastapi import FastAPI, HTTPException | |
from src.pred.image_classifier import * | |
from pydantic import BaseModel | |
app = FastAPI(title="Image Classifier API") | |
class Img(BaseModel): | |
img_url: str | |
@app.post("/predict/tf/", status_code=200) |