why is this here
Browse files
app.py
DELETED
|
@@ -1,44 +0,0 @@
|
|
| 1 |
-
import gradio as gr
|
| 2 |
-
import sys
|
| 3 |
-
import os
|
| 4 |
-
|
| 5 |
-
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 6 |
-
from api.predict import predict_review
|
| 7 |
-
|
| 8 |
-
def predict_api(text):
|
| 9 |
-
try:
|
| 10 |
-
if not text or len(text.strip()) == 0:
|
| 11 |
-
return {
|
| 12 |
-
"error": "text cannot be empty",
|
| 13 |
-
"prediction": None,
|
| 14 |
-
"confidence": 0.0,
|
| 15 |
-
"is_fake": False
|
| 16 |
-
}
|
| 17 |
-
|
| 18 |
-
result = predict_review(text)
|
| 19 |
-
|
| 20 |
-
return {
|
| 21 |
-
"prediction": result['prediction'],
|
| 22 |
-
"confidence": result['confidence'],
|
| 23 |
-
"is_fake": result['is_fake']
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
except Exception as e:
|
| 27 |
-
return {
|
| 28 |
-
"error": str(e),
|
| 29 |
-
"prediction": None,
|
| 30 |
-
"confidence": 0.0,
|
| 31 |
-
"is_fake": False
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
demo = gr.Interface(
|
| 35 |
-
fn=predict_api,
|
| 36 |
-
inputs=gr.Textbox(label="review text", lines=5, placeholder="enter review text here..."),
|
| 37 |
-
outputs=gr.JSON(label="result"),
|
| 38 |
-
title="sentinelcheck api",
|
| 39 |
-
description="check if review is fake or real",
|
| 40 |
-
api_name="predict"
|
| 41 |
-
)
|
| 42 |
-
|
| 43 |
-
if __name__ == "__main__":
|
| 44 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|