from huggingface_hub import hf_hub_download import fasttext import gradio as gr # 모델 다운로드 model_path = hf_hub_download(repo_id="cis-lmu/glotlid", filename="model.bin") # 모델 로드 model = fasttext.load_model(model_path) # 예측 함수 def predict_language(text): predictions = model.predict(text) return { "Predicted language": predictions[0][0], "Confidence score": predictions[1][0] } # Gradio 인터페이스 interface = gr.Interface( fn=predict_language, inputs=gr.Textbox(label="Input Text"), outputs="json", title="Language Predictor" ) interface.launch()