Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -58,18 +58,19 @@ def api_predict(text):
|
|
| 58 |
words = get_hate_words(text)
|
| 59 |
return {"hate_words": words}
|
| 60 |
|
| 61 |
-
# UI
|
| 62 |
-
with gr.Blocks() as
|
| 63 |
input_text = gr.Textbox(label="Enter Georgian text")
|
| 64 |
output_json = gr.JSON(label="Detected Hate Words")
|
| 65 |
submit_btn = gr.Button("Predict")
|
| 66 |
-
|
| 67 |
submit_btn.click(fn=api_predict, inputs=input_text, outputs=output_json)
|
| 68 |
|
| 69 |
-
# FastAPI app
|
| 70 |
app = FastAPI()
|
| 71 |
-
app = mount_gradio_app(app, demo, path="/") # UI at /
|
| 72 |
|
| 73 |
-
#
|
| 74 |
-
|
| 75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
words = get_hate_words(text)
|
| 59 |
return {"hate_words": words}
|
| 60 |
|
| 61 |
+
# Create the main Gradio UI
|
| 62 |
+
with gr.Blocks() as gradio_ui:
|
| 63 |
input_text = gr.Textbox(label="Enter Georgian text")
|
| 64 |
output_json = gr.JSON(label="Detected Hate Words")
|
| 65 |
submit_btn = gr.Button("Predict")
|
|
|
|
| 66 |
submit_btn.click(fn=api_predict, inputs=input_text, outputs=output_json)
|
| 67 |
|
| 68 |
+
# Create FastAPI app
|
| 69 |
app = FastAPI()
|
|
|
|
| 70 |
|
| 71 |
+
# Mount Gradio UI at `/`
|
| 72 |
+
app = mount_gradio_app(app, gradio_ui, path="/")
|
| 73 |
+
|
| 74 |
+
# Mount Gradio API interface at `/predict`
|
| 75 |
+
api_interface = gr.Interface(fn=api_predict, inputs=gr.Textbox(), outputs="json")
|
| 76 |
+
app = mount_gradio_app(app, api_interface, path="/predict")
|