rahul7star commited on
Commit
f00b269
Β·
verified Β·
1 Parent(s): 6cec303

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -8
app.py CHANGED
@@ -68,38 +68,52 @@ from huggingface_hub import HfApi, upload_file
68
  import os
69
  import uuid
70
 
 
 
 
 
 
 
71
  def upload_to_hf(video_path, summary_text):
72
  api = HfApi()
73
- unique_folder = f"WAN-T2V-video_{uuid.uuid4().hex[:8]}"
74
- logging.info(f"Creating new HF folder: {unique_folder} in repo {HF_MODEL}")
 
 
 
 
 
 
 
75
 
76
  # Upload video
77
  video_filename = os.path.basename(video_path)
78
- video_hf_path = f"{unique_folder}/{video_filename}"
79
  upload_file(
80
  path_or_fileobj=video_path,
81
  path_in_repo=video_hf_path,
82
  repo_id=HF_MODEL,
83
- repo_type="model", # Specify that it's a model repo
84
  token=os.environ.get("HUGGINGFACE_HUB_TOKEN"),
85
  )
86
  logging.info(f"βœ… Uploaded video to HF: {video_hf_path}")
87
 
88
  # Upload summary.txt
89
- summary_file = f"/tmp/summary.txt"
90
  with open(summary_file, "w", encoding="utf-8") as f:
91
  f.write(summary_text)
92
 
93
- summary_hf_path = f"{unique_folder}/summary.txt"
94
  upload_file(
95
  path_or_fileobj=summary_file,
96
  path_in_repo=summary_hf_path,
97
  repo_id=HF_MODEL,
98
- repo_type="model", # Specify that it's a model repo
99
  token=os.environ.get("HUGGINGFACE_HUB_TOKEN"),
100
  )
101
  logging.info(f"βœ… Uploaded summary to HF: {summary_hf_path}")
102
- return unique_folder
 
103
 
104
 
105
  def get_duration(
 
68
  import os
69
  import uuid
70
 
71
+ import os
72
+ import uuid
73
+ import logging
74
+ from datetime import datetime
75
+ from huggingface_hub import HfApi, upload_file
76
+
77
  def upload_to_hf(video_path, summary_text):
78
  api = HfApi()
79
+
80
+ # Create a date-based folder (YYYY-MM-DD)
81
+ today_str = datetime.now().strftime("%Y-%m-%d")
82
+ date_folder = today_str
83
+
84
+ # Generate a unique subfolder for this upload
85
+ unique_subfolder = f"WANT2V-EXP-upload_{uuid.uuid4().hex[:8]}"
86
+ hf_folder = f"{date_folder}/{unique_subfolder}"
87
+ logging.info(f"Uploading files to HF folder: {hf_folder} in repo {HF_MODEL}")
88
 
89
  # Upload video
90
  video_filename = os.path.basename(video_path)
91
+ video_hf_path = f"{hf_folder}/{video_filename}"
92
  upload_file(
93
  path_or_fileobj=video_path,
94
  path_in_repo=video_hf_path,
95
  repo_id=HF_MODEL,
96
+ repo_type="model",
97
  token=os.environ.get("HUGGINGFACE_HUB_TOKEN"),
98
  )
99
  logging.info(f"βœ… Uploaded video to HF: {video_hf_path}")
100
 
101
  # Upload summary.txt
102
+ summary_file = "/tmp/summary.txt"
103
  with open(summary_file, "w", encoding="utf-8") as f:
104
  f.write(summary_text)
105
 
106
+ summary_hf_path = f"{hf_folder}/summary.txt"
107
  upload_file(
108
  path_or_fileobj=summary_file,
109
  path_in_repo=summary_hf_path,
110
  repo_id=HF_MODEL,
111
+ repo_type="model",
112
  token=os.environ.get("HUGGINGFACE_HUB_TOKEN"),
113
  )
114
  logging.info(f"βœ… Uploaded summary to HF: {summary_hf_path}")
115
+
116
+ return hf_folder
117
 
118
 
119
  def get_duration(