Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -32,7 +32,7 @@ grid_wide=10
|
|
32 |
|
33 |
|
34 |
|
35 |
-
def
|
36 |
print(in1)
|
37 |
print(in2)
|
38 |
im1=Image.open(in1)
|
@@ -59,6 +59,15 @@ def get_concat_h_cut(in1, in2, pos_x,pos_y):
|
|
59 |
dst.paste(im2, (im1.width, im2.height *pos_y))
|
60 |
return dst
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
def get_concat_v_cut(in1, in2):
|
64 |
print(in1)
|
@@ -89,6 +98,7 @@ def run_dif_color(out_prompt,im_path,model_drop,tint,im_height,im_width):
|
|
89 |
model=loaded_model[int(model_drop)]
|
90 |
p_seed=""
|
91 |
out_box=[]
|
|
|
92 |
out_html=""
|
93 |
im_height=int(im_height)
|
94 |
im_width=int(im_width)
|
@@ -135,25 +145,33 @@ def run_dif_color(out_prompt,im_path,model_drop,tint,im_height,im_width):
|
|
135 |
#im_roll.save(f'comb-{uid}-tmp.png')
|
136 |
#for i in range(2,len(out_box)):
|
137 |
#im_roll = get_concat_h_cut(f'comb-{uid}-tmp.png',f'{out_box[cnt]}')
|
138 |
-
im_roll = get_concat_h_cut(f'comb-{uid}-tmp.png',f'tmp-{cnt}-{uid}.png'
|
139 |
-
im_roll.save(f'comb-{uid}-tmp.png')
|
140 |
-
out = f'comb-{uid}-tmp.png'
|
141 |
yield gr.Image(out),out_html
|
142 |
|
143 |
else:
|
144 |
tmp_im = Image.open(out_box[0])
|
145 |
#tmp_im = out_box[0]
|
146 |
-
tmp_im.save(f'comb-{uid}-tmp.png')
|
147 |
-
out = f'comb-{uid}-tmp.png'
|
148 |
yield gr.Image(out),out_html
|
149 |
|
150 |
-
|
151 |
except Exception as e:
|
152 |
print(e)
|
153 |
out_html=str(e)
|
154 |
pass
|
155 |
|
156 |
cnt+=1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
adj_h+=1
|
158 |
yield gr.Image(out),out_html
|
159 |
|
|
|
32 |
|
33 |
|
34 |
|
35 |
+
def get_concat_h_cut_old(in1, in2, pos_x,pos_y):
|
36 |
print(in1)
|
37 |
print(in2)
|
38 |
im1=Image.open(in1)
|
|
|
59 |
dst.paste(im2, (im1.width, im2.height *pos_y))
|
60 |
return dst
|
61 |
|
62 |
+
def get_concat_h_cut(in1, in2):
|
63 |
+
print(in1)
|
64 |
+
print(in2)
|
65 |
+
im1=Image.open(in1)
|
66 |
+
im2=Image.open(in2)
|
67 |
+
dst = Image.new('RGB', (im1.width + im2.width, min(im1.height,im2.height)))
|
68 |
+
dst.paste(im1, (0, 0))
|
69 |
+
dst.paste(im2, (im1.width,0))
|
70 |
+
return dst
|
71 |
|
72 |
def get_concat_v_cut(in1, in2):
|
73 |
print(in1)
|
|
|
98 |
model=loaded_model[int(model_drop)]
|
99 |
p_seed=""
|
100 |
out_box=[]
|
101 |
+
big_box=[]
|
102 |
out_html=""
|
103 |
im_height=int(im_height)
|
104 |
im_width=int(im_width)
|
|
|
145 |
#im_roll.save(f'comb-{uid}-tmp.png')
|
146 |
#for i in range(2,len(out_box)):
|
147 |
#im_roll = get_concat_h_cut(f'comb-{uid}-tmp.png',f'{out_box[cnt]}')
|
148 |
+
im_roll = get_concat_h_cut(f'comb-{uid}-{hh}-tmp.png',f'tmp-{cnt}-{uid}.png')
|
149 |
+
im_roll.save(f'comb-{uid}-{hh}-tmp.png')
|
150 |
+
out = f'comb-{uid}-{hh}-tmp.png'
|
151 |
yield gr.Image(out),out_html
|
152 |
|
153 |
else:
|
154 |
tmp_im = Image.open(out_box[0])
|
155 |
#tmp_im = out_box[0]
|
156 |
+
tmp_im.save(f'comb-{uid}-{hh}-tmp.png')
|
157 |
+
out = f'comb-{uid}-{hh}-tmp.png'
|
158 |
yield gr.Image(out),out_html
|
159 |
|
|
|
160 |
except Exception as e:
|
161 |
print(e)
|
162 |
out_html=str(e)
|
163 |
pass
|
164 |
|
165 |
cnt+=1
|
166 |
+
big_box.append(f'comb-{uid}-{hh}-tmp.png')
|
167 |
+
|
168 |
+
if big_box:
|
169 |
+
print(f'big_box:: {big_box}')
|
170 |
+
if len(big_box)>1:
|
171 |
+
im_roll2 = get_concat_v_cut(big_box[hh],big_box[hh-1])
|
172 |
+
im_roll2.save(f'comb-{uid}-{hh}-out.png')
|
173 |
+
out=[]
|
174 |
+
yield gr.Image(f'comb-{uid}-{hh}-out.png'),out_html
|
175 |
adj_h+=1
|
176 |
yield gr.Image(out),out_html
|
177 |
|