CoolFace
Apppublic

DeepVen/streamlit

sourceHugging Facemitupdated 3y agoView on Hugging Face
0likes
app.py20 linesDownload Raw Back to root
1from fastapi import FastAPI2from transformers import pipeline3 4 5# NOTE - we configure docs_url to serve the interactive Docs at the root path6# of the app. This way, we can use the docs as a landing page for the app on Spaces.7app = FastAPI(docs_url="/")8 9pipe = pipeline("text2text-generation", model="google/flan-t5-small")10 11 12@app.get("/generate")13def generate(text: str):14    """15    Using the text2text-generation pipeline from `transformers`, generate text16    from the given input text. The model used is `google/flan-t5-small`, which17    can be found [here](https://huggingface.co/google/flan-t5-small).18    """19    output = pipe(text)20    return {"output": output[0]["generated_text"]}