Forums

Kernel Died Working with Jupyter and Segment anything model

We are trying to use Segment Anything Model in a Jupyter notebook in this plataform.

With previous testing on local jupyter notebook and Google Colab online that worked but here in PA don't work anyboth codes.

pip install git+https://github.com/facebookresearch/segment-anything.git
------------------------------
import torch
from segment_anything import sam_model_registry, SamPredictor, SamAutomaticMaskGenerator
-----------------------------
 DEVICE = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')
 MODEL_TYPE = "vit_h"

----- previously we just install the github and import the neccesary for the project. ----

 sam = sam_model_registry[MODEL_TYPE](checkpoint="sam_vit_h_4b8939.pth").to(device=DEVICE)

And in this line causes the problem and the Kernel Died. We just trying alot of variations in the code for this error, but we can't reach a correct answer or if we are missing something. Help us please.

Did you try to run it in the console?

Thanks for the comment. No, we didn't try it in the console, can you give us a reference/tutorial about how to do that? we are new about using notebooks and AI

You can start a new console from your Consoles page and run the code there.

Thanks Can you provide an example for the command to run a ipynb file?

Take a look ta that thread https://www.pythonanywhere.com/forums/topic/14094/