File size: 473 Bytes
8acfab4
7328228
 
 
3586c36
 
8acfab4
 
c504ae3
8acfab4
 
 
 
 
 
7328228
 
 
8acfab4
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
@app.post("/predict")
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="/")