Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,9 +2,16 @@ import streamlit as st
|
|
| 2 |
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
| 3 |
import huggingface_hub
|
| 4 |
import torch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
# Login to Hugging Face Hub
|
| 7 |
-
|
| 8 |
|
| 9 |
# Load model and tokenizer
|
| 10 |
repo_id = "Darshan03/t5-model-small" # Replace with your hub username and model name
|
|
|
|
| 2 |
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
| 3 |
import huggingface_hub
|
| 4 |
import torch
|
| 5 |
+
import os
|
| 6 |
+
|
| 7 |
+
# Load Hugging Face API key from environment variable
|
| 8 |
+
HF_API_KEY = os.getenv("HF_API_KEY")
|
| 9 |
+
if not HF_API_KEY:
|
| 10 |
+
st.error("Please set your Hugging Face API key in the environment variables.")
|
| 11 |
+
st.stop()
|
| 12 |
|
| 13 |
# Login to Hugging Face Hub
|
| 14 |
+
huggingface_hub.login(HF_API_KEY)
|
| 15 |
|
| 16 |
# Load model and tokenizer
|
| 17 |
repo_id = "Darshan03/t5-model-small" # Replace with your hub username and model name
|