Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -91,31 +91,23 @@ if user_image_object is not None:
|
|
| 91 |
|
| 92 |
'''Show some demos: '''
|
| 93 |
|
|
|
|
| 94 |
if len(img_array) > 7:
|
| 95 |
for ii in [1, 4, 7]:
|
| 96 |
st.image( img_array[ii] )
|
| 97 |
|
| 98 |
-
|
|
|
|
| 99 |
|
| 100 |
-
|
| 101 |
-
So to show the video/gif we save it as a file then open that file to show it in streamlit'''
|
| 102 |
-
|
| 103 |
-
''' mp4 method
|
| 104 |
-
out = cv2.VideoWriter('outputvideo.mp4',cv2.VideoWriter_fourcc(*'DIVX'), 15, size)
|
| 105 |
-
for i in range(len(img_array)):
|
| 106 |
-
out.write(img_array[i])
|
| 107 |
-
out.release()
|
| 108 |
-
|
| 109 |
-
video_file = open('outputvideo.mp4', 'rb')
|
| 110 |
-
video_bytes = video_file.read()
|
| 111 |
-
st.video(video_bytes )
|
| 112 |
-
'''
|
| 113 |
|
|
|
|
| 114 |
img, *imgs = [Image.open(f) for f in output_filename_array]
|
| 115 |
img.save(fp="output_gif.gif", format='GIF', append_images=imgs,
|
| 116 |
save_all=True, duration=duration_parameter, loop=loop_parameter)
|
| 117 |
-
|
| 118 |
-
|
|
|
|
| 119 |
"""### gif from local file"""
|
| 120 |
file_ = open("output_gif.gif", "rb")
|
| 121 |
contents = file_.read()
|
|
|
|
| 91 |
|
| 92 |
'''Show some demos: '''
|
| 93 |
|
| 94 |
+
#Uncomment this if to show some sample images of the gif
|
| 95 |
if len(img_array) > 7:
|
| 96 |
for ii in [1, 4, 7]:
|
| 97 |
st.image( img_array[ii] )
|
| 98 |
|
| 99 |
+
#HuggingFaces Spaces can create a video vile ephemerally but doesn't actually save one that we can access.
|
| 100 |
+
#So to show the video/gif we save it as a file then open that file to show it in streamlit
|
| 101 |
|
| 102 |
+
st.text("Generating GIF, may take a minute")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
+
#Create GIF
|
| 105 |
img, *imgs = [Image.open(f) for f in output_filename_array]
|
| 106 |
img.save(fp="output_gif.gif", format='GIF', append_images=imgs,
|
| 107 |
save_all=True, duration=duration_parameter, loop=loop_parameter)
|
| 108 |
+
|
| 109 |
+
|
| 110 |
+
#Show gif using this script to show gifs in streamlit https://discuss.streamlit.io/t/how-to-show-local-gif-image/3408/2
|
| 111 |
"""### gif from local file"""
|
| 112 |
file_ = open("output_gif.gif", "rb")
|
| 113 |
contents = file_.read()
|