Spaces:
Sleeping
Sleeping
Commit
·
bbf4d25
1
Parent(s):
29b936b
made changes to app.py
Browse files- app/main.py +15 -10
app/main.py
CHANGED
@@ -1,8 +1,9 @@
|
|
1 |
-
from fastapi import FastAPI, UploadFile, File, HTTPException
|
2 |
from uuid import uuid4
|
3 |
import io
|
4 |
from PIL import Image
|
5 |
from pydantic import BaseModel
|
|
|
6 |
|
7 |
# Import modules from the Uspark package
|
8 |
from app.chatbot import ChatbotSession
|
@@ -11,15 +12,6 @@ from app.database import save_chat_session, save_medseg_result
|
|
11 |
|
12 |
app = FastAPI(title="Uspark API")
|
13 |
|
14 |
-
import gradio as gr
|
15 |
-
|
16 |
-
def my_model(input_text):
|
17 |
-
return f"Processed: {input_text}"
|
18 |
-
|
19 |
-
iface = gr.Interface(fn=my_model, inputs="text", outputs="text")
|
20 |
-
iface.launch(server_name="0.0.0.0", server_port=7860)
|
21 |
-
|
22 |
-
|
23 |
# Ensure models are loaded from the 'models' directory within 'Uspark'
|
24 |
import sys
|
25 |
import os
|
@@ -73,3 +65,16 @@ async def medseg_endpoint(file: UploadFile = File(...)):
|
|
73 |
save_medseg_result(result_record)
|
74 |
|
75 |
return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI, UploadFile, File, HTTPException
|
2 |
from uuid import uuid4
|
3 |
import io
|
4 |
from PIL import Image
|
5 |
from pydantic import BaseModel
|
6 |
+
import gradio as gr
|
7 |
|
8 |
# Import modules from the Uspark package
|
9 |
from app.chatbot import ChatbotSession
|
|
|
12 |
|
13 |
app = FastAPI(title="Uspark API")
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
# Ensure models are loaded from the 'models' directory within 'Uspark'
|
16 |
import sys
|
17 |
import os
|
|
|
65 |
save_medseg_result(result_record)
|
66 |
|
67 |
return result
|
68 |
+
|
69 |
+
# Gradio Interface
|
70 |
+
def my_model(input_text):
|
71 |
+
return f"Processed: {input_text}"
|
72 |
+
|
73 |
+
gradio_app = gr.Interface(fn=my_model, inputs="text", outputs="text")
|
74 |
+
|
75 |
+
# Mount Gradio app inside FastAPI
|
76 |
+
app = gr.mount_gradio_app(app, gradio_app, path="/gradio")
|
77 |
+
|
78 |
+
if __name__ == "__main__":
|
79 |
+
import uvicorn
|
80 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|