Omnibus commited on
Commit
749bb52
1 Parent(s): 71aa58b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -2
app.py CHANGED
@@ -5,7 +5,8 @@ import requests
5
  import uuid
6
  import io
7
  import base64
8
- import threading
 
9
 
10
  loaded_model=[]
11
  for i,model in enumerate(models):
@@ -16,6 +17,35 @@ for i,model in enumerate(models):
16
  pass
17
  print (loaded_model)
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  def run_dif(out_prompt,model_drop,cnt):
20
  p_seed=""
21
  out_box=[]
@@ -136,5 +166,5 @@ with gr.Blocks(css=css) as app:
136
  cnt = gr.Number(value=1)
137
  out_html=gr.HTML()
138
  outp=gr.Gallery()
139
- btn.click(run_dif,[inp,model_drop,cnt],[outp,out_html])
140
  app.launch()
 
5
  import uuid
6
  import io
7
  import base64
8
+ from transforms import RGBTransform # from source code mentioned above
9
+
10
 
11
  loaded_model=[]
12
  for i,model in enumerate(models):
 
17
  pass
18
  print (loaded_model)
19
 
20
+
21
+
22
+ def run_dif_color(out_prompt,model_drop,cnt,color):
23
+
24
+ p_seed=""
25
+ out_box=[]
26
+ out_html=""
27
+ #for i,ea in enumerate(loaded_model):
28
+ for i in range(int(cnt)):
29
+ p_seed+=" "
30
+ try:
31
+ model=loaded_model[int(model_drop)]
32
+ out_img=model(out_prompt+p_seed)
33
+ print(out_img)
34
+
35
+ raw=Image.open(out_img)
36
+ raw=raw.convert('RGB')
37
+
38
+ colorize = RGBTransform().mix_with((255, 0, 0),factor=.30).applied_to(raw)
39
+
40
+ out_box.append(colorize)
41
+ except Exception as e:
42
+ print(e)
43
+ out_html=str(e)
44
+ pass
45
+
46
+ yield out_box,out_html
47
+
48
+
49
  def run_dif(out_prompt,model_drop,cnt):
50
  p_seed=""
51
  out_box=[]
 
166
  cnt = gr.Number(value=1)
167
  out_html=gr.HTML()
168
  outp=gr.Gallery()
169
+ btn.click(run_dif_color,[inp,model_drop,cnt],[outp,out_html])
170
  app.launch()