File size: 2,589 Bytes
59e84d3
 
 
 
 
 
f777c4c
59e84d3
 
 
 
 
 
f777c4c
 
59e84d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f777c4c
 
 
 
47bd397
 
 
 
 
 
 
 
 
 
 
f777c4c
 
 
47bd397
 
 
 
 
 
 
 
 
 
f777c4c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import gradio as gr
import os
from transformers import pipeline

title = "📗Health and Mindful Story Gen❤️"

# Define the examples to show in the interface
examples = [
    ["Mental Body Scan"],
    ["Stretch, Calm, Breath"],
    ["Relaxed Seat Breath"],
    ["Walk Feel"],
    ["Brain gamification"],
    ["Alleviating stress"],
    ["Helping breathing, satisfaction"],
    ["Relieve Stress, Build Support"],
    ["Relaxation Response"],
    ["Deep Breaths"],
    ["Delete Not Helpful Thoughts"],
    ["Strengthen Helpful"],
    ["Reprogram Pain Stress Reactions"],
    ["Sleep Better and Find Joy"],
    ["Yoga Sleep"],
    ["Being a Happier and Healthier Person"],
    ["Relieve Pain"],
    ["Learn to Use Mindfulness to Affect Well Being"],
    ["Build and Boost Mental Strength"],
    ["Spending Time Outdoors"],
    ["Daily Routine Tasks"],
    ["Eating and Drinking - Find Healthy Nutrition Habits"],
    ["Drinking - Find Reasons and Cut Back or Quit Entirely"],
    ["Feel better each day when you awake by"],
    ["Feel better physically by"],
    ["Practicing mindfulness each day"],
    ["Be happier by"],
    ["Meditation can improve health"],
    ["Spending time outdoors"],
    ["Stress is relieved by quieting your mind, getting exercise and time with nature"],
    ["Break the cycle of stress and anxiety"],
    ["Feel calm in stressful situations"],
    ["Deal with work pressure"],
    ["Learn to reduce feelings of overwhelmed"]
]

# Initialize the models using Hugging Face pipelines
generator1 = pipeline("text-generation", model="gpt2-large")
generator2 = pipeline("text-generation", model="EleutherAI/gpt-neo-2.7B")
generator3 = pipeline("text-generation", model="EleutherAI/gpt-j-6B")

with gr.Blocks() as demo:
    gr.Markdown(f"# {title}")
    input_textbox = gr.Textbox(lines=5, label="Enter a sentence to get another sentence.")

    with gr.Row():
        gen1_output = gr.Textbox(label="GPT-2 Large Output")
        gen2_output = gr.Textbox(label="GPT-Neo Output")
        gen3_output = gr.Textbox(label="GPT-J Output")

    def generate_outputs(input_text):
        out1 = generator1(input_text, max_length=50)[0]['generated_text']
        out2 = generator2(input_text, max_length=50)[0]['generated_text']
        out3 = generator3(input_text, max_length=50)[0]['generated_text']
        return out1, out2, out3

    gr.Button("Generate").click(
        fn=generate_outputs,
        inputs=input_textbox,
        outputs=[gen1_output, gen2_output, gen3_output]
    )

    gr.Examples(examples=examples, inputs=input_textbox)

demo.launch(share=False)