Spaces:
Running
Running
Commit
·
fbdc35c
1
Parent(s):
f449ed9
req update
Browse files- app.py +13 -15
- requirements.txt +2 -1
app.py
CHANGED
@@ -1,21 +1,19 @@
|
|
1 |
import gradio as gr
|
2 |
-
from
|
|
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
|
7 |
-
#
|
8 |
def classify_emotion(text):
|
9 |
-
|
10 |
-
return
|
11 |
|
12 |
-
|
13 |
-
iface = gr.Interface(
|
14 |
-
fn=classify_emotion, # function that will classify emotion
|
15 |
-
inputs=gr.Textbox(), # input text box
|
16 |
-
outputs=[gr.Textbox(), gr.Textbox()], # output emotion label and score
|
17 |
-
live=True # Enable live mode (optional)
|
18 |
-
)
|
19 |
|
20 |
-
#
|
21 |
-
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from fastapi import FastAPI
|
3 |
+
import uvicorn
|
4 |
|
5 |
+
# Create a FastAPI app
|
6 |
+
app = FastAPI()
|
7 |
|
8 |
+
# Create Gradio interface (just like in Hugging Face Spaces)
|
9 |
def classify_emotion(text):
|
10 |
+
# Your model code here (replace this with the actual classification)
|
11 |
+
return "happy" # example return value
|
12 |
|
13 |
+
gradio_interface = gr.Interface(fn=classify_emotion, inputs="text", outputs="text")
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
# Mount the Gradio app inside FastAPI
|
16 |
+
app.mount("/gradio", gradio_interface)
|
17 |
+
|
18 |
+
if __name__ == "__main__":
|
19 |
+
uvicorn.run(app, host="0.0.0.0", port=7860)
|
requirements.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
transformers
|
2 |
gradio
|
3 |
-
torch
|
|
|
|
1 |
transformers
|
2 |
gradio
|
3 |
+
torch
|
4 |
+
uvicorn
|