Spaces:
Sleeping
Sleeping
Model Access update
Browse filesGated public model access specifier added
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
-
# Create a Gradio-based fake news detection dashboard
|
| 2 |
import gradio as gr
|
| 3 |
import torch
|
|
|
|
| 4 |
import numpy as np
|
| 5 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
| 6 |
|
|
@@ -9,15 +9,18 @@ model_path = "deepesh-goel/news-veracity-model"
|
|
| 9 |
|
| 10 |
def load_model():
|
| 11 |
"""Load model and tokenizer"""
|
| 12 |
-
#
|
|
|
|
|
|
|
|
|
|
| 13 |
try:
|
| 14 |
-
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
| 15 |
except:
|
| 16 |
# Default to base model if tokenizer not found in checkpoint
|
| 17 |
tokenizer = AutoTokenizer.from_pretrained("roberta-base")
|
| 18 |
|
| 19 |
-
# Load the model
|
| 20 |
-
model = AutoModelForSequenceClassification.from_pretrained(model_path)
|
| 21 |
return tokenizer, model
|
| 22 |
|
| 23 |
tokenizer, model = load_model()
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import torch
|
| 3 |
+
import os
|
| 4 |
import numpy as np
|
| 5 |
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
| 6 |
|
|
|
|
| 9 |
|
| 10 |
def load_model():
|
| 11 |
"""Load model and tokenizer"""
|
| 12 |
+
# Get the token from environment variable
|
| 13 |
+
token = os.environ.get("HF_TOKEN", None)
|
| 14 |
+
|
| 15 |
+
# Load the tokenizer with authentication
|
| 16 |
try:
|
| 17 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path, token=token)
|
| 18 |
except:
|
| 19 |
# Default to base model if tokenizer not found in checkpoint
|
| 20 |
tokenizer = AutoTokenizer.from_pretrained("roberta-base")
|
| 21 |
|
| 22 |
+
# Load the model with authentication
|
| 23 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_path, token=token)
|
| 24 |
return tokenizer, model
|
| 25 |
|
| 26 |
tokenizer, model = load_model()
|