Spaces:
Sleeping
Sleeping
Download app.py from rmz0312/text2text_Docker: direct link, hf CLI and curl.
- Browser
- Download file 379 Bytes
-
https://huggingface.co/spaces/rmz0312/text2text_Docker/resolve/main/app.py
- Command line
-
hf download hf://spaces/rmz0312/text2text_Docker/app.py
-
curl -L -o app.py https://huggingface.co/spaces/rmz0312/text2text_Docker/resolve/main/app.py
379 Bytes
| from fastapi import FastAPI | |
| from transformers import pipeline | |
| app = FastAPI() | |
| pipeline = pipeline("text2text-generation", model="google/flan-t5-small") | |
| def home(): | |
| return {"message": "Welcome to the Text Generation API!"} | |
| def generate(text: str): | |
| output = pipeline(text) | |
| return {"generated_text": output[0]['generated_text']} | |