File size: 488 Bytes
ba74f1a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import os
from fastapi import FastAPI, File, UploadFile, Form
from scripts.blip2_infer import describe_image
import shutil
app = FastAPI()
@app.post("/vision")
async def process_vision(image: UploadFile = File(...), prompt: str = Form("Describe this image.")):
temp_path = "frame.jpg"
with open(temp_path, "wb") as f:
shutil.copyfileobj(image.file, f)
desc = describe_image(temp_path, prompt)
os.remove(temp_path)
return {"description": desc}
|