Pendrokar commited on
Commit
809daf0
1 Parent(s): 24deab8

emoji count slider

Browse files
Files changed (1) hide show
  1. app.py +14 -11
app.py CHANGED
@@ -31,7 +31,7 @@ st = SentenceTokenizer(vocabulary, maxlen)
31
 
32
  model = torchmoji_emojis(model_path)
33
 
34
- def predict(deepmoji_analysis):
35
  output_text = "\n"
36
  tokenized, _, _ = st.tokenize_sentences([deepmoji_analysis])
37
  prob = model(tokenized)
@@ -45,7 +45,7 @@ def predict(deepmoji_analysis):
45
  t_tokens = tokenized[i]
46
  t_score = [t]
47
  t_prob = prob[i]
48
- ind_top = top_elements(t_prob, 5)
49
  t_score.append(sum(t_prob[ind_top]))
50
  t_score.extend(ind_top)
51
  t_score.extend([t_prob[ind] for ind in ind_top])
@@ -55,17 +55,20 @@ def predict(deepmoji_analysis):
55
  return str(tokenized) + output_text
56
 
57
  gradio_app = gr.Interface(
58
- fn=predict,
59
- inputs="text",
 
 
 
60
  outputs="text",
61
  examples=[
62
- "You love hurting me, huh?",
63
- "I know good movies, this ain't one",
64
- "It was fun, but I'm not going to miss you",
65
- "My flight is delayed.. amazing.",
66
- "What is happening to me??",
67
- "This is the shit!",
68
- "This is shit!",
69
  ]
70
  )
71
 
 
31
 
32
  model = torchmoji_emojis(model_path)
33
 
34
+ def predict(deepmoji_analysis, emoji_count):
35
  output_text = "\n"
36
  tokenized, _, _ = st.tokenize_sentences([deepmoji_analysis])
37
  prob = model(tokenized)
 
45
  t_tokens = tokenized[i]
46
  t_score = [t]
47
  t_prob = prob[i]
48
+ ind_top = top_elements(t_prob, emoji_count)
49
  t_score.append(sum(t_prob[ind_top]))
50
  t_score.extend(ind_top)
51
  t_score.extend([t_prob[ind] for ind in ind_top])
 
55
  return str(tokenized) + output_text
56
 
57
  gradio_app = gr.Interface(
58
+ predict,
59
+ [
60
+ "text",
61
+ gr.Slider(1, 64, value=5, step=1, label="Top # Emoji", info="Choose between 1 and 64"),
62
+ ],
63
  outputs="text",
64
  examples=[
65
+ [5, "You love hurting me, huh?"],
66
+ [5, "I know good movies, this ain't one"],
67
+ [5, "It was fun, but I'm not going to miss you"],
68
+ [5, "My flight is delayed.. amazing."],
69
+ [5, "What is happening to me??"],
70
+ [5, "This is the shit!"],
71
+ [5, "This is shit!"],
72
  ]
73
  )
74