Dejansimic
commited on
Commit
•
13c4a3f
1
Parent(s):
f444e89
Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
#
|
5 |
-
|
6 |
|
7 |
-
def generate_blog_post(topic
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
return generated[0]['generated_text']
|
12 |
|
13 |
# Gradio interfejs
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
output_area = gr.Textbox(label="Generated Blog Post", placeholder="Your blog post will appear here...", interactive=False)
|
22 |
-
|
23 |
-
generate_button.click(
|
24 |
-
fn=generate_blog_post,
|
25 |
-
inputs=[topic_input, keywords_input],
|
26 |
-
outputs=output_area
|
27 |
-
)
|
28 |
-
|
29 |
-
demo.launch()
|
30 |
|
|
|
31 |
if __name__ == "__main__":
|
32 |
-
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Inicijalizuj model za generisanje teksta
|
5 |
+
text_generator = pipeline("text-generation", model="gpt-2") # Možeš promeniti model ako želiš
|
6 |
|
7 |
+
def generate_blog_post(topic):
|
8 |
+
# Generiši tekst na osnovu zadatog teme
|
9 |
+
response = text_generator(topic, max_length=300, num_return_sequences=1)
|
10 |
+
return response[0]['generated_text']
|
|
|
11 |
|
12 |
# Gradio interfejs
|
13 |
+
demo = gr.Interface(
|
14 |
+
fn=generate_blog_post,
|
15 |
+
inputs=gr.inputs.Textbox(label="Enter the topic for your blog post"),
|
16 |
+
outputs=gr.outputs.Textbox(label="Generated Blog Post"),
|
17 |
+
title="Blog Post Generator",
|
18 |
+
description="Enter a topic and generate a blog post using AI."
|
19 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
+
# Pokreni aplikaciju
|
22 |
if __name__ == "__main__":
|
23 |
+
demo.launch()
|