Spaces:
Runtime error
Runtime error
Download main.py from Akbartus/FastAPIExample: direct link, hf CLI and curl.
- Browser
- Download file 526 Bytes
-
https://huggingface.co/spaces/Akbartus/FastAPIExample/resolve/ff879e2a9d4ece0df062b0847318c41465a83c14/main.py
- Command line
-
hf download hf://spaces/Akbartus/FastAPIExample@ff879e2a9d4ece0df062b0847318c41465a83c14/main.py
-
curl -L -o main.py https://huggingface.co/spaces/Akbartus/FastAPIExample/resolve/ff879e2a9d4ece0df062b0847318c41465a83c14/main.py
526 Bytes
| from model import model_pipeline | |
| from typing import Union | |
| from fastapi import FastAPI, UploadFile | |
| import io | |
| from PIL import Image | |
| import os | |
| os.environ['TRANSFORMERS_CACHE'] = '/blabla/cache/' | |
| app = FastAPI() | |
| def read_root(): | |
| return {"Hello": "World"} | |
| def ask(text: str, image: UploadFile): | |
| content = image.file.read() | |
| image = Image.open(io.BytesIO(content)) | |
| # image = Image.open(image.file) | |
| result = model_pipeline(text, image) | |
| return {"answer": result} |