Talhaalvi12 commited on
Commit
a3d9ef8
·
verified ·
1 Parent(s): 4ad6f04
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
3
+
4
+ # Load model and tokenizer
5
+ tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-small")
6
+ model = AutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-small")
7
+
8
+ # Note generator function
9
+ def generate_notes(prompt):
10
+ # Add task prefix for FLAN-T5
11
+ input_text = f"Summarize or make concise notes: {prompt}"
12
+ inputs = tokenizer(input_text, return_tensors="pt", truncation=True)
13
+ outputs = model.generate(**inputs, max_new_tokens=200)
14
+ result = tokenizer.decode(outputs[0], skip_special_tokens=True)
15
+ return result
16
+
17
+ # Gradio interface
18
+ iface = gr.Interface(
19
+ fn=generate_notes,
20
+ inputs=gr.Textbox(lines=5, placeholder="Enter your topic or text here..."),
21
+ outputs="text",
22
+ title="🧠 Free Note Generator (FLAN-T5-small)",
23
+ description="Generate summarized notes using Google's FLAN-T5-small model — runs 100% free on CPU in Hugging Face Spaces."
24
+ )
25
+
26
+ iface.launch()