Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -32,17 +32,16 @@ grid_wide=10
|
|
32 |
|
33 |
|
34 |
|
35 |
-
def get_concat_h_cut(in1, in2):
|
36 |
print(in1)
|
37 |
print(in2)
|
38 |
im1=Image.open(in1)
|
39 |
im2=Image.open(in2)
|
40 |
#im1=in1
|
41 |
#im2=in2
|
42 |
-
dst = Image.new('RGB', (im1.width + im2.width,
|
43 |
-
|
44 |
-
dst.paste(
|
45 |
-
dst.paste(im2, (im1.width, 0))
|
46 |
return dst
|
47 |
|
48 |
|
@@ -72,7 +71,7 @@ def load_model(model_drop):
|
|
72 |
|
73 |
def run_dif_color(out_prompt,im_path,model_drop,tint,im_height,im_width):
|
74 |
uid=uuid.uuid4()
|
75 |
-
|
76 |
p_seed=""
|
77 |
out_box=[]
|
78 |
out_html=""
|
@@ -80,6 +79,7 @@ def run_dif_color(out_prompt,im_path,model_drop,tint,im_height,im_width):
|
|
80 |
im_width=int(im_width)
|
81 |
#for i,ea in enumerate(im_path.root):
|
82 |
cnt = 0
|
|
|
83 |
for hh in range(int(im_height/grid_wide)):
|
84 |
for b in range(int(im_width/grid_wide)):
|
85 |
|
@@ -100,7 +100,7 @@ def run_dif_color(out_prompt,im_path,model_drop,tint,im_height,im_width):
|
|
100 |
p_seed+=" "
|
101 |
try:
|
102 |
#model=gr.load(f'models/{model[int(model_drop)]}')
|
103 |
-
|
104 |
out_img=model(out_prompt+p_seed)
|
105 |
#print(out_img)
|
106 |
|
@@ -119,8 +119,8 @@ def run_dif_color(out_prompt,im_path,model_drop,tint,im_height,im_width):
|
|
119 |
#im_roll = get_concat_v_cut(f'{out_box[0]}',f'{out_box[1]}')
|
120 |
#im_roll.save(f'comb-{uid}-tmp.png')
|
121 |
#for i in range(2,len(out_box)):
|
122 |
-
im_roll = get_concat_h_cut(f'comb-{uid}-tmp.png',f'{out_box[cnt]}')
|
123 |
-
|
124 |
im_roll.save(f'comb-{uid}-tmp.png')
|
125 |
out = f'comb-{uid}-tmp.png'
|
126 |
yield gr.Image(out),out_html
|
@@ -130,7 +130,7 @@ def run_dif_color(out_prompt,im_path,model_drop,tint,im_height,im_width):
|
|
130 |
#tmp_im = out_box[0]
|
131 |
tmp_im.save(f'comb-{uid}-tmp.png')
|
132 |
out = f'comb-{uid}-tmp.png'
|
133 |
-
yield out,out_html
|
134 |
|
135 |
|
136 |
except Exception as e:
|
@@ -139,8 +139,8 @@ def run_dif_color(out_prompt,im_path,model_drop,tint,im_height,im_width):
|
|
139 |
pass
|
140 |
|
141 |
cnt+=1
|
142 |
-
|
143 |
-
yield out,out_html
|
144 |
|
145 |
|
146 |
|
|
|
32 |
|
33 |
|
34 |
|
35 |
+
def get_concat_h_cut(in1, in2, adj_h):
|
36 |
print(in1)
|
37 |
print(in2)
|
38 |
im1=Image.open(in1)
|
39 |
im2=Image.open(in2)
|
40 |
#im1=in1
|
41 |
#im2=in2
|
42 |
+
dst = Image.new('RGB', (im1.width + im2.width, min(im1.height, im2.height)))
|
43 |
+
dst.paste(im1, (0, int(adj_h)))
|
44 |
+
dst.paste(im2, (im1.width, int(adj_h)))
|
|
|
45 |
return dst
|
46 |
|
47 |
|
|
|
71 |
|
72 |
def run_dif_color(out_prompt,im_path,model_drop,tint,im_height,im_width):
|
73 |
uid=uuid.uuid4()
|
74 |
+
model=loaded_model[int(model_drop)]
|
75 |
p_seed=""
|
76 |
out_box=[]
|
77 |
out_html=""
|
|
|
79 |
im_width=int(im_width)
|
80 |
#for i,ea in enumerate(im_path.root):
|
81 |
cnt = 0
|
82 |
+
adj_h=0
|
83 |
for hh in range(int(im_height/grid_wide)):
|
84 |
for b in range(int(im_width/grid_wide)):
|
85 |
|
|
|
100 |
p_seed+=" "
|
101 |
try:
|
102 |
#model=gr.load(f'models/{model[int(model_drop)]}')
|
103 |
+
|
104 |
out_img=model(out_prompt+p_seed)
|
105 |
#print(out_img)
|
106 |
|
|
|
119 |
#im_roll = get_concat_v_cut(f'{out_box[0]}',f'{out_box[1]}')
|
120 |
#im_roll.save(f'comb-{uid}-tmp.png')
|
121 |
#for i in range(2,len(out_box)):
|
122 |
+
#im_roll = get_concat_h_cut(f'comb-{uid}-tmp.png',f'{out_box[cnt]}')
|
123 |
+
im_roll = get_concat_h_cut(f'comb-{uid}-tmp.png',f'tmp-{cnt}-{uid}.png',adj_h=adj_h)
|
124 |
im_roll.save(f'comb-{uid}-tmp.png')
|
125 |
out = f'comb-{uid}-tmp.png'
|
126 |
yield gr.Image(out),out_html
|
|
|
130 |
#tmp_im = out_box[0]
|
131 |
tmp_im.save(f'comb-{uid}-tmp.png')
|
132 |
out = f'comb-{uid}-tmp.png'
|
133 |
+
yield gr.Image(out),out_html
|
134 |
|
135 |
|
136 |
except Exception as e:
|
|
|
139 |
pass
|
140 |
|
141 |
cnt+=1
|
142 |
+
adj_h+=grid_wide
|
143 |
+
yield gr.Image(out),out_html
|
144 |
|
145 |
|
146 |
|