RaphaelLiu commited on
Commit
035a2be
1 Parent(s): 337fe94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -174,6 +174,12 @@ window.onload = addMotionBackgrounds;
174
  # # video_html += "</center>"
175
  # return video_html
176
 
 
 
 
 
 
 
177
  def showcase(page_num):
178
  videos_per_page = 1
179
  start_index = (page_num - 1) * videos_per_page
@@ -185,19 +191,21 @@ def showcase(page_num):
185
  caption_name = f"{i:04d}.txt"
186
  video_html += "<div class='video-container'>"
187
 
188
- for category in [ 'VideoCrafter2','Pika','VideoCrafter1','VideoCrafter0.9','Pika1.0', 'Gen2-09.2023','Gen2-12.2023','HotShot','Lavie-Base','Lavie-Interpolation','ModelScope','MoonValley','Show1', 'ZeroScope']:
189
- video_url = f"https://huggingface.co/spaces/RaphaelLiu/EvalCrafter-T2V-Gallery/resolve/main/0001.mp4"
190
  caption_path = os.path.join('prompts', caption_name)
191
- if os.path.exists(os.path.join('static', category, video_name)):
192
  caption_text = ""
193
  if os.path.exists(caption_path):
194
  with open(caption_path, 'r') as file:
195
  caption_text = file.read().strip()
196
 
 
 
197
  video_html += f"""
198
  <div class='video-item'>
199
  <video controls>
200
- <source src="{video_url}" type="video/mp4">
201
  Your browser does not support the video tag.
202
  </video>
203
  <p class='video-caption'>{category}: {caption_text}</p>
@@ -208,7 +216,6 @@ def showcase(page_num):
208
  video_html += "</div>"
209
  return video_html
210
 
211
-
212
  # Description and Acknowledgements
213
 
214
  description_html = """
 
174
  # # video_html += "</center>"
175
  # return video_html
176
 
177
+ import base64
178
+
179
+ def video_to_base64(video_path):
180
+ with open(video_path, "rb") as video_file:
181
+ return base64.b64encode(video_file.read()).decode('utf-8')
182
+
183
  def showcase(page_num):
184
  videos_per_page = 1
185
  start_index = (page_num - 1) * videos_per_page
 
191
  caption_name = f"{i:04d}.txt"
192
  video_html += "<div class='video-container'>"
193
 
194
+ for category in ['VideoCrafter2', 'Pika', 'VideoCrafter1', 'VideoCrafter0.9', 'Pika1.0', 'Gen2-09.2023', 'Gen2-12.2023', 'HotShot', 'Lavie-Base', 'Lavie-Interpolation', 'ModelScope', 'MoonValley', 'Show1', 'ZeroScope']:
195
+ video_path = f"./{category}/{video_name}" # Updated to use local path
196
  caption_path = os.path.join('prompts', caption_name)
197
+ if os.path.exists(video_path):
198
  caption_text = ""
199
  if os.path.exists(caption_path):
200
  with open(caption_path, 'r') as file:
201
  caption_text = file.read().strip()
202
 
203
+ # Convert video to Base64 for embedding if necessary
204
+ video_base64 = video_to_base64(video_path)
205
  video_html += f"""
206
  <div class='video-item'>
207
  <video controls>
208
+ <source src="data:video/mp4;base64,{video_base64}" type="video/mp4">
209
  Your browser does not support the video tag.
210
  </video>
211
  <p class='video-caption'>{category}: {caption_text}</p>
 
216
  video_html += "</div>"
217
  return video_html
218
 
 
219
  # Description and Acknowledgements
220
 
221
  description_html = """