Spaces:
Runtime error
Runtime error
mac commited on
Commit Β·
1e8128a
1
Parent(s): 51fd630
private access
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
# MiniCPM5-1B Demo
|
| 2 |
|
| 3 |
from pathlib import Path
|
|
|
|
| 4 |
import time
|
| 5 |
import logging
|
| 6 |
import threading
|
|
@@ -8,6 +9,7 @@ import threading
|
|
| 8 |
import gradio as gr
|
| 9 |
import spaces
|
| 10 |
import torch
|
|
|
|
| 11 |
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
|
| 12 |
|
| 13 |
from utils_chatbot import organize_messages, stream2display_text
|
|
@@ -17,6 +19,13 @@ logger = logging.getLogger(__name__)
|
|
| 17 |
|
| 18 |
MODEL_PATH = "openbmb/MiniCPM5-1B"
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH, trust_remote_code=True)
|
| 21 |
|
| 22 |
model = AutoModelForCausalLM.from_pretrained(
|
|
|
|
| 1 |
# MiniCPM5-1B Demo
|
| 2 |
|
| 3 |
from pathlib import Path
|
| 4 |
+
import os
|
| 5 |
import time
|
| 6 |
import logging
|
| 7 |
import threading
|
|
|
|
| 9 |
import gradio as gr
|
| 10 |
import spaces
|
| 11 |
import torch
|
| 12 |
+
from huggingface_hub import login
|
| 13 |
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer
|
| 14 |
|
| 15 |
from utils_chatbot import organize_messages, stream2display_text
|
|
|
|
| 19 |
|
| 20 |
MODEL_PATH = "openbmb/MiniCPM5-1B"
|
| 21 |
|
| 22 |
+
hf_token = os.environ.get("HF_TOKEN")
|
| 23 |
+
if hf_token:
|
| 24 |
+
login(token=hf_token)
|
| 25 |
+
logger.info("Logged in to Hugging Face Hub")
|
| 26 |
+
else:
|
| 27 |
+
logger.warning("HF_TOKEN not set β private/gated models will be inaccessible")
|
| 28 |
+
|
| 29 |
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH, trust_remote_code=True)
|
| 30 |
|
| 31 |
model = AutoModelForCausalLM.from_pretrained(
|