Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,7 @@ import pandas as pd
|
|
| 3 |
from transformers import pipeline
|
| 4 |
import torch
|
| 5 |
from transformers import AutoModel, AutoTokenizer
|
| 6 |
-
|
| 7 |
import torch
|
| 8 |
import torch.nn as nn
|
| 9 |
from huggingface_hub import PyTorchModelHubMixin
|
|
@@ -16,7 +16,7 @@ class MyModel(
|
|
| 16 |
nn.Module,
|
| 17 |
PyTorchModelHubMixin,
|
| 18 |
# optionally, you can add metadata which gets pushed to the model card
|
| 19 |
-
repo_url="your-repo-url",
|
| 20 |
pipeline_tag="text-classification",
|
| 21 |
license="mit",
|
| 22 |
):
|
|
@@ -66,9 +66,6 @@ def preprocessing(input_text, tokenizer):
|
|
| 66 |
def convert_excel_to_csv(file):
|
| 67 |
return pd.read_excel(file)
|
| 68 |
|
| 69 |
-
# initialising the Softmax function
|
| 70 |
-
soft = Softmax()
|
| 71 |
-
|
| 72 |
# Function to load models from Hugging Face Hub
|
| 73 |
@st.cache_resource
|
| 74 |
def get_model_score(sentence, mft):
|
|
@@ -83,7 +80,7 @@ def get_model_score(sentence, mft):
|
|
| 83 |
|
| 84 |
# predicting the mft score
|
| 85 |
output = model(**encodeds)
|
| 86 |
-
score =
|
| 87 |
|
| 88 |
# extracting and return the second value from the tensor
|
| 89 |
#mft_value = score[0, 1].item()
|
|
|
|
| 3 |
from transformers import pipeline
|
| 4 |
import torch
|
| 5 |
from transformers import AutoModel, AutoTokenizer
|
| 6 |
+
import torch.nn.functional as F
|
| 7 |
import torch
|
| 8 |
import torch.nn as nn
|
| 9 |
from huggingface_hub import PyTorchModelHubMixin
|
|
|
|
| 16 |
nn.Module,
|
| 17 |
PyTorchModelHubMixin,
|
| 18 |
# optionally, you can add metadata which gets pushed to the model card
|
| 19 |
+
# repo_url="your-repo-url",
|
| 20 |
pipeline_tag="text-classification",
|
| 21 |
license="mit",
|
| 22 |
):
|
|
|
|
| 66 |
def convert_excel_to_csv(file):
|
| 67 |
return pd.read_excel(file)
|
| 68 |
|
|
|
|
|
|
|
|
|
|
| 69 |
# Function to load models from Hugging Face Hub
|
| 70 |
@st.cache_resource
|
| 71 |
def get_model_score(sentence, mft):
|
|
|
|
| 80 |
|
| 81 |
# predicting the mft score
|
| 82 |
output = model(**encodeds)
|
| 83 |
+
score = F.softmax(output, dim=1)
|
| 84 |
|
| 85 |
# extracting and return the second value from the tensor
|
| 86 |
#mft_value = score[0, 1].item()
|