File size: 981 Bytes
f87a7c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71c6023
f87a7c3
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# -*- coding: utf-8 -*-
"""Text_classifiers.ipynb

Automatically generated by Colab.

Original file is located at
    https://colab.research.google.com/drive/12UdfdxBHN2JLxsSOPPzTp7JkXOXxArJn
"""

from transformers import pipeline

#!pip install transformers

classifier=pipeline("text-classification",model="distilbert/distilbert-base-uncased-finetuned-sst-2-english")

classifier("I absolutely love this new phone! The camera quality is amazing")

classifier("this is so boring movie")

import gradio as gr
from transformers import pipeline

classifier=pipeline("text-classification",model="distilbert/distilbert-base-uncased-finetuned-sst-2-english")

def predict_sentiments(text):
  return classifier(text)[0]

gr.Interface(fn=predict_sentiments,
             inputs=[gr.Textbox(label="Insert Prompt here", lines=5)],
             outputs=[gr.Textbox(label="outputs sentiments", lines=3)],
             title="My App"
             ).launch(share=True)



#!pip install gradio