3laa2 commited on
Commit
fa3565d
·
1 Parent(s): 686fb49

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -26
app.py CHANGED
@@ -3,7 +3,6 @@ import cv2 as cv
3
  import time
4
  import torch
5
  from diffusers import StableDiffusionPipeline
6
- import SessionState
7
 
8
  # "stabilityai/stable-diffusion-2-1-base"
9
  # "CompVis/stable-diffusion-v1-4"
@@ -18,30 +17,27 @@ the_type = st.selectbox("Model Name",("stabilityai/stable-diffusion-2-1-base",
18
  "CompVis/stable-diffusion-v1-4"))
19
  create = st.button("Create The Model")
20
 
21
- session_state = SessionState.get(name='', mod=None)
22
-
23
  if create:
24
  t2m_mod = create_model(loc=the_type)
25
- session_state.mod = t2m_mod
26
-
27
- prom = st.text_input("# Prompt",'')
28
-
29
- c1,c2,c3 = st.columns([1,1,3])
30
- c4,c5 = st.columns(2)
31
- with c1:
32
- bu_1 = st.text_input("Seed",'999')
33
- with c2:
34
- bu_2 = st.text_input("Steps",'12')
35
- with c3:
36
- bu_3 = st.text_input("Number of Images",'1')
37
- with c4:
38
- sl_1 = st.slider("Width",256,1024,128)
39
- with c5:
40
- sl_2 = st.slider("hight",256,1024,128)
41
-
42
- create = st.button("Imagine")
43
- if create:
44
- generator = torch.Generator("cpu").manual_seed(int(bu_1))
45
- model = session_state.mod
46
- img = model(prom, width=int(sl_1), height=int(sl_2), num_inference_steps=int(bu_2), generator=generator).images[0]
47
- st.image(img)
 
3
  import time
4
  import torch
5
  from diffusers import StableDiffusionPipeline
 
6
 
7
  # "stabilityai/stable-diffusion-2-1-base"
8
  # "CompVis/stable-diffusion-v1-4"
 
17
  "CompVis/stable-diffusion-v1-4"))
18
  create = st.button("Create The Model")
19
 
 
 
20
  if create:
21
  t2m_mod = create_model(loc=the_type)
22
+ cont = True
23
+ with cont:
24
+ prom = st.text_input("# Prompt",'')
25
+
26
+ c1,c2,c3 = st.columns([1,1,3])
27
+ c4,c5 = st.columns(2)
28
+ with c1:
29
+ bu_1 = st.text_input("Seed",'999')
30
+ with c2:
31
+ bu_2 = st.text_input("Steps",'12')
32
+ with c3:
33
+ bu_3 = st.text_input("Number of Images",'1')
34
+ with c4:
35
+ sl_1 = st.slider("Width",256,1024,128)
36
+ with c5:
37
+ sl_2 = st.slider("hight",256,1024,128)
38
+
39
+ create = st.button("Imagine")
40
+ if create:
41
+ generator = torch.Generator("cpu").manual_seed(int(bu_1))
42
+ img = t2m_mod(prom, width=int(sl_1), height=int(sl_2), num_inference_steps=int(bu_2), generator=generator).images[0]
43
+ st.image(img)