Download app.py from Srisamorn/Lab10: direct link, hf CLI and curl.
- Browser
- Download file 513 Bytes
-
https://huggingface.co/spaces/Srisamorn/Lab10/resolve/main/app.py
- Command line
-
hf download hf://spaces/Srisamorn/Lab10/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Srisamorn/Lab10/resolve/main/app.py
513 Bytes
| import streamlit as st | |
| from transformers import pipeline | |
| from datasets import load_dataset | |
| classifier = pipeline("text-generation", model="gpt2-medium") | |
| def main(): | |
| st.title("Text generation") | |
| with st.form("text_field"): | |
| text = st.text_area('enter some text:') | |
| # clicked==True only when the button is clicked | |
| clicked = st.form_submit_button("Submit") | |
| if clicked: | |
| results = classifier([text]) | |
| st.json(results) | |
| if __name__ == "__main__": | |
| main() | |