Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -62,11 +62,18 @@ def predict(text):
|
|
| 62 |
outputs = model.predict(inputs)
|
| 63 |
print(f"Model outputs: {outputs}")
|
| 64 |
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
except Exception as e:
|
| 67 |
print(f"Error during prediction: {e}")
|
| 68 |
return f"Error during prediction: {e}"
|
| 69 |
|
| 70 |
# Set up the Gradio interface
|
| 71 |
demo = gr.Interface(fn=predict, inputs="text", outputs="text")
|
| 72 |
-
demo.launch()
|
|
|
|
| 62 |
outputs = model.predict(inputs)
|
| 63 |
print(f"Model outputs: {outputs}")
|
| 64 |
|
| 65 |
+
# Interpret the output as a prediction
|
| 66 |
+
prediction = outputs[0][0]
|
| 67 |
+
if prediction >= 0.5:
|
| 68 |
+
result = f"This text is a violation = {prediction:.2f}"
|
| 69 |
+
else:
|
| 70 |
+
result = f"This text is not a violation = {prediction:.2f}"
|
| 71 |
+
|
| 72 |
+
return result
|
| 73 |
except Exception as e:
|
| 74 |
print(f"Error during prediction: {e}")
|
| 75 |
return f"Error during prediction: {e}"
|
| 76 |
|
| 77 |
# Set up the Gradio interface
|
| 78 |
demo = gr.Interface(fn=predict, inputs="text", outputs="text")
|
| 79 |
+
demo.launch()
|