Spaces:
Runtime error
Runtime error
Image generation error fix
Browse files
app.py
CHANGED
|
@@ -97,14 +97,14 @@ def display_sample_pytorch(seed, truncation, directions, distances, scale, start
|
|
| 97 |
else:
|
| 98 |
w_numpy = [x.cpu().detach().numpy() for x in w]
|
| 99 |
w = [np.expand_dims(x, 0) for x in w_numpy]
|
| 100 |
-
w = [torch.from_numpy(x).to(device) for x in w]
|
| 101 |
#w = [x.unsqueeze(0) for x in w]
|
| 102 |
|
| 103 |
|
| 104 |
for l in range(start, end):
|
| 105 |
for i in range(len(directions)):
|
| 106 |
w[l] = w[l] + directions[i] * distances[i] * scale
|
| 107 |
-
|
|
|
|
| 108 |
torch.cuda.empty_cache()
|
| 109 |
#save image and display
|
| 110 |
out = model.sample(w)
|
|
@@ -255,9 +255,9 @@ if submit_button: # Execute when the submit button is pressed
|
|
| 255 |
w2 = clip_optimized_latent(text2, seed2, iters)
|
| 256 |
st.session_state['w2-np'] = w2
|
| 257 |
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
st.image(
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
|
|
|
| 97 |
else:
|
| 98 |
w_numpy = [x.cpu().detach().numpy() for x in w]
|
| 99 |
w = [np.expand_dims(x, 0) for x in w_numpy]
|
|
|
|
| 100 |
#w = [x.unsqueeze(0) for x in w]
|
| 101 |
|
| 102 |
|
| 103 |
for l in range(start, end):
|
| 104 |
for i in range(len(directions)):
|
| 105 |
w[l] = w[l] + directions[i] * distances[i] * scale
|
| 106 |
+
|
| 107 |
+
w = [torch.from_numpy(x).to(device) for x in w]
|
| 108 |
torch.cuda.empty_cache()
|
| 109 |
#save image and display
|
| 110 |
out = model.sample(w)
|
|
|
|
| 255 |
w2 = clip_optimized_latent(text2, seed2, iters)
|
| 256 |
st.session_state['w2-np'] = w2
|
| 257 |
|
| 258 |
+
try:
|
| 259 |
+
input_im, output_im = generate_image(content, style, truncation, c0, c1, c2, c3, c4, c5, c6, start_layer, end_layer,st.session_state['w1-np'],st.session_state['w2-np'])
|
| 260 |
+
st.image(input_im, caption="Input Image")
|
| 261 |
+
st.image(output_im, caption="Output Image")
|
| 262 |
+
except:
|
| 263 |
+
pass
|