sashtech commited on
Commit
686234d
·
verified ·
1 Parent(s): 1e61893

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -12
app.py CHANGED
@@ -1,5 +1,6 @@
 
1
  import gradio as gr
2
- from transformers import AutoTokenizer, AutoModelForSequenceClassification
3
  import torch
4
  import spacy
5
  import subprocess
@@ -45,7 +46,7 @@ def detect_ai_generated(text):
45
  label = "Human"
46
  probability = human_probability
47
 
48
- return f"The content is {probability:.2f}% {label} Written"
49
 
50
  # Function to get synonyms using NLTK WordNet
51
  def get_synonyms_nltk(word, pos):
@@ -117,17 +118,18 @@ def paraphrase_and_correct(text):
117
  return final_text
118
 
119
  # Gradio interface definition
120
- with gr.Blocks() as interface:
121
  with gr.Row():
122
  with gr.Column():
123
- text_input = gr.Textbox(lines=5, label="Input Text")
124
- detect_button = gr.Button("AI Detection")
125
- paraphrase_button = gr.Button("Paraphrase & Correct")
126
- with gr.Column():
127
- output_text = gr.Textbox(label="Output")
 
 
 
128
 
129
- detect_button.click(detect_ai_generated, inputs=text_input, outputs=output_text)
130
- paraphrase_button.click(paraphrase_and_correct, inputs=text_input, outputs=output_text)
131
 
132
- # Launch the Gradio app
133
- interface.launch(debug=False)
 
1
+ import os
2
  import gradio as gr
3
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline
4
  import torch
5
  import spacy
6
  import subprocess
 
46
  label = "Human"
47
  probability = human_probability
48
 
49
+ return f"The content is {probability:.2f}% {label} Written", probability
50
 
51
  # Function to get synonyms using NLTK WordNet
52
  def get_synonyms_nltk(word, pos):
 
118
  return final_text
119
 
120
  # Gradio interface definition
121
+ with gr.Blocks() as demo:
122
  with gr.Row():
123
  with gr.Column():
124
+ t1 = gr.Textbox(
125
+ lines=5,
126
+ label='Text',
127
+ value="There are a few things that can help protect your credit card information from being misused when you give it to a restaurant or any other business:\n\nEncryption: Many businesses use encryption to protect your credit card information when it is being transmitted or stored. This means that the information is transformed into a code that is difficult for anyone to read without the right key."
128
+ )
129
+ button1 = gr.Button("🤖 Predict!")
130
+ label1 = gr.Textbox(lines=1, label='Predicted Label 🎃')
131
+ score1 = gr.Textbox(lines=1, label='Probability (%)')
132
 
133
+ button1.click(detect_ai_generated, inputs=[t1], outputs=[label1, score1])
 
134
 
135
+ demo.launch()