Zmorell commited on
Commit
4ccd3e0
·
verified ·
1 Parent(s): 04edfad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -62,11 +62,18 @@ def predict(text):
62
  outputs = model.predict(inputs)
63
  print(f"Model outputs: {outputs}")
64
 
65
- return f"This text is a violation = {outputs[0][0]:.2f}"
 
 
 
 
 
 
 
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()