Spaces:
Runtime error
Runtime error
Upload 3 files
Browse files- .well-known/openapi.yaml +33 -0
- app.py +20 -0
- requirements.txt +5 -0
.well-known/openapi.yaml
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
openapi: 3.0.1
|
| 2 |
+
info:
|
| 3 |
+
title: θ©ζ§ζ¨θ¨» API
|
| 4 |
+
description: ζδΎ θ©ζ§ζ¨θ¨» δ»»εεζ
|
| 5 |
+
version: "1.0.0"
|
| 6 |
+
servers:
|
| 7 |
+
- url: https://turkeyengineer-ckip-pos.hf.space
|
| 8 |
+
paths:
|
| 9 |
+
/analyze:
|
| 10 |
+
post:
|
| 11 |
+
summary: εζθΌΈε
₯ε₯ε
|
| 12 |
+
operationId: analyze
|
| 13 |
+
requestBody:
|
| 14 |
+
required: true
|
| 15 |
+
content:
|
| 16 |
+
application/json:
|
| 17 |
+
schema:
|
| 18 |
+
type: object
|
| 19 |
+
properties:
|
| 20 |
+
sentence:
|
| 21 |
+
type: string
|
| 22 |
+
example: ιζ―δΈε測試ε₯εγ
|
| 23 |
+
responses:
|
| 24 |
+
'200':
|
| 25 |
+
description: ζεεε³εζη΅ζ
|
| 26 |
+
content:
|
| 27 |
+
application/json:
|
| 28 |
+
schema:
|
| 29 |
+
type: object
|
| 30 |
+
properties:
|
| 31 |
+
result:
|
| 32 |
+
type: string
|
| 33 |
+
example: εζη΅ζ
|
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from fastapi import FastAPI, Request
|
| 3 |
+
from fastapi.responses import JSONResponse
|
| 4 |
+
from transformers import pipeline, AutoTokenizer
|
| 5 |
+
|
| 6 |
+
model = pipeline("token-classification", model="ckiplab/bert-base-chinese-pos", tokenizer=AutoTokenizer.from_pretrained("ckiplab/bert-base-chinese-pos"), aggregation_strategy="simple")
|
| 7 |
+
|
| 8 |
+
def analyze(sentence: str):
|
| 9 |
+
result = model(sentence)
|
| 10 |
+
return
|
| 11 |
+
|
| 12 |
+
demo = gr.Interface(fn=analyze, inputs="text", outputs="text", title="θ©ζ§ζ¨θ¨»")
|
| 13 |
+
|
| 14 |
+
app = FastAPI()
|
| 15 |
+
app = gr.mount_gradio_app(app, demo, path="/")
|
| 16 |
+
|
| 17 |
+
@app.post("/analyze")
|
| 18 |
+
async def api_analyze(request: Request):
|
| 19 |
+
payload = await request.json()
|
| 20 |
+
return JSONResponse(content={"result": analyze(payload.get("sentence", ""))})
|
requirements.txt
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
transformers
|
| 3 |
+
torch
|
| 4 |
+
fastapi
|
| 5 |
+
uvicorn
|