capradeepgujaran commited on
Commit
bb5413b
·
verified ·
1 Parent(s): 93ce120

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -85,11 +85,12 @@ def analyze_construction_media(media):
85
  "and suggest steps to resolve them. If it's not a construction site, simply state that")
86
 
87
  for i, file in enumerate(media):
88
- file_type = file.name.split('.')[-1].lower()
 
89
 
90
  if file_type in ['jpg', 'jpeg', 'png', 'gif']:
91
  # Handle image
92
- image = Image.open(file.name)
93
  resized_image = resize_image(image)
94
  image_data_url = f"data:image/png;base64,{encode_image(resized_image)}"
95
  messages = [
@@ -122,7 +123,7 @@ def analyze_construction_media(media):
122
  results.append((f"Image {i+1} analysis", result))
123
  elif file_type in ['mp4', 'avi', 'mov', 'wmv']:
124
  # Handle video
125
- frames = extract_frames_from_video(file.name)
126
  for j, frame in enumerate(frames):
127
  image_data_url = f"data:image/png;base64,{encode_image(frame)}"
128
  messages = [
 
85
  "and suggest steps to resolve them. If it's not a construction site, simply state that")
86
 
87
  for i, file in enumerate(media):
88
+ file_path = file.name # Get the file path
89
+ file_type = file_path.split('.')[-1].lower()
90
 
91
  if file_type in ['jpg', 'jpeg', 'png', 'gif']:
92
  # Handle image
93
+ image = Image.open(file_path)
94
  resized_image = resize_image(image)
95
  image_data_url = f"data:image/png;base64,{encode_image(resized_image)}"
96
  messages = [
 
123
  results.append((f"Image {i+1} analysis", result))
124
  elif file_type in ['mp4', 'avi', 'mov', 'wmv']:
125
  # Handle video
126
+ frames = extract_frames_from_video(file_path)
127
  for j, frame in enumerate(frames):
128
  image_data_url = f"data:image/png;base64,{encode_image(frame)}"
129
  messages = [