Fathi7ma commited on
Commit
caeab65
·
verified ·
1 Parent(s): 9b591a7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py CHANGED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ def generate_story(prompt):
5
+ pipe = pipeline("text-generation", model="Fathi7ma/tiny-stories-gpt2")
6
+ story = pipe(
7
+ prompt,
8
+ max_length=150,
9
+ num_return_sequences=1,
10
+ do_sample=True,
11
+ temperature=0.8
12
+ )
13
+ return story[0]["generated_text"]
14
+
15
+ demo = gr.Interface(
16
+ fn=generate_story,
17
+ inputs=gr.Textbox(label="Enter a story prompt"),
18
+ outputs=gr.Textbox(label="Generated Story"),
19
+ title="Tiny Story Generator",
20
+ description="A fine-tuned GPT-2 model that writes short creative stories."
21
+ )
22
+
23
+ if __name__ == "__main__":
24
+ demo.launch()