Spaces:
Sleeping
Sleeping
outshine84@gmail.com
commited on
Commit
·
53e95b3
1
Parent(s):
860d6f8
Revert "fix api sospesa da ui gradio"
Browse filesThis reverts commit ce30917a95f28e7a2784c142dd1f4aa782a5cf8f.
- .gitignore +0 -1
- app.py +5 -14
.gitignore
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
__app.py___
|
|
|
|
|
|
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from fastapi import FastAPI
|
| 3 |
from transformers import pipeline
|
|
|
|
| 4 |
|
| 5 |
app = FastAPI(title="Company Reputation API")
|
| 6 |
|
|
@@ -25,24 +26,14 @@ def root():
|
|
| 25 |
def predict(text: str):
|
| 26 |
pipeline_model = get_pipeline()
|
| 27 |
return pipeline_model(text)
|
| 28 |
-
|
| 29 |
-
#
|
| 30 |
-
# GRADIO UI
|
| 31 |
-
# ------------------------
|
| 32 |
-
|
| 33 |
def analyze(text):
|
| 34 |
pipeline_model = get_pipeline()
|
| 35 |
return pipeline_model(text)
|
| 36 |
|
| 37 |
-
demo = gr.Interface(
|
| 38 |
-
|
| 39 |
-
inputs="text",
|
| 40 |
-
outputs="text",
|
| 41 |
-
title="Company Sentiment Analyzer",
|
| 42 |
-
).queue()
|
| 43 |
-
|
| 44 |
-
# Mount Gradio
|
| 45 |
-
app = gr.mount_gradio_app(app, demo, path="/gradio")
|
| 46 |
|
| 47 |
|
| 48 |
#if __name__ == "__main__":
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from fastapi import FastAPI
|
| 3 |
from transformers import pipeline
|
| 4 |
+
from fastapi.middleware.wsgi import WSGIMiddleware
|
| 5 |
|
| 6 |
app = FastAPI(title="Company Reputation API")
|
| 7 |
|
|
|
|
| 26 |
def predict(text: str):
|
| 27 |
pipeline_model = get_pipeline()
|
| 28 |
return pipeline_model(text)
|
| 29 |
+
|
| 30 |
+
# Gradio
|
|
|
|
|
|
|
|
|
|
| 31 |
def analyze(text):
|
| 32 |
pipeline_model = get_pipeline()
|
| 33 |
return pipeline_model(text)
|
| 34 |
|
| 35 |
+
demo = gr.Interface(fn=analyze, inputs="text", outputs="text")
|
| 36 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
|
| 39 |
#if __name__ == "__main__":
|