Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,17 @@
|
|
2 |
import gradio as gr
|
3 |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
4 |
import torch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
# Load model and tokenizer
|
6 |
model_name = "meta-llama/Llama-2-7b-chat-hf"
|
7 |
print("started loading model")
|
@@ -14,13 +25,11 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
14 |
return_dict=True,
|
15 |
torch_dtype=torch.float16,
|
16 |
revision="main", # Or the desired revision
|
17 |
-
token=api_token # Provide the API token here
|
18 |
)
|
19 |
|
20 |
tokenizer = AutoTokenizer.from_pretrained(
|
21 |
model_name,
|
22 |
revision="main", # Or the desired revision
|
23 |
-
auth_token=api_token # Provide the API token here
|
24 |
)
|
25 |
|
26 |
print("loaded model")
|
|
|
2 |
import gradio as gr
|
3 |
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
4 |
import torch
|
5 |
+
from huggingface_hub import HfApi, HfFolder
|
6 |
+
|
7 |
+
# Replace '<your_api_token>' with your actual API token
|
8 |
+
api_token = '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'
|
9 |
+
|
10 |
+
# Initialize the HfApi with the API token
|
11 |
+
api = HfApi(token=api_token)
|
12 |
+
print('loggedin')
|
13 |
+
# Verify that you're logged in
|
14 |
+
user = api.whoami()
|
15 |
+
print(user)
|
16 |
# Load model and tokenizer
|
17 |
model_name = "meta-llama/Llama-2-7b-chat-hf"
|
18 |
print("started loading model")
|
|
|
25 |
return_dict=True,
|
26 |
torch_dtype=torch.float16,
|
27 |
revision="main", # Or the desired revision
|
|
|
28 |
)
|
29 |
|
30 |
tokenizer = AutoTokenizer.from_pretrained(
|
31 |
model_name,
|
32 |
revision="main", # Or the desired revision
|
|
|
33 |
)
|
34 |
|
35 |
print("loaded model")
|