sagar4tech's picture
Update main.py
d9e1541 verified
raw
history blame contribute delete
663 Bytes
## mounting Gradio on fast api
from fastapi import FastAPI
import gradio as gr
from inference import demo
# Define your predict function
def predict(text):
# Your prediction logic here
return text[::-1] # Just an example, reverse the input text
# Create a Gradio interface
demo = gr.Interface(
fn=predict,
inputs='text',
outputs='text',
title='Text Reversal' # Add a title for the Gradio UI
)
# Create a FastAPI app
app = FastAPI()
# Define your root route
@app.get('/')
async def root():
return 'Gradio is running', 200
# Mount the Gradio interface onto the FastAPI app
app = gr.mount_gradio_app(app, demo, path='/gradio')