Update app.py
Browse files
app.py
CHANGED
|
@@ -1,21 +1,11 @@
|
|
| 1 |
-
|
| 2 |
|
| 3 |
-
from fastapi import FastAPI
|
| 4 |
-
from pydantic import BaseModel
|
| 5 |
-
from transformers import pipeline
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
|
| 10 |
-
# 加载 Hugging Face 模型,假设是一个文本分类模型
|
| 11 |
-
model = pipeline("text-classification", model="distilbert-base-uncased-finetuned-sst-2-english")
|
| 12 |
|
| 13 |
-
|
| 14 |
-
class TextRequest(BaseModel):
|
| 15 |
-
text: str
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
async def predict(request: TextRequest):
|
| 20 |
-
result = model(request.text)
|
| 21 |
-
return {"label": result[0]['label'], "score": result[0]['score']}
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
def greet(name):
|
| 5 |
+
return "Hello " + name + "!"
|
| 6 |
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
demo = gr.Interface(fn=greet, inputs="textbox", outputs="textbox")
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
if __name__ == "__main__":
|
| 11 |
+
demo.launch()
|
|
|
|
|
|
|
|
|