File size: 444 Bytes
ae1d257
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from fastapi import FastAPI
from transformers import pipeline 

app = FastAPI()

# Initialize the pipeline with the correct model type
pipe = pipeline("text-generation", model="Qwen/Qwen2.5-VL-7B-Instruct", model_type="qwen2_5_vl")

@app.get("/")
def home():
    return {"message": "FastAPI is running!"}

@app.get("/generate")
def generate(text: str):
    output = pipe(text)
    return {"output": output[0]['generated_text']}