Rahatara commited on
Commit
25080b2
·
verified ·
1 Parent(s): 6517f50

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -34,10 +34,11 @@ def generate_descriptions_for_frames(video_path):
34
  frames = frame_capture(video_path)
35
  images = [PIL.Image.fromarray(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)) for frame in frames]
36
 
37
- prompt = "Describe what is happening in each of these frame. Identify any protetial railway defect or risk."
38
  images_with_prompt = [prompt] + images
39
 
40
  responses = model.generate_content(images_with_prompt)
 
41
  descriptions = [response.text for response in responses]
42
 
43
  formatted_description = format_descriptions(descriptions)
@@ -52,7 +53,9 @@ def chat_interaction(video_path, chatbot, user_message):
52
  images_with_prompt = [prompt] + images
53
 
54
  responses = model.generate_content(images_with_prompt)
55
- response_text = responses[-1].text if user_message.strip() else format_descriptions([r.text for r in responses])
 
 
56
 
57
  chatbot.append((user_message, response_text))
58
  return "", chatbot
 
34
  frames = frame_capture(video_path)
35
  images = [PIL.Image.fromarray(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)) for frame in frames]
36
 
37
+ prompt = "Describe what is happening in each of these frames. Identify any potential railway defect or risk."
38
  images_with_prompt = [prompt] + images
39
 
40
  responses = model.generate_content(images_with_prompt)
41
+
42
  descriptions = [response.text for response in responses]
43
 
44
  formatted_description = format_descriptions(descriptions)
 
53
  images_with_prompt = [prompt] + images
54
 
55
  responses = model.generate_content(images_with_prompt)
56
+
57
+ # Collect the text responses properly
58
+ response_text = "".join([response.text for response in responses])
59
 
60
  chatbot.append((user_message, response_text))
61
  return "", chatbot