Spaces:
Configuration error
Configuration error
Erwann Millon
commited on
Commit
·
21d692f
1
Parent(s):
61b9782
update state animation
Browse files- ImageState.py +8 -6
- animation.py +18 -17
ImageState.py
CHANGED
|
@@ -50,20 +50,22 @@ class ImageState:
|
|
| 50 |
"./latent_vectors/asian10.pt", map_location=self.device
|
| 51 |
)
|
| 52 |
|
| 53 |
-
def create_gif(
|
|
|
|
|
|
|
| 54 |
images = []
|
| 55 |
-
|
| 56 |
-
paths
|
| 57 |
frame_duration = total_duration / len(paths)
|
| 58 |
print(len(paths), "frame dur", frame_duration)
|
| 59 |
durations = [frame_duration] * len(paths)
|
| 60 |
if extend_frames:
|
| 61 |
durations[0] = 1.5
|
| 62 |
durations[-1] = 3
|
| 63 |
-
for file_name in
|
| 64 |
if file_name.endswith(".png"):
|
| 65 |
-
|
| 66 |
-
images.append(imageio.imread(
|
| 67 |
imageio.mimsave(gif_name, images, duration=durations)
|
| 68 |
return gif_name
|
| 69 |
|
|
|
|
| 50 |
"./latent_vectors/asian10.pt", map_location=self.device
|
| 51 |
)
|
| 52 |
|
| 53 |
+
def create_gif(
|
| 54 |
+
total_duration, extend_frames, folder="./img_history", gif_name="face_edit.gif"
|
| 55 |
+
):
|
| 56 |
images = []
|
| 57 |
+
paths = list(sorted(glob.glob(folder + "/*")))
|
| 58 |
+
print(paths)
|
| 59 |
frame_duration = total_duration / len(paths)
|
| 60 |
print(len(paths), "frame dur", frame_duration)
|
| 61 |
durations = [frame_duration] * len(paths)
|
| 62 |
if extend_frames:
|
| 63 |
durations[0] = 1.5
|
| 64 |
durations[-1] = 3
|
| 65 |
+
for file_name in paths:
|
| 66 |
if file_name.endswith(".png"):
|
| 67 |
+
print(file_name)
|
| 68 |
+
images.append(imageio.imread(file_name))
|
| 69 |
imageio.mimsave(gif_name, images, duration=durations)
|
| 70 |
return gif_name
|
| 71 |
|
animation.py
CHANGED
|
@@ -8,23 +8,24 @@ def clear_img_dir(img_dir):
|
|
| 8 |
os.remove(filename)
|
| 9 |
|
| 10 |
|
| 11 |
-
def create_gif(
|
| 12 |
-
|
| 13 |
-
):
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
| 28 |
|
| 29 |
|
| 30 |
if __name__ == "__main__":
|
|
|
|
| 8 |
os.remove(filename)
|
| 9 |
|
| 10 |
|
| 11 |
+
# def create_gif(
|
| 12 |
+
# total_duration, extend_frames, folder="./img_history", gif_name="face_edit.gif"
|
| 13 |
+
# ):
|
| 14 |
+
# images = []
|
| 15 |
+
# paths = list(sorted(glob.glob(folder + "/*")))
|
| 16 |
+
# print(paths)
|
| 17 |
+
# frame_duration = total_duration / len(paths)
|
| 18 |
+
# print(len(paths), "frame dur", frame_duration)
|
| 19 |
+
# durations = [frame_duration] * len(paths)
|
| 20 |
+
# if extend_frames:
|
| 21 |
+
# durations[0] = 1.5
|
| 22 |
+
# durations[-1] = 3
|
| 23 |
+
# for file_name in paths:
|
| 24 |
+
# if file_name.endswith(".png"):
|
| 25 |
+
# print(file_name)
|
| 26 |
+
# images.append(imageio.imread(file_name))
|
| 27 |
+
# imageio.mimsave(gif_name, images, duration=durations)
|
| 28 |
+
# return gif_name
|
| 29 |
|
| 30 |
|
| 31 |
if __name__ == "__main__":
|