Anne314159 commited on
Commit
dee81af
·
verified ·
1 Parent(s): f3d322a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -0
app.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ # Initialize a text generation pipeline
5
+ generator = pipeline('text-generation', model='dbmdz/german-gpt2')
6
+
7
+ st.title('German Medical Content Manager')
8
+
9
+ # Sidebar for user input
10
+ st.sidebar.header('User Input Options')
11
+ input_topic = st.sidebar.text_input('Enter a medical topic', 'Type 1 Diabetes')
12
+
13
+ # Main Page
14
+ st.write(f"Creating social media content for: {input_topic}")
15
+
16
+ # Function to generate text based on the input topic
17
+ def generate_content(topic):
18
+ generated_text = generator(f"Letzte Nachrichten über {topic}:", max_length=50, num_return_sequences=1)
19
+ return generated_text[0]['generated_text']
20
+
21
+ if st.button('Generate Social Media Post'):
22
+ with st.spinner('Generating...'):
23
+ post_content = generate_content(input_topic)
24
+ st.success('Generated Content:')
25
+ st.write(post_content)
26
+
27
+ st.write('Generated social media posts will appear here after clicking the "Generate" button.')