ritwikbiswas commited on
Commit
b29e29f
1 Parent(s): 3057350

try diffusion

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -1,12 +1,12 @@
1
  import gradio as gr
2
  import os
3
  import openai
4
- # from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
5
- # import torch
6
 
7
- # model_id = "stabilityai/stable-diffusion-2-1"
8
- # pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
9
- # pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
10
  # pipe = pipe.to("cuda")
11
 
12
  openai.api_key = os.getenv("OPENAI_API_KEY")
@@ -32,9 +32,9 @@ def generate_prompt(radio,word1,word2):
32
  )['choices'][0]['text']
33
 
34
  response_txt = response.replace('\n','')
35
- # diffusion_in = f'a dramatic painting of: {response_txt.split(".")[0]}'
36
- # image = pipe(diffusion_in).images[0]
37
- return response_txt#, image
38
 
39
  demo = gr.Interface(
40
  generate_prompt,
@@ -45,11 +45,11 @@ demo = gr.Interface(
45
  # gr.Dropdown(team_list, value=[team_list[random.randint(1,30)]], multiselect=True),
46
  # gr.Checkbox(label="Is it the morning?"),
47
  ],
48
- "text",
49
  # "image",
50
  allow_flagging="never",
51
  title="GPT-3 Analogy Lab 🧪",
52
- description="foo tested",
53
  css="footer {visibility: hidden}"
54
  )
55
 
 
1
  import gradio as gr
2
  import os
3
  import openai
4
+ from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
5
+ import torch
6
 
7
+ model_id = "stabilityai/stable-diffusion-2-1"
8
+ pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
9
+ pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
10
  # pipe = pipe.to("cuda")
11
 
12
  openai.api_key = os.getenv("OPENAI_API_KEY")
 
32
  )['choices'][0]['text']
33
 
34
  response_txt = response.replace('\n','')
35
+ diffusion_in = f'a dramatic painting of: {response_txt.split(".")[0]}'
36
+ image = pipe(diffusion_in).images[0]
37
+ return response_txt, image
38
 
39
  demo = gr.Interface(
40
  generate_prompt,
 
45
  # gr.Dropdown(team_list, value=[team_list[random.randint(1,30)]], multiselect=True),
46
  # gr.Checkbox(label="Is it the morning?"),
47
  ],
48
+ ["text","image"],
49
  # "image",
50
  allow_flagging="never",
51
  title="GPT-3 Analogy Lab 🧪",
52
+ description="Enter two things you want to connect.",
53
  css="footer {visibility: hidden}"
54
  )
55