Download application/server/main.py from segestic/BrainTum: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/spaces/segestic/BrainTum/resolve/main/application/server/main.py
- Command line
-
hf download hf://spaces/segestic/BrainTum/application/server/main.py
-
curl -L -o main.py https://huggingface.co/spaces/segestic/BrainTum/resolve/main/application/server/main.py
1.04 kB
| import uvicorn | |
| from fastapi import FastAPI, File, UploadFile | |
| from starlette.responses import RedirectResponse | |
| from application.components import predict, read_imagefile | |
| from application.schema import Symptom | |
| from application.components.prediction import symptom_check | |
| app_desc = """<h2>Use this 🦠 API by uploading any image with `predict/image`</h2> | |
| <h4> 🦠 Brain Tumor Prediction API - it is just for research learning</h4> | |
| <br>by Olusegun Odewole - AIOT lab""" | |
| app = FastAPI(title=' 🦠 Brain Tumor Prediction API', description=app_desc) | |
| async def index(): | |
| return RedirectResponse(url="/docs") | |
| async def predict_api(file: UploadFile = File(...)): | |
| extension = file.filename.split(".")[-1] in ("jpg", "jpeg", "png") | |
| if not extension: | |
| return "Image must be jpg or png format!" | |
| image = read_imagefile(await file.read()) | |
| prediction = predict(image) | |
| return prediction | |
| if __name__ == "__main__": | |
| uvicorn.run(app, debug=True) | |