Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emergent Object Detection/Classification Model.v1 #56

Closed
wants to merge 8 commits into from
Binary file added vision/emergent_object/best.pt
Binary file not shown.
26 changes: 26 additions & 0 deletions vision/emergent_object/emergent_object.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import torch
import pandas
fallscameron01 marked this conversation as resolved.
Show resolved Hide resolved


# Function to create model
def emergent_object_model(path_to_weights):
fallscameron01 marked this conversation as resolved.
Show resolved Hide resolved
fallscameron01 marked this conversation as resolved.
Show resolved Hide resolved
fallscameron01 marked this conversation as resolved.
Show resolved Hide resolved
fallscameron01 marked this conversation as resolved.
Show resolved Hide resolved
model = torch.hub.load(
"ultralytics/yolov5", "custom", path=path_to_weights
) # path depends on location of the pretrained weights
fallscameron01 marked this conversation as resolved.
Show resolved Hide resolved
eblake003 marked this conversation as resolved.
Show resolved Hide resolved
return model


# Function to do detection / classification
def emergent_object_detection(image_path, model):
fallscameron01 marked this conversation as resolved.
Show resolved Hide resolved
fallscameron01 marked this conversation as resolved.
Show resolved Hide resolved
image = image_path
results = model(image)
output = results.pandas().xyxy[0]
fallscameron01 marked this conversation as resolved.
Show resolved Hide resolved
fallscameron01 marked this conversation as resolved.
Show resolved Hide resolved
return output
fallscameron01 marked this conversation as resolved.
Show resolved Hide resolved


if __name__ == "__main__":
# Create model
model = emergent_object_model()

# Use model for detection / classification
emergent_object_detection()
eblake003 marked this conversation as resolved.
Show resolved Hide resolved