Spaces:
Sleeping
Sleeping
Download app.py from dantedgp/question-generator: direct link, hf CLI and curl.
- Browser
- Download file 1.03 kB
-
https://huggingface.co/spaces/dantedgp/question-generator/resolve/main/app.py
- Command line
-
hf download hf://spaces/dantedgp/question-generator/app.py
-
curl -L -o app.py https://huggingface.co/spaces/dantedgp/question-generator/resolve/main/app.py
1.03 kB
| import streamlit as st | |
| import nltk | |
| from transformers import pipeline | |
| # Initialize NLTK | |
| nltk.download('punkt') | |
| # Instantiate the model | |
| model = pipeline(model="dantedgp/question-generator", tokenizer="google-t5/t5-small") | |
| placeholder = """The mitochondria is the powerhouse of the cell. | |
| Glycolisis harnesses the energy in the bonds of glucose. | |
| The nucleus stores the genetic code of a living being. | |
| The peroxisome produces hydrogen peroxide used for lipid breakdown. | |
| Ribosomes are the sites of protein synthesis. | |
| Antibodies label and target pathogens for destruction. | |
| Hemoglobin is a transport protein for oxygen.""" | |
| st.set_page_config(page_title='AI Quiz Generator') | |
| st.title('AI Quiz Generator') | |
| text_input = st.text_area('Enter your text', value=placeholder, height=200) | |
| generate_button = st.button("Generate") | |
| if generate_button: | |
| sentences = nltk.sent_tokenize(text_input) | |
| print(sentences) | |
| for sentence in sentences: | |
| output = model(f"ask: {sentence}")[0]['generated_text'] | |
| st.write(output) | |