nebiyu29 commited on
Commit
f402264
1 Parent(s): d53c98f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -1
app.py CHANGED
@@ -1,3 +1,26 @@
1
  import gradio as gr
2
 
3
- gr.load("models/nebiyu29/psychology_classifier").launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
+ from transformers import AutoModelForSequenceClassification
4
+ from transformers import TextClassificationPipeline
5
+ from transformers import AutoTokenizer
6
+
7
+ model_name = "nebiyu29/finetunned_version_2"
8
+
9
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
10
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
11
+
12
+ classifier = TextClassificationPipeline(model=model, tokenizer=tokenizer)
13
+
14
+ def classify(text):
15
+ result = classifier(text)[0] # Access the first result
16
+ return {"label": result["label"], "score": result["score"]}
17
+
18
+ iface = gr.Interface(
19
+ fn=classify,
20
+ inputs=[gr.Textbox(lines=2, placeholder="Enter text to classify")],
21
+ outputs=gr.JSON(label="Classification"),
22
+ title="Text Classification",
23
+ live=True, # Enable live prediction
24
+ )
25
+
26
+ iface.launch()