KaranNag commited on
Commit
3e25306
1 Parent(s): 53f2e25
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ from transformers import pipeline, BertForSequenceClassification, BertTokenizer
4
+
5
+ # Load the model and tokenizer from the Hugging Face Hub
6
+ model = BertForSequenceClassification.from_pretrained("Ai_text_model")
7
+ tokenizer = BertTokenizer.from_pretrained("Ai_text_model")
8
+
9
+ # Create a pipeline
10
+ text_classification = pipeline('text-classification', model=model, tokenizer=tokenizer)
11
+
12
+ # Define the Gradio interface function
13
+ def classify_text(text):
14
+ result = text_classification(text)
15
+ label = result[0]['label']
16
+ return label
17
+
18
+ # Create Gradio interface
19
+ interface = gr.Interface(fn=classify_text, inputs='text', outputs='text', title='Text Classification', description='Classify text as human or AI generated')
20
+
21
+ if __name__ == "__main__":
22
+ interface.launch()
23
+
24
+