NotesGenerator / app.py
Talhaalvi12's picture
app.py
a3d9ef8 verified
raw
history blame
981 Bytes
import gradio as gr
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-small")
model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-small")
# Note generator function
def generate_notes(prompt):
# Add task prefix for FLAN-T5
input_text = f"Summarize or make concise notes: {prompt}"
inputs = tokenizer(input_text, return_tensors="pt", truncation=True)
outputs = model.generate(**inputs, max_new_tokens=200)
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
return result
# Gradio interface
iface = gr.Interface(
fn=generate_notes,
inputs=gr.Textbox(lines=5, placeholder="Enter your topic or text here..."),
outputs="text",
title="🧠 Free Note Generator (FLAN-T5-small)",
description="Generate summarized notes using Google's FLAN-T5-small model — runs 100% free on CPU in Hugging Face Spaces."
)
iface.launch()