File size: 861 Bytes
033b3d4
eb2f3de
3670523
eb2f3de
6a6bb68
3670523
 
c37c54b
6703ecd
c37c54b
3670523
 
 
c37c54b
 
 
 
 
033b3d4
3670523
 
033b3d4
 
3670523
c37c54b
 
033b3d4
3670523
 
c37c54b
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
import gradio as gr
from transformers import pipeline

# Load the text generation pipeline
pipe = pipeline("text-generation", model="openai-community/gpt2")     

# Define the function for text generation
def generate(text):
    result = pipe(text, max_length=69, num_return_sequences=5)
    return result[0]['generated_text']

# Define examples
examples = [
    ["What is the fundamental difference between supervised and unsupervised learning"],
    ["What is overfitting in supervised learning"],
    ["What is a convolutional neural network"],
    ["Describe the concept of transfer learning and its significance in deep learning"]

]

# Create the Gradio interface
run = gr.Interface(
    fn=generate,
    inputs=gr.Textbox(lines=5, label="Input Text"),
    outputs=gr.Textbox(label="Generated Text"),
    examples=examples
)

# Launch the app
run.launch()