AmpomahChief
commited on
Commit
•
449ab17
1
Parent(s):
7a5a651
Update gradioapp.py
Browse files- gradioapp.py +30 -6
gradioapp.py
CHANGED
@@ -21,11 +21,35 @@
|
|
21 |
# # Launch the interface
|
22 |
# interface.launch()
|
23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
import gradio as gr
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
-
|
|
|
|
21 |
# # Launch the interface
|
22 |
# interface.launch()
|
23 |
|
24 |
+
|
25 |
+
|
26 |
+
# import gradio as gr
|
27 |
+
# # Creating a gradio app using the inferene API
|
28 |
+
# App = gr.Interface.load("huggingface/AmpomahChief/sentiment_analysis_on_covid_tweets",
|
29 |
+
# title="COVID 19 tweets sentiment analysis", description ="This is a sentiment analysis on COVID 19 tweets using pretrained model on hugging face",
|
30 |
+
# allow_flagging=False, examples=[["Input your text here"]]
|
31 |
+
# )
|
32 |
+
|
33 |
+
# App.launch()
|
34 |
+
|
35 |
+
|
36 |
+
|
37 |
+
|
38 |
+
|
39 |
import gradio as gr
|
40 |
+
from transformers import pipeline
|
41 |
+
import transformers
|
42 |
+
|
43 |
+
Model = transformers.AutoModel.from_pretrained('AmpomahChief/sentiment_analysis_on_covid_tweets')
|
44 |
+
pipeline = pipeline(task="image-classification", model=Model)
|
45 |
+
|
46 |
+
def predict(inputs):
|
47 |
+
input_ids = transformers.BertTokenizer.from_pretrained('AmpomahChief/sentiment_analysis_on_covid_tweets').encode(inputs, return_tensors='pt')
|
48 |
+
output = model(input_ids)[0]
|
49 |
+
return output
|
50 |
+
|
51 |
+
# Create a Gradio interface for the model
|
52 |
+
interface = gr.Interface(fn=predict, inputs=gr.Textbox(prompt="Input text:"), outputs=gr.Textbox(prompt="Model output:"))
|
53 |
|
54 |
+
# Launch the interface
|
55 |
+
interface.launch()
|