Create importing
Browse files
importing
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from huggingface_hub import hf_hub_download
|
2 |
+
import fasttext
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
# 모델 다운로드
|
6 |
+
model_path = hf_hub_download(repo_id="cis-lmu/glotlid", filename="model.bin")
|
7 |
+
|
8 |
+
# 모델 로드
|
9 |
+
model = fasttext.load_model(model_path)
|
10 |
+
|
11 |
+
# 예측 함수
|
12 |
+
def predict_language(text):
|
13 |
+
predictions = model.predict(text)
|
14 |
+
return {
|
15 |
+
"Predicted language": predictions[0][0],
|
16 |
+
"Confidence score": predictions[1][0]
|
17 |
+
}
|
18 |
+
|
19 |
+
# Gradio 인터페이스
|
20 |
+
interface = gr.Interface(
|
21 |
+
fn=predict_language,
|
22 |
+
inputs=gr.Textbox(label="Input Text"),
|
23 |
+
outputs="json",
|
24 |
+
title="Language Predictor"
|
25 |
+
)
|
26 |
+
|
27 |
+
interface.launch()
|