AmpomahChief commited on
Commit
06f8313
1 Parent(s): 0ea8b1f

Update gradioapp.py

Browse files
Files changed (1) hide show
  1. gradioapp.py +29 -6
gradioapp.py CHANGED
@@ -1,8 +1,31 @@
 
1
  import gradio as gr
2
- # Creating a gradio app using the inferene API
3
- App = gr.Interface.load("huggingface/AmpomahChief/sentiment_analysis_on_covid_tweets",
4
- title="COVID 19 tweets sentiment analysis", description ="This is a sentiment analysis on COVID 19 tweets using pretrained model on hugging face",
5
- allow_flagging=False, examples=[["Input your text here"]]
6
- )
7
 
8
- App.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Import the required Libraries
2
  import gradio as gr
3
+ import pickle
4
+ import pandas as pd
5
+ import numpy as np
6
+ import transformers
 
7
 
8
+ # Load a BERT model from the Hugging Face model hub
9
+ model = transformers.AutoModel.from_pretrained('AmpomahChief/sentiment_analysis_on_covid_tweets')
10
+
11
+
12
+ # Define a function that takes in input and passes it through the model
13
+ def predict(inputs):
14
+ input_ids = transformers.BertTokenizer.from_pretrained('AmpomahChief/sentiment_analysis_on_covid_tweets').encode(inputs, return_tensors='pt')
15
+ output = model(input_ids)[0]
16
+ return output
17
+
18
+ # Create a Gradio interface for the model
19
+ interface = gr.Interface(fn=predict, inputs=gr.Textbox(prompt="Input text:"), outputs=gr.Textbox(prompt="Model output:"))
20
+
21
+ # Launch the interface
22
+ interface.launch()
23
+
24
+ # import gradio as gr
25
+ # # Creating a gradio app using the inferene API
26
+ # App = gr.Interface.load("huggingface/AmpomahChief/sentiment_analysis_on_covid_tweets",
27
+ # title="COVID 19 tweets sentiment analysis", description ="This is a sentiment analysis on COVID 19 tweets using pretrained model on hugging face",
28
+ # allow_flagging=False, examples=[["Input your text here"]]
29
+ # )
30
+
31
+ # App.launch()