Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,27 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
# Wczytanie własnego modelu chatbota z Hugging Face
|
5 |
model_name = "pp3232133/pp3232133-distilgpt2-wikitext2"
|
6 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
|
4 |
+
# Wczytanie tokena z pliku konfiguracyjnego
|
5 |
+
with open("config.txt", "r") as f:
|
6 |
+
lines = f.readlines()
|
7 |
+
config = {}
|
8 |
+
for line in lines:
|
9 |
+
key, value = line.strip().split(" = ")
|
10 |
+
config[key] = value
|
11 |
+
|
12 |
+
repo_id = config["repo_id"]
|
13 |
+
repo_type = config["repo_type"]
|
14 |
+
username = config["username"]
|
15 |
+
password = config["password"]
|
16 |
+
|
17 |
+
# Utworzenie folderu Hugging Face z tokenem uwierzytelniającym
|
18 |
+
hf_folder = HfFolder(repo_id, repo_type, token=username + ":" + password)
|
19 |
+
|
20 |
+
# Wczytanie modelu chatbota z Hugging Face
|
21 |
+
model_name = "pp3232133/distilgpt2-wikitext2"
|
22 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, repo_path=hf_folder)
|
23 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, repo_path=hf_folder)
|
24 |
+
|
25 |
# Wczytanie własnego modelu chatbota z Hugging Face
|
26 |
model_name = "pp3232133/pp3232133-distilgpt2-wikitext2"
|
27 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|