Spaces:
Sleeping
Sleeping
Update app.py for fixing the runtime
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from pydantic import BaseModel
|
| 3 |
from transformers import pipeline
|
|
@@ -12,3 +13,6 @@ class TextInput(BaseModel):
|
|
| 12 |
async def moderate_text(input: TextInput):
|
| 13 |
results = moderate_pipe(input.text)
|
| 14 |
return {r["label"]: r["score"] for r in results}
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
from fastapi import FastAPI
|
| 3 |
from pydantic import BaseModel
|
| 4 |
from transformers import pipeline
|
|
|
|
| 13 |
async def moderate_text(input: TextInput):
|
| 14 |
results = moderate_pipe(input.text)
|
| 15 |
return {r["label"]: r["score"] for r in results}
|
| 16 |
+
|
| 17 |
+
# Gradio interface to expose the model API via a Space
|
| 18 |
+
gr.Interface(fn=moderate_text, inputs="text", outputs="json").launch(share=True)
|