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="/")