Skip to content

Instantly share code, notes, and snippets.

View ashmibanerjee's full-sized avatar

Ashmi Banerjee ashmibanerjee

View GitHub Profile
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")
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)
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
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)