maduvantha commited on
Commit
f0b0938
·
1 Parent(s): fc34ca6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py CHANGED
@@ -2,6 +2,41 @@ import streamlit as st
2
  import pandas as pd
3
  import numpy as np
4
  import matplotlib.pyplot as plt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
  # Create some example data
7
  st.write("Hello, World!")
 
2
  import pandas as pd
3
  import numpy as np
4
  import matplotlib.pyplot as plt
5
+ import imageio
6
+ import numpy as np
7
+ import matplotlib.pyplot as plt
8
+ import matplotlib.animation as animation
9
+ from skimage.transform import resize
10
+ from IPython.display import HTML
11
+ import warnings
12
+
13
+ warnings.filterwarnings("ignore")
14
+ source_image = imageio.imread('harold.jpg')
15
+ driving_video = imageio.mimread('part1.mov')
16
+
17
+
18
+ #Resize image and video to 256x256
19
+
20
+ source_image = resize(source_image, (256, 256))[..., :3]
21
+ driving_video = [resize(frame, (256, 256))[..., :3] for frame in driving_video]
22
+
23
+ def display(source, driving, generated=None):
24
+ fig = plt.figure(figsize=(8 + 4 * (generated is not None), 6))
25
+
26
+ ims = []
27
+ for i in range(len(driving)):
28
+ cols = [source]
29
+ cols.append(driving[i])
30
+ if generated is not None:
31
+ cols.append(generated[i])
32
+ im = plt.imshow(np.concatenate(cols, axis=1), animated=True)
33
+ plt.axis('off')
34
+ ims.append([im])
35
+
36
+ ani = animation.ArtistAnimation(fig, ims, interval=50, repeat_delay=1000)
37
+ plt.close()
38
+ return ani
39
+
40
 
41
  # Create some example data
42
  st.write("Hello, World!")