Skip to content

Commit

Permalink
Added Mood & Enhanced Speech Classifications
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangsonww committed Mar 30, 2024
1 parent fb53090 commit da79550
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 17 deletions.
Binary file added Object-Classification/balls.mp4
Binary file not shown.
3 changes: 3 additions & 0 deletions Object-Classification/object_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ def main():
choice = input("Choose 'image', 'video', or 'webcam': ").lower()
if choice == 'image':
image_path = input("Enter the image path: ")

print("Check the popup window for the results.")

results, image = classify_image(model, image_path)
annotated_image = annotate_image(image, results)
annotated_image.show()
Expand Down
Binary file added Vehicle-Classification/india.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 33 additions & 17 deletions Vehicle-Classification/vehicle_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,38 +60,54 @@ def process_input(source):

if source == 'webcam':
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
if not ret:
break
process_frame(frame, model, classes, output_layers, colors)
if cv2.waitKey(1) == 27:
break
cap.release()
elif source.endswith(('.png', '.jpg', '.jpeg')):
frame = cv2.imread(source)
if frame is None:
print(f"Failed to load image at {source}")
return
process_frame(frame, model, classes, output_layers, colors)
cv2.waitKey(0)
else:
cap = cv2.VideoCapture(source)
while True:
ret, frame = cap.read()
if not ret:
break
process_frame(frame, model, classes, output_layers, colors)
if cv2.waitKey(1) == 27:
break
cap.release()

while True:
ret, frame = cap.read()
if not ret:
break

height, width, channels = frame.shape
outputs = detect_objects(frame, model, output_layers)
boxes, confs, class_ids = get_box_dimensions(outputs, height, width)
draw_labels(boxes, confs, colors, class_ids, classes, frame)
cv2.destroyAllWindows()

cv2.imshow("Video", frame)
key = cv2.waitKey(1)
if key == 27: # ESC key to exit
break
if cv2.getWindowProperty("Video", cv2.WND_PROP_VISIBLE) < 1: # Check if the window is closed
break

cap.release()
cv2.destroyAllWindows()
def process_frame(frame, model, classes, output_layers, colors):
height, width, channels = frame.shape
outputs = detect_objects(frame, model, output_layers)
boxes, confs, class_ids = get_box_dimensions(outputs, height, width)
draw_labels(boxes, confs, colors, class_ids, classes, frame)
cv2.imshow("Video", frame)


if __name__ == "__main__":
choice = input("Enter 'image', 'video', or 'webcam': ").lower()

if choice == 'image':
image_path = input("Enter the image path: ")
print("Check the popup window for the results.")
process_input(image_path)
elif choice == 'video':
video_path = input("Enter the video path: ")
print("Check the popup window for the results.")
process_input(video_path)
elif choice == 'webcam':
print("Check the popup window for the results.")
process_input('webcam')

0 comments on commit da79550

Please sign in to comment.