mawairon commited on
Commit
dc7d693
1 Parent(s): 1f65033

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -3,6 +3,9 @@ import transformers
3
  from transformers import AutoTokenizer, AutoModelForSequenceClassification, AutoModel
4
  import torch
5
  import torch.nn as nn
 
 
 
6
 
7
 
8
  class LogisticRegressionTorch(nn.Module):
@@ -110,9 +113,15 @@ def analyze_dna(sequence):
110
  top_5_labels = [int_to_label[i] for i in top_5_indices]
111
 
112
  # Prepare the output as a list of tuples (label_name, probability)
113
- result = [(label, prob) for label, prob in zip(top_5_labels, top_5_probs)]
114
-
115
- return result
 
 
 
 
 
 
116
 
117
  # Create a Gradio interface
118
  demo = gr.Interface(fn=analyze_dna, inputs="text", outputs="json")
 
3
  from transformers import AutoTokenizer, AutoModelForSequenceClassification, AutoModel
4
  import torch
5
  import torch.nn as nn
6
+ import matplotlib.pyplot as plt
7
+ import pandas as pd
8
+
9
 
10
 
11
  class LogisticRegressionTorch(nn.Module):
 
113
  top_5_labels = [int_to_label[i] for i in top_5_indices]
114
 
115
  # Prepare the output as a list of tuples (label_name, probability)
116
+ #result = [(label, prob) for label, prob in zip(top_5_labels, top_5_probs)]
117
+ # Plot histogram
118
+ fig, ax = plt.subplots(figsize=(10, 6))
119
+ ax.barh(top_5_labels, top_5_probs, color='skyblue')
120
+ ax.set_xlabel('Probability')
121
+ ax.set_title('Top 5 Most Likely Labels')
122
+ plt.gca().invert_yaxis() # Highest probabilities at the top
123
+
124
+ #return result
125
 
126
  # Create a Gradio interface
127
  demo = gr.Interface(fn=analyze_dna, inputs="text", outputs="json")