Fred808 commited on
Commit
36bd2b5
·
verified ·
1 Parent(s): 67adc9d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -4
app.py CHANGED
@@ -161,12 +161,31 @@ async def send_image_for_captioning(image_path: Path, course_name: str, server:
161
 
162
  async def download_and_extract_zip(course_name: str) -> Optional[Path]:
163
  """Downloads the zip file for the course and extracts its contents."""
164
- zip_filename = f"{course_name}.zip"
165
- repo_file = f"frames/{zip_filename}"
166
-
167
- print(f"[{FLOW_ID}] Downloading {repo_file} from {HF_DATASET_ID}...")
168
 
169
  try:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
  # Use hf_hub_download to get the file path
171
  zip_path = hf_hub_download(
172
  repo_id=HF_DATASET_ID,
 
161
 
162
  async def download_and_extract_zip(course_name: str) -> Optional[Path]:
163
  """Downloads the zip file for the course and extracts its contents."""
164
+ print(f"[{FLOW_ID}] Looking for files starting with '{course_name}' in frames/ directory...")
 
 
 
165
 
166
  try:
167
+ api = HfApi(token=HF_TOKEN)
168
+
169
+ # List all files in the frames directory
170
+ repo_files = api.list_repo_files(
171
+ repo_id=HF_DATASET_ID,
172
+ repo_type="dataset"
173
+ )
174
+
175
+ # Find zip files that start with the course name
176
+ matching_files = [
177
+ f for f in repo_files
178
+ if f.startswith(f"frames/{course_name}") and f.endswith('.zip')
179
+ ]
180
+
181
+ if not matching_files:
182
+ print(f"[{FLOW_ID}] No zip files found starting with '{course_name}' in frames/ directory.")
183
+ return None
184
+
185
+ # Use the first matching file (you could modify this to process all matches)
186
+ repo_file = matching_files[0]
187
+ print(f"[{FLOW_ID}] Found matching file: {repo_file}")
188
+
189
  # Use hf_hub_download to get the file path
190
  zip_path = hf_hub_download(
191
  repo_id=HF_DATASET_ID,