File size: 663 Bytes
5626163
 
 
 
 
d9e1541
5626163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

## 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')