Closed pushkin-dev closed 1 year ago
Hi,
Apologies for the trouble you're facing! I appreciate for your interest in SoccerTrack and am grateful that you raised this issue. This might be due to an outdated version of SoccerTrack, so the pip installation may not be working.
Try reinstalling it from the source:
git clone https://github.com/AtomScott/SoccerTrack.git
cd SoccerTrack
conda create -y --name soccertrack python=3.10
conda activate soccertrack
python -m pip install -e .
Also, install these dependencies:
python -m pip install torch torchvision pytorch-lightning
python -m pip install git+https://github.com/KaiyangZhou/deep-person-reid.git
python -m pip install ultralytics
python -m pip install git+https://github.com/openai/CLIP.git
Sorry for any confusion due to outdated docs. I'm working on updates! Let us know if the issue persists.
after upgrade python to 3.10 and following the steps that you described above - everything is ok but there is a new error
AttributeError Traceback (most recent call last)
Cell In [30], line 15
12 model_ckpt = root / "models" / "yolov5" / "yolov5x_last.pt"
14 # define the player detection model
---> 15 player_det_model = detection_model.load(model_name, model_repo, model_ckpt)
16 player_det_model.model.conf = 0.5
17 player_det_model.model.size = 1920
File ~/soccertrack/SoccerTrack/soccertrack/detection_model/__init__.py:74, in load(model_name, model_config, inference_config)
72 for cls in inheritors(BaseDetectionModel):
73 if model_name in [cls.__name__.lower(), cls.__name__]:
---> 74 return cls(
75 model_config=model_config,
76 inference_config=inference_config,
77 )
78 logger.warning(
79 f"Model {model_name} not found. Available models: {[cls.__name__ for cls in inheritors(BaseDetectionModel)]} (lowercase is allowed)"
80 )
File ~/soccertrack/SoccerTrack/soccertrack/detection_model/base.py:151, in BaseDetectionModel.__init__(self, model_config, inference_config)
143 """
144 Initializes the base detection model.
145
(...)
148 inference_config (Optional[dict]): The configuration for the inference. This is optional and can be used to pass additional parameters to the inference.
149 """
150 super().__init__()
--> 151 self.model_config = self.validate_model_config(model_config)
152 self.inference_config = self.validate_inference_config(inference_config)
153 self.input_is_batched = False # initialize the input_is_batched attribute
File ~/soccertrack/SoccerTrack/soccertrack/detection_model/base.py:284, in BaseDetectionModel.validate_model_config(self, config)
283 def validate_model_config(self, config: dict):
--> 284 return validate_config(config, self.model_config_template)
File ~/soccertrack/SoccerTrack/soccertrack/detection_model/base.py:53, in validate_config(config, config_class)
51 valid_keys = {f.name for f in fields(config_class)}
52 # Check if there are any unknown keys in the config
---> 53 unknown_keys = set(config.keys()) - valid_keys
54 if unknown_keys:
55 raise ValueError(f"Unknown keys in configuration: {unknown_keys}. Valid keys are {valid_keys}")
AttributeError: 'PosixPath' object has no attribute 'keys'
Hmm.. This is strange. Can you provide me a code snippet that I can run which reproduces this error?
it's example from notebooks/02_user_guide/detection_with_yolov5.ipynb
I took all the steps from notebook and stopped there:
from soccertrack import detection_model
from soccertrack.utils import get_git_root
# let's load the first frame of the video
frame = cam.get_frame(0)
root = get_git_root()
# define the path to the model checkpoint
model_name = "yolov5"
model_repo = root / "external" / "yolov5"
model_ckpt = root / "models" / "yolov5" / "yolov5x_last.pt"
# define the player detection model
player_det_model = detection_model.load(model_name, model_repo, model_ckpt)
player_det_model.model.conf = 0.5
player_det_model.model.size = 1920
# define the ball detection model
ball_det_model = detection_model.load(model_name, model_repo, model_ckpt.parent / 'yolov5s_ball_best.pt')
ball_det_model.model.conf = 0.5
ball_det_model.model.size = 1920
player_det_result = player_det_model(frame, augment=True)
ball_det_result = ball_det_model(frame, augment=True)
# change the results for the ball to have the class id 1
ball_det_pred = ball_det_result.pred
# ball_det_pred[:, 5] = 1
det_result = player_det_result.merge(ball_det_pred)
print(det_result.to_df()) # print the results as a dataframe
det_result.show(width=5) # show the bounding boxes on the frame
any news or tips how to solve this errors?
Sorry for the delay in response.
The API for using detection models has changed and the documentation has not been updated yet. We have made changes to the API to make it more flexible for using other detection models such as yolov8 and potentially YoloX in the future.
Please use the following code to achieve the same functionality as the code in the notebook:
from soccertrack import detection_model
from soccertrack.utils import get_git_root
# Load the first frame of the video
frame = cam.get_frame(0)
model_config = {'ckpt': 'yolov5x.pt'}
inference_config = {'augment': True, 'size': 1280}
det_model = detection_model.load('yolov5x', model_config, inference_config=inference_config)
det_result = det_model(frame)[0]
print(det_result.to_df()) # Print the results as a dataframe
det_result.show(width=5) # Show the bounding boxes on the frame
If you have any further questions, please feel free to ask.
I have updated the notebook to reflect the changes. https://github.com/AtomScott/SoccerTrack/blob/develop/notebooks/02_user_guide/detection_with_yolov5.ipynb
thanks, everything works fine, now.
Great! This issue will be closed as it appears to be resolved. However, if you have any further questions or need additional assistance, please don't hesitate to ask.
Search before asking
SoccerTrack Component
Detection
Bug
When I importing the package from soccertrack import detection_model Run....
Output:
how to fix this? thank you in advance
Environment
No response
Minimal Reproducible Example
No response
Additional
No response
Are you willing to submit a PR?