minemaster01 commited on
Commit
50d78dc
·
verified ·
1 Parent(s): e01a601

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -83,7 +83,7 @@ def get_word_probabilities(text):
83
  if current_word and current_probs:
84
  current_prob = sum(current_probs) / len(current_probs)
85
  word_probs.append(current_prob)
86
- color = ("green" if current_prob < 0.25 else "yellow" if current_prob < 0.5 else "orange" if current_prob < 0.75 else "red")
87
  word_colors.append(color)
88
  word_probs = [float(p) for p in word_probs]
89
  return word_probs, word_colors
@@ -104,7 +104,8 @@ def infer_and_log(text_input):
104
  except Exception as e:
105
  print(f"Error uploading log: {e}")
106
  tokens = text_input.split()
107
- formatted_output = " ".join(f'<span style="color:{color}">{token}</span>' for token, color in zip(tokens, word_colors))
 
108
  return formatted_output
109
 
110
  def clear_fields():
 
83
  if current_word and current_probs:
84
  current_prob = sum(current_probs) / len(current_probs)
85
  word_probs.append(current_prob)
86
+ color = ("green" if current_prob < 0.25 else "yellow" if current_prob < 0.5 else "orange" if current_prob < 0.75 else "red")
87
  word_colors.append(color)
88
  word_probs = [float(p) for p in word_probs]
89
  return word_probs, word_colors
 
104
  except Exception as e:
105
  print(f"Error uploading log: {e}")
106
  tokens = text_input.split()
107
+
108
+ formatted_output = " ".join(f'<span style="background-color:#1F1F23; color:{color}">{token}</span>' for token, color in zip(tokens, word_colors))
109
  return formatted_output
110
 
111
  def clear_fields():