Update app.py
Browse files
app.py
CHANGED
@@ -2,15 +2,20 @@
|
|
2 |
import gradio as gr
|
3 |
import requests
|
4 |
from datetime import datetime
|
5 |
-
from transformers import
|
|
|
6 |
|
7 |
-
#
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
11 |
generator = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
12 |
|
13 |
-
# NEIS API
|
14 |
NEIS_KEY = "a69e08342c8947b4a52cd72789a5ecaf"
|
15 |
SCHOOL_INFO_URL = "https://open.neis.go.kr/hub/schoolInfo"
|
16 |
SCHEDULE_URL = "https://open.neis.go.kr/hub/SchoolSchedule"
|
@@ -104,6 +109,6 @@ with gr.Interface(
|
|
104 |
],
|
105 |
outputs=gr.Textbox(label="GPTμ μλ΅"),
|
106 |
title="π
νμ¬μΌμ + GPT μ±λ΄ (Gemma 2B)",
|
107 |
-
description="
|
108 |
) as app:
|
109 |
app.launch()
|
|
|
2 |
import gradio as gr
|
3 |
import requests
|
4 |
from datetime import datetime
|
5 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
6 |
+
import os
|
7 |
|
8 |
+
# β
Hugging Face token μΈμ¦ (νμμ νκ²½λ³μ μ¬μ©)
|
9 |
+
from huggingface_hub import login
|
10 |
+
login(token=os.environ.get("HF_TOKEN"), new_session=False)
|
11 |
+
|
12 |
+
# β
Gemma λͺ¨λΈ λ‘λ (gated repo)
|
13 |
+
model_id = "google/gemma-2-2b-it"
|
14 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, token=os.environ.get("HF_TOKEN"))
|
15 |
+
model = AutoModelForCausalLM.from_pretrained(model_id, token=os.environ.get("HF_TOKEN"))
|
16 |
generator = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
17 |
|
18 |
+
# β
NEIS API
|
19 |
NEIS_KEY = "a69e08342c8947b4a52cd72789a5ecaf"
|
20 |
SCHOOL_INFO_URL = "https://open.neis.go.kr/hub/schoolInfo"
|
21 |
SCHEDULE_URL = "https://open.neis.go.kr/hub/SchoolSchedule"
|
|
|
109 |
],
|
110 |
outputs=gr.Textbox(label="GPTμ μλ΅"),
|
111 |
title="π
νμ¬μΌμ + GPT μ±λ΄ (Gemma 2B)",
|
112 |
+
description="Gemma λͺ¨λΈ κΈ°λ°μ νμ¬μΌμ μ±λ΄μ
λλ€. μ°λ/μμ μλ΅ μ μ€λ κΈ°μ€μΌλ‘ μ²λ¦¬λ©λλ€."
|
113 |
) as app:
|
114 |
app.launch()
|