Aliashraf commited on
Commit
b8d6bec
·
verified ·
1 Parent(s): 73c256a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -9
app.py CHANGED
@@ -1,4 +1,3 @@
1
- # app.py
2
  import cv2
3
  import numpy as np
4
  import torch
@@ -12,7 +11,7 @@ feature_extractor = AutoFeatureExtractor.from_pretrained(model_name)
12
 
13
  def process_frame(frame):
14
  # Convert frame to tensor
15
- inputs = feature_extractor(images=frame, return_tensors="pt")
16
  outputs = model(**inputs)
17
  predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
18
  return predictions
@@ -29,17 +28,11 @@ def main():
29
  st.write("Failed to capture video")
30
  break
31
  else:
32
- predictions = process_frame(frame)
33
  frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
 
34
  frame_placeholder.image(frame, channels="RGB")
35
  cap.release()
36
 
37
  if __name__ == "__main__":
38
  main()
39
 
40
- # requirements.txt
41
- opencv-python
42
- numpy
43
- torch
44
- transformers
45
- streamlit
 
 
1
  import cv2
2
  import numpy as np
3
  import torch
 
11
 
12
  def process_frame(frame):
13
  # Convert frame to tensor
14
+ inputs = feature_extractor(images=[frame], return_tensors="pt")
15
  outputs = model(**inputs)
16
  predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
17
  return predictions
 
28
  st.write("Failed to capture video")
29
  break
30
  else:
 
31
  frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
32
+ predictions = process_frame(frame)
33
  frame_placeholder.image(frame, channels="RGB")
34
  cap.release()
35
 
36
  if __name__ == "__main__":
37
  main()
38