Spaces:
Sleeping
Sleeping
outshine84@gmail.com commited on
Commit ·
860d6f8
1
Parent(s): 1ba8781
Revert "fix variabile app sovrascritta"
Browse filesThis reverts commit c877820281241b6760fd4fc5314c0adc175a69f9.
app.py
CHANGED
|
@@ -2,8 +2,9 @@ import gradio as gr
|
|
| 2 |
from fastapi import FastAPI
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
-
|
| 6 |
|
|
|
|
| 7 |
model_path="AChierici84/sentiment-roberta-finetuned"
|
| 8 |
sentiment_task = None
|
| 9 |
|
|
@@ -13,14 +14,14 @@ def get_pipeline():
|
|
| 13 |
sentiment_task = pipeline("sentiment-analysis", model=model_path, tokenizer=model_path)
|
| 14 |
return sentiment_task
|
| 15 |
|
| 16 |
-
@
|
| 17 |
def root():
|
| 18 |
return {
|
| 19 |
"status" : "OK",
|
| 20 |
"message": "Company reputation alive! API documentation on /docs."
|
| 21 |
}
|
| 22 |
|
| 23 |
-
@
|
| 24 |
def predict(text: str):
|
| 25 |
pipeline_model = get_pipeline()
|
| 26 |
return pipeline_model(text)
|
|
@@ -41,7 +42,7 @@ demo = gr.Interface(
|
|
| 41 |
).queue()
|
| 42 |
|
| 43 |
# Mount Gradio
|
| 44 |
-
app = gr.mount_gradio_app(
|
| 45 |
|
| 46 |
|
| 47 |
#if __name__ == "__main__":
|
|
|
|
| 2 |
from fastapi import FastAPI
|
| 3 |
from transformers import pipeline
|
| 4 |
|
| 5 |
+
app = FastAPI(title="Company Reputation API")
|
| 6 |
|
| 7 |
+
# Carica modello
|
| 8 |
model_path="AChierici84/sentiment-roberta-finetuned"
|
| 9 |
sentiment_task = None
|
| 10 |
|
|
|
|
| 14 |
sentiment_task = pipeline("sentiment-analysis", model=model_path, tokenizer=model_path)
|
| 15 |
return sentiment_task
|
| 16 |
|
| 17 |
+
@app.get("/")
|
| 18 |
def root():
|
| 19 |
return {
|
| 20 |
"status" : "OK",
|
| 21 |
"message": "Company reputation alive! API documentation on /docs."
|
| 22 |
}
|
| 23 |
|
| 24 |
+
@app.post("/predict")
|
| 25 |
def predict(text: str):
|
| 26 |
pipeline_model = get_pipeline()
|
| 27 |
return pipeline_model(text)
|
|
|
|
| 42 |
).queue()
|
| 43 |
|
| 44 |
# Mount Gradio
|
| 45 |
+
app = gr.mount_gradio_app(app, demo, path="/gradio")
|
| 46 |
|
| 47 |
|
| 48 |
#if __name__ == "__main__":
|