Spaces:
Runtime error
Runtime error
Download app.py from win2win/8-epochs-classifier-api: direct link, hf CLI and curl.
- Browser
- Download file 473 Bytes
-
https://huggingface.co/spaces/win2win/8-epochs-classifier-api/resolve/main/app.py
- Command line
-
hf download hf://spaces/win2win/8-epochs-classifier-api/app.py
-
curl -L -o app.py https://huggingface.co/spaces/win2win/8-epochs-classifier-api/resolve/main/app.py
473 Bytes
| from fastapi import FastAPI | |
| from transformers import pipeline | |
| import gradio as gr | |
| app = FastAPI() | |
| model = pipeline("text-classification", model="win2win/3-epochs-classifier-ver2") | |
| # Custom endpoint | |
| async def api_predict(text: str): | |
| return model(text) | |
| # Gradio interface | |
| def predict(text): | |
| return model(text) | |
| io = gr.Interface(fn=predict, inputs="text", outputs="json") | |
| # Mount both endpoints | |
| app = gr.mount_gradio_app(app, io, path="/") |