Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
3 |
import torch
|
|
|
|
|
|
|
|
|
4 |
|
5 |
# 定义模型名称(替换为您上传的模型名称)
|
6 |
model_name = "larry1129/WooWoof_AI" # 替换为您的模型名称
|
7 |
|
8 |
# 加载分词器
|
9 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
10 |
|
11 |
# 加载模型
|
12 |
model = AutoModelForCausalLM.from_pretrained(
|
13 |
model_name,
|
14 |
device_map="auto",
|
15 |
torch_dtype=torch.float16,
|
|
|
16 |
trust_remote_code=True # 如果你的模型使用自定义代码,请保留此参数
|
17 |
)
|
18 |
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
3 |
import torch
|
4 |
+
import os
|
5 |
+
|
6 |
+
# 获取 Hugging Face 访问令牌
|
7 |
+
hf_token = os.getenv("HF_API_TOKEN")
|
8 |
|
9 |
# 定义模型名称(替换为您上传的模型名称)
|
10 |
model_name = "larry1129/WooWoof_AI" # 替换为您的模型名称
|
11 |
|
12 |
# 加载分词器
|
13 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, use_auth_token=hf_token)
|
14 |
|
15 |
# 加载模型
|
16 |
model = AutoModelForCausalLM.from_pretrained(
|
17 |
model_name,
|
18 |
device_map="auto",
|
19 |
torch_dtype=torch.float16,
|
20 |
+
use_auth_token=hf_token,
|
21 |
trust_remote_code=True # 如果你的模型使用自定义代码,请保留此参数
|
22 |
)
|
23 |
|