Spaces:
Runtime error
Runtime error
unt2tled
commited on
Commit
•
4f0eb76
1
Parent(s):
b82d52c
Update Demo.py
Browse files
Demo.py
CHANGED
@@ -10,14 +10,6 @@ from model_loader import HFPretrainedModel
|
|
10 |
from transformers import pipeline
|
11 |
import torch
|
12 |
|
13 |
-
@st.cache(hash_funcs={"MyUnhashableClass": lambda _: None})
|
14 |
-
def load_sentiment_model():
|
15 |
-
return pipeline("sentiment-analysis", model="siebert/sentiment-roberta-large-english")
|
16 |
-
|
17 |
-
@st.cache(hash_funcs={"MyUnhashableClass": lambda _: None})
|
18 |
-
def load_campaign_model():
|
19 |
-
return HFPretrainedModel("distilbert-base-uncased", "deano/political-campaign-analysis-110922")
|
20 |
-
|
21 |
if "session_id" not in st.session_state:
|
22 |
st.session_state["session_id"] = uuid.uuid1()
|
23 |
|
@@ -42,14 +34,14 @@ if b:
|
|
42 |
#upload_cap.caption("Extracting text from frames... (can take some time)")
|
43 |
#text_ocr = ocr.get_formated_text(ocr.retrieve_text(TMP_PATH+"uploaded_video_tmp", frames_path = "tmp_frames-{"+str(st.session_state["session_id"])+"}", show_print = False))
|
44 |
upload_cap.caption("Extracting text sentiment...")
|
45 |
-
sentiment_analysis =
|
46 |
text_sentiment = sentiment_analysis(text)[0]["label"]
|
47 |
status_bar.progress(80)
|
48 |
|
49 |
#shutil.rmtree(TMP_PATH)
|
50 |
status_bar.progress(90)
|
51 |
upload_cap.caption("Prediction...")
|
52 |
-
model =
|
53 |
#query_dict = {"text": [text], "text_ocr": [text_ocr]}
|
54 |
query_dict = {"text": [text], "label_sentiment": [text_sentiment]}
|
55 |
# Predicted confidence for each label
|
|
|
10 |
from transformers import pipeline
|
11 |
import torch
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
if "session_id" not in st.session_state:
|
14 |
st.session_state["session_id"] = uuid.uuid1()
|
15 |
|
|
|
34 |
#upload_cap.caption("Extracting text from frames... (can take some time)")
|
35 |
#text_ocr = ocr.get_formated_text(ocr.retrieve_text(TMP_PATH+"uploaded_video_tmp", frames_path = "tmp_frames-{"+str(st.session_state["session_id"])+"}", show_print = False))
|
36 |
upload_cap.caption("Extracting text sentiment...")
|
37 |
+
sentiment_analysis = pipeline("sentiment-analysis", model="siebert/sentiment-roberta-large-english")
|
38 |
text_sentiment = sentiment_analysis(text)[0]["label"]
|
39 |
status_bar.progress(80)
|
40 |
|
41 |
#shutil.rmtree(TMP_PATH)
|
42 |
status_bar.progress(90)
|
43 |
upload_cap.caption("Prediction...")
|
44 |
+
model = HFPretrainedModel("distilbert-base-uncased", "deano/political-campaign-analysis-110922")
|
45 |
#query_dict = {"text": [text], "text_ocr": [text_ocr]}
|
46 |
query_dict = {"text": [text], "label_sentiment": [text_sentiment]}
|
47 |
# Predicted confidence for each label
|