kandi1clickkits commited on
Commit
77770c5
·
1 Parent(s): 813e8a0

added code

Browse files
Files changed (1) hide show
  1. main.py +24 -17
main.py CHANGED
@@ -1,21 +1,28 @@
1
- import gradio as gr
2
- import pandas as pd
 
 
 
 
3
 
4
- simple = pd.DataFrame(
5
- {
6
- "item": ["A", "B", "C", "D", "E", "F", "G", "H", "I"],
7
- "inventory": [28, 55, 43, 91, 81, 53, 19, 87, 52],
8
- }
9
- )
10
 
11
- with gr.Blocks() as demo:
12
- gr.BarPlot(
13
- value=simple,
14
- x="item",
15
- y="inventory",
16
- title="Simple Bar Plot",
17
- container=False,
 
 
 
 
 
 
18
  )
19
 
20
- if __name__ == "__main__":
21
- demo.launch(share=True)
 
 
 
1
+ from fastapi import FastAPI, HTTPException
2
+ from fastapi.responses import HTMLResponse
3
+ import matplotlib.pyplot as plt
4
+ from io import BytesIO
5
+ import base64
6
+ from gradio_client import Client
7
 
8
+ app = FastAPI()
 
 
 
 
 
9
 
10
+ @app.post("/predict")
11
+ async def predict(
12
+ name1: str, score1: int,
13
+ name2: str, score2: int,
14
+ name3: str, score3: int,
15
+ name4: str, score4: int,
16
+ name5: str, score5: int
17
+ ):
18
+ # Create a Gradio client and make a prediction
19
+ gradio_client = Client("https://deepak6593-gradio-app.hf.space/--replicas/9890g/")
20
+ result = gradio_client.predict(
21
+ name1, score1, name2, score2, name3, score3, name4, score4, name5, score5,
22
+ api_name="/predict"
23
  )
24
 
25
+ # HTML response containing the iframe
26
+ iframe_html = f'<iframe src="{result['plot']}" width="600" height="400"></iframe>'
27
+
28
+ return HTMLResponse(content=iframe_html)