Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import os
|
2 |
import base64
|
3 |
import gradio as gr
|
4 |
-
from PIL import Image
|
5 |
import io
|
6 |
import json
|
7 |
from groq import Groq
|
@@ -45,12 +45,12 @@ def encode_image(image):
|
|
45 |
def resize_image(image, max_size=(800, 800)):
|
46 |
"""Resize image to avoid exceeding the API size limits."""
|
47 |
try:
|
48 |
-
image.thumbnail(max_size, Image.
|
49 |
return image
|
50 |
except Exception as e:
|
51 |
logger.error(f"Error resizing image: {str(e)}")
|
52 |
-
raise
|
53 |
-
|
54 |
def extract_frames_from_video(video, frame_points=[0, 0.5, 1], max_size=(800, 800)):
|
55 |
"""Extract key frames from the video at specific time points."""
|
56 |
cap = cv2.VideoCapture(video)
|
|
|
1 |
import os
|
2 |
import base64
|
3 |
import gradio as gr
|
4 |
+
from PIL import Image, ImageOps
|
5 |
import io
|
6 |
import json
|
7 |
from groq import Groq
|
|
|
45 |
def resize_image(image, max_size=(800, 800)):
|
46 |
"""Resize image to avoid exceeding the API size limits."""
|
47 |
try:
|
48 |
+
image.thumbnail(max_size, Image.Resampling.LANCZOS) # Use LANCZOS resampling for better quality
|
49 |
return image
|
50 |
except Exception as e:
|
51 |
logger.error(f"Error resizing image: {str(e)}")
|
52 |
+
raise
|
53 |
+
|
54 |
def extract_frames_from_video(video, frame_points=[0, 0.5, 1], max_size=(800, 800)):
|
55 |
"""Extract key frames from the video at specific time points."""
|
56 |
cap = cv2.VideoCapture(video)
|