Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -5,21 +5,24 @@ from transformers import T5Tokenizer, T5ForConditionalGeneration
|
|
5 |
from transformers import pipeline
|
6 |
import torch
|
7 |
import base64
|
8 |
-
import os
|
9 |
-
from dotenv import load_dotenv
|
10 |
-
|
11 |
-
token = os.environ.get("HF_TOKEN")
|
12 |
|
13 |
-
|
14 |
-
|
15 |
|
|
|
|
|
16 |
|
17 |
|
18 |
-
|
|
|
|
|
19 |
#model and tokenizer loading
|
20 |
|
21 |
-
tokenizer = T5Tokenizer.from_pretrained(checkpoint)
|
22 |
-
base_model = T5ForConditionalGeneration.from_pretrained(checkpoint, device_map='auto', torch_dtype=torch.float32, offload_folder='D:/project/offload')
|
23 |
|
24 |
#file loader and preprocessing
|
25 |
def file_preprocessing(file):
|
|
|
5 |
from transformers import pipeline
|
6 |
import torch
|
7 |
import base64
|
8 |
+
#import os
|
9 |
+
#from dotenv import load_dotenv
|
10 |
+
from huggingface_hub import HfApi
|
|
|
11 |
|
12 |
+
api = HfApi()
|
13 |
+
token = api.get_secret("secret_token") # Replace with your secret name
|
14 |
|
15 |
+
#load_dotenv()
|
16 |
+
#token = os.environ.get("HF_TOKEN")
|
17 |
|
18 |
|
19 |
+
|
20 |
+
|
21 |
+
checkpoint = "LaMini-Flan-T5-248M"
|
22 |
#model and tokenizer loading
|
23 |
|
24 |
+
tokenizer = T5Tokenizer.from_pretrained(checkpoint, token=token)
|
25 |
+
base_model = T5ForConditionalGeneration.from_pretrained(checkpoint, token=token, device_map='auto', torch_dtype=torch.float32, offload_folder='D:/project/offload')
|
26 |
|
27 |
#file loader and preprocessing
|
28 |
def file_preprocessing(file):
|