txarst commited on
Commit
e67e464
·
1 Parent(s): 659d40d

api output fix

Browse files
gradio_app.py CHANGED
@@ -259,11 +259,15 @@ def process_media_unified(media_input, pupil_selection, tv_model, blink_detectio
259
  if hasattr(media_input, 'name'):
260
  # It's a file object (video)
261
  file_path = media_input.name
262
- if is_video(file_path):
 
 
 
 
263
  plot_img, csv_data, summary_text = process_video_gradio(media_input, pupil_selection, tv_model, blink_detection)
264
  combined_output = f"{summary_text}\n\n--- CSV Data ---\n{csv_data}"
265
  return plot_img, combined_output
266
- elif is_image(file_path):
267
  # Convert file to PIL Image
268
  from PIL import Image
269
  image = Image.open(file_path)
@@ -272,7 +276,7 @@ def process_media_unified(media_input, pupil_selection, tv_model, blink_detectio
272
  # Unknown file type
273
  from PIL import Image
274
  error_img = Image.new('RGB', (400, 200), 'white')
275
- return error_img, f"Unsupported file type: {file_path}"
276
  else:
277
  # It's a PIL Image or other format
278
  if media_input is not None:
 
259
  if hasattr(media_input, 'name'):
260
  # It's a file object (video)
261
  file_path = media_input.name
262
+ # Extract file extension from the path
263
+ import os
264
+ file_extension = os.path.splitext(file_path)[1][1:] # Remove the dot
265
+
266
+ if is_video(file_extension):
267
  plot_img, csv_data, summary_text = process_video_gradio(media_input, pupil_selection, tv_model, blink_detection)
268
  combined_output = f"{summary_text}\n\n--- CSV Data ---\n{csv_data}"
269
  return plot_img, combined_output
270
+ elif is_image(file_extension):
271
  # Convert file to PIL Image
272
  from PIL import Image
273
  image = Image.open(file_path)
 
276
  # Unknown file type
277
  from PIL import Image
278
  error_img = Image.new('RGB', (400, 200), 'white')
279
+ return error_img, f"Unsupported file type: {file_extension}. Supported video formats: mp4, avi, mov, mkv, webm, flv, wmv. Supported image formats: png, jpg, jpeg, bmp, tiff, webp."
280
  else:
281
  # It's a PIL Image or other format
282
  if media_input is not None:
sample_videos/{All Smiles Ahead.webm → AllSmilesAhead.webm} RENAMED
File without changes