Download app.py from Hanjaewon/space: direct link, hf CLI and curl.
- Browser
- Download file 647 Bytes
-
https://huggingface.co/spaces/Hanjaewon/space/resolve/main/app.py
- Command line
-
hf download hf://spaces/Hanjaewon/space/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Hanjaewon/space/resolve/main/app.py
647 Bytes
| import gradio as gr | |
| from transformers import pipeline, AutoTokenizer, AutoModelForQuestionAnswering | |
| # Hugging Face ๋ชจ๋ธ ๋ก๋ | |
| model_name = "distilbert-base-cased-distilled-squad" | |
| tokenizer = AutoTokenizer.from_pretrained(model_name) | |
| model = AutoModelForQuestionAnswering.from_pretrained(model_name) | |
| qa_pipeline = pipeline("question-answering", model=model, tokenizer=tokenizer) | |
| # Gradio ์ธํฐํ์ด์ค ์ ์ | |
| iface = gr.Interface( | |
| fn=lambda question: qa_pipeline(question=question, context=context)["answer"], | |
| inputs=gr.Textbox(label="Enter a question"), | |
| outputs="text", | |
| live=True, | |
| ) | |
| # ์ธํฐํ์ด์ค ์คํ | |
| iface.launch() | |