The example code does not work

#1
by electronicbites - opened

The device variable has not been defined

Traceback (most recent call last):
  File "~/objectdetection/experiment5.py", line 7, in <module>
    model = AutoModelForObjectDetection.from_pretrained(ckpt).to(device)
                                                                 ^^^^^^
NameError: name 'device' is not defined

This is not related to my model. you must define variable device.
If you work with cuda,

device = torch.device('cuda') if torch.cuda.is_available() else torch.device('cpu')

Or if you use mps(MacOS) backends,

device = torch.device('mps') if torch.backends.mps.is_available() else torch.device('cpu')

Please print device and check your device.

This comment has been hidden
yainage90 changed discussion status to closed
yainage90 changed discussion status to open
yainage90 changed discussion status to closed

Sign up or log in to comment