MoGis commited on
Commit
bd67174
·
verified ·
1 Parent(s): 1f5e8b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -16
app.py CHANGED
@@ -1,21 +1,11 @@
1
- # app.py
2
 
3
- from fastapi import FastAPI
4
- from pydantic import BaseModel
5
- from transformers import pipeline
6
 
7
- # 创建 FastAPI 应用
8
- app = FastAPI()
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
- # 定义一个 POST 路由,接收文本并返回分类结果
18
- @app.post("/predict/")
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()