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

Missing example to save and reload ObjectDetection model #183

Open
rebotnix opened this issue Jan 10, 2020 · 3 comments
Open

Missing example to save and reload ObjectDetection model #183

rebotnix opened this issue Jan 10, 2020 · 3 comments
Assignees
Milestone

Comments

@rebotnix
Copy link

@rebotnix rebotnix commented Jan 10, 2020

I installed the requirements and the demo for object detection works fine.

Is there a way how I can save and reload a trained model after the task.fit call?

detector = task.fit(dataset_train,
num_trials=2,
epochs=epochs,
lr=ag.Categorical(5e-4, 1e-4),
ngpus_per_trial=1,
time_limits=time_limits)

I also tried to set a resume to False to initialize the task to predict directly, but training is always started from the beginng.

?

@zhanghang1989

This comment has been minimized.

Copy link
Collaborator

@zhanghang1989 zhanghang1989 commented Jan 10, 2020

That's good question. We should improve the documentation.

When calling task.fit(...), the training will start. If resume=True, it will start will the existing search history.

If you would like to save/load the trained model, please use detector.save('detector.ag') and detector= Detector .load('detector.ag')

@rebotnix

This comment has been minimized.

Copy link
Author

@rebotnix rebotnix commented Jan 11, 2020

Thanks @zhanghang1989 for your response. It seems that save method in detector is not implemented yet?

I tried to call the save method after training, but receive an error.

# start training
detector = task.fit(dataset_train,
                    num_trials=2,
                    epochs=epochs,
                    lr=ag.Categorical(5e-4, 1e-4),
                    ngpus_per_trial=1,
                    time_limits=time_limits)

# save model
detector.save("motorbike.ag")

Error message:
/usr/lib/python3/dist-packages/apport/report.py:13: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import fnmatch, glob, traceback, errno, sys, atexit, locale, imp
Traceback (most recent call last):
File "demo_eval.py", line 24, in
detector.save("motorbike.ag")
File "/home/user/.local/lib/python3.7/site-packages/autogluon/task/object_detection/detector.py", line 154, in save
raise NotImplemented
TypeError: exceptions must derive from BaseException

I take a look at the original detector source of the object detector class and load and save are not implemented yet.

    def load(cls, checkpoint):
        raise NotImplemented
    
    def save(self, checkpoint):
        raise NotImplemented

@zhanghang1989

This comment has been minimized.

Copy link
Collaborator

@zhanghang1989 zhanghang1989 commented Jan 12, 2020

Thanks for the feedback @rebotnix . We will prioritize the implementation of save/load method.

@zhanghang1989 zhanghang1989 added this to the 0.1 Release milestone Jan 12, 2020
@jwmueller jwmueller changed the title Missing example to save and reload a trained model Missing example to save and reload ObjectDetection model Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.