Cogito2012 / UString

[ACM MM 2020] Uncertainty-based Traffic Accident Anticipation
MIT License
67 stars 19 forks source link

final_model_ccd.pth and Pre-trained UString Models: #9

Closed ZhangJianshu3 closed 3 years ago

ZhangJianshu3 commented 3 years ago

Thanks for your work!

I have cloned your code and download Pre-trained UString Models (final_model_crash_vgg16.pth). When setting the file 'final_model_crash_vgg16.pth' as the model file and placed it at demo/final_model_ccd.pth run the run_demo.sh, the curve and the possibility in the output video file is random (for the same video, the output of each run is inconsistent) and is not consistent with the given example.

Did I use the wrong model? The Pre-trained UString Model (final_model_crash_vgg16.pth) is not the final model and it should not be used identify in demo?

Cogito2012 commented 3 years ago

@ZhangJianshu3 Thank you for the interest in this repo!

For the demo script, you may fix the random seed for both pytorch and numpy to get reproducible results. For example, calling the following function at the beginning of the python code by set_random_seed()

def set_random_seed(seed):
    torch.manual_seed(seed)
    torch.cuda.manual_seed(seed)
    torch.cuda.manual_seed_all(seed)  # if you are using multi-GPU.
    np.random.seed(seed)  # Numpy module.
    torch.backends.cudnn.benchmark = True
    torch.backends.cudnn.deterministic = True

By the way, your used model should be correct but I do not well remember if it is exactly that model that generates the demo showing in the README.

ZhangJianshu3 commented 3 years ago

After setting the number of seed I get the reproducible results and different seeds correspond to different results. How can I get the same result as in demo (000821_vis.gif)? In other words, what is the value of seed?

Cogito2012 commented 3 years ago

@ZhangJianshu3 Sorry for the late reply. At the time when the demo in README was created, random seed was unfortunately not set.

redeyezt commented 2 years ago

Hi, I'm having the same problem.(no checkpoint found at 'demo/final_model_ccd.pth'), I place the files(final_model_crash_vgg16.pth) in the (demo) folder.The result is as follows.

Run feature extraction...
mmlab-mmlab-mmlab-mmlab-mmlab
OUT-OUT-OUT-OUT-mmlab-mmlab
Saved in: demo/000821_feature.npz
Run accident inference...
py37-py37-py37-py37-py37
=> no checkpoint found at 'demo/final_model_ccd.pth'
OUT-OUT-OUT-OUT-py37-py37
Saved in: demo/000821_result.npz
Run result visualization...
py37-py37-py37-py37-py37

When setting up the random seed, I put the following code in demo.py

seed = 123
np.random.seed(seed)
torch.manual_seed(seed)
ROOT_PATH = os.path.dirname(__file__)

or

def set_random_seed(seed):
    torch.manual_seed(seed)
    torch.cuda.manual_seed(seed)
    torch.cuda.manual_seed_all(seed)  # if you are using multi-GPU.
    np.random.seed(seed)  # Numpy module.
    torch.backends.cudnn.benchmark = True
    torch.backends.cudnn.deterministic = True

The results from both operations are not as good as you described in readme.md. Can you tell me how to get the ideal prediction curve. Thank you for your work and sharing.