Spaces:
Sleeping
Sleeping
File size: 475 Bytes
f7934f7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import asyncio
from fastapi import FastAPI
from fastapi.responses import JSONResponse
from gradio_client import Client
app = FastAPI()
client = Client("vikhyatk/moondream1")
def get_caption(image: str, question: str):
result = client.predict(image, question, api_name="/answer_question")
return result.strip()
@app.post("/caption")
async def captioning(image: str, question):
return JSONResponse({"caption": asyncio.to_thread(get_caption, image, question)})
|