vs4vijay commited on
Commit
fe24022
·
1 Parent(s): cffabb0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -0
app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import transformers
3
+
4
+ # Load the Dall-E model
5
+ dalle2 = transformers.DALL-E2.from_pretrained('dall-e')
6
+
7
+ # Load the Stable Diffusion model
8
+ stable_diffusion = transformers.StableDiffusion.from_pretrained('stable-diffusion')
9
+
10
+ # Load the GPT-2 model
11
+ gpt2 = transformers.GPT2.from_pretrained('gpt2')
12
+
13
+ # Load the GPT-3 model
14
+ gpt3 = transformers.GPT3.from_pretrained('gpt3')
15
+
16
+ # Load the ChatGPT model
17
+ chatgpt = transformers.ChatGPT.from_pretrained('chatgpt')
18
+
19
+ # Define a function that takes in an input text and returns the output text generated by the model
20
+ def generate_text(input_text, model):
21
+ input_ids = model.encode(input_text)
22
+ output = model.generate(input_ids)
23
+ output_text = model.decode(output[0])
24
+ return output_text
25
+
26
+ # Create a Gradio interface for the Dall-E2 model
27
+ dalle2_interface = gr.Interface(fn=generate_text,
28
+ inputs=gr.inputs.Textbox(lines=1, label='Enter your text for Dall-E2'),
29
+ outputs=gr.outputs.Textbox(label='Generated text'),
30
+ description='Dall-E2 Text Generation',
31
+ model=dalle2)
32
+ dalle2_interface.launch()
33
+
34
+ # Create a Gradio interface for the Stable Diffusion model
35
+ stable_diffusion_interface = gr.Interface(fn=generate_text,
36
+ inputs=gr.inputs.Textbox(lines=1, label='Enter your text for Stable Diffusion'),
37
+ outputs=gr.outputs.Textbox(label='Generated text'),
38
+ description='Stable Diffusion Text Generation',
39
+ model=stable_diffusion)
40
+ stable_diffusion_interface.launch()
41
+
42
+ # Create a Gradio interface for the GPT-2 model
43
+ gpt2_interface = gr.Interface(fn=generate_text, inputs=gr.inputs.Textbox(lines=1, label='Enter your text for GPT-3'), outputs=gr.outputs.Textbox(label='Generated text'), description='GPT-2 Text Generation', model=gpt2)
44
+ gpt2_interface.launch()
45
+
46
+ # Create a Gradio interface for the GPT-3 model
47
+ gpt3_interface = gr.Interface(fn=generate_text, inputs=gr.inputs.Textbox(lines=1, label='Enter your text for GPT-3'), outputs=gr.outputs.Textbox(label='Generated text'), description='GPT-3 Text Generation', model=gpt3)
48
+ gpt3_interface.launch()
49
+
50
+ # Create a Gradio interface for the ChatGPT model
51
+ chatgpt_interface = gr.Interface(fn=generate_text, inputs=gr.inputs.Textbox(lines=1, label='Enter your text for ChatGPT'), outputs=gr.outputs.Textbox(label='Generated text'), description='ChatGPT Text Generation', model=chatgpt)
52
+ chatgpt_interface.launch()