Spaces:
Runtime error
Runtime error
jhj0517
commited on
Commit
·
ba52666
1
Parent(s):
31d94d2
Add colab notebook
Browse files- notebooks/sam2_playground.ipynb +117 -0
notebooks/sam2_playground.ipynb
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "markdown",
|
| 5 |
+
"source": [
|
| 6 |
+
"---\n",
|
| 7 |
+
"\n",
|
| 8 |
+
"📌 **This notebook has been updated [here](https://github.com/jhj0517/sam2-playground)!**\n",
|
| 9 |
+
"\n",
|
| 10 |
+
"🖋 **Author**: [jhj0517](https://github.com/jhj0517/sam2-playground/blob/master/notebooks/sam2-playground.ipynb)\n",
|
| 11 |
+
"\n",
|
| 12 |
+
"😎 **Support the Project**:\n",
|
| 13 |
+
"\n",
|
| 14 |
+
"If you find this project useful, please consider supporting it:\n",
|
| 15 |
+
"\n",
|
| 16 |
+
"<a href=\"https://ko-fi.com/jhj0517\" target=\"_blank\">\n",
|
| 17 |
+
" <img src=\"https://storage.ko-fi.com/cdn/kofi2.png?v=3\" alt=\"Buy Me a Coffee at ko-fi.com\" height=\"36\">\n",
|
| 18 |
+
"</a>\n",
|
| 19 |
+
"\n",
|
| 20 |
+
"---"
|
| 21 |
+
],
|
| 22 |
+
"metadata": {
|
| 23 |
+
"id": "doKhBBXIfS21"
|
| 24 |
+
}
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"cell_type": "code",
|
| 28 |
+
"source": [
|
| 29 |
+
"#@title #(Optional) Check GPU\n",
|
| 30 |
+
"#@markdown Some models may not function correctly on a CPU runtime.\n",
|
| 31 |
+
"\n",
|
| 32 |
+
"#@markdown so you should check your GPU setup before run.\n",
|
| 33 |
+
"!nvidia-smi"
|
| 34 |
+
],
|
| 35 |
+
"metadata": {
|
| 36 |
+
"id": "23yZvUlagEsx",
|
| 37 |
+
"cellView": "form"
|
| 38 |
+
},
|
| 39 |
+
"execution_count": null,
|
| 40 |
+
"outputs": []
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"cell_type": "code",
|
| 44 |
+
"execution_count": null,
|
| 45 |
+
"metadata": {
|
| 46 |
+
"id": "kNbSbsctxahq"
|
| 47 |
+
},
|
| 48 |
+
"outputs": [],
|
| 49 |
+
"source": [
|
| 50 |
+
"#@title #Installation\n",
|
| 51 |
+
"#@markdown This cell will install dependencies for Whisper-WebUI!\n",
|
| 52 |
+
"!git clone https://github.com/jhj0517/sam2-playground.git\n",
|
| 53 |
+
"%cd sam2-playground\n",
|
| 54 |
+
"!pip install gradio\n",
|
| 55 |
+
"!pip install git+https://github.com/jhj0517/gradio-image-prompter.git\n",
|
| 56 |
+
"!pip install git+https://github.com/jhj0517/segment-anything-2.git\n",
|
| 57 |
+
"!pip install git+https://github.com/jhj0517/forked-pytoshop.git\n",
|
| 58 |
+
"!pip install packbits\n",
|
| 59 |
+
"!pip install hydra-core\n",
|
| 60 |
+
"!pip install -U numpy==1.26.4"
|
| 61 |
+
]
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"cell_type": "code",
|
| 65 |
+
"source": [
|
| 66 |
+
"#@title # (Optional) Configure arguments\n",
|
| 67 |
+
"#@markdown This section is used to configure some command line arguments.\n",
|
| 68 |
+
"\n",
|
| 69 |
+
"#@markdown You can simply ignore this section and the default values will be used.\n",
|
| 70 |
+
"THEME = '' #@param {type: \"string\"}\n",
|
| 71 |
+
"\n",
|
| 72 |
+
"arguments = \"\"\n",
|
| 73 |
+
"if THEME:\n",
|
| 74 |
+
" arguments += f\" --theme {THEME}\""
|
| 75 |
+
],
|
| 76 |
+
"metadata": {
|
| 77 |
+
"id": "Qosz9BFlGui3",
|
| 78 |
+
"cellView": "form"
|
| 79 |
+
},
|
| 80 |
+
"execution_count": null,
|
| 81 |
+
"outputs": []
|
| 82 |
+
},
|
| 83 |
+
{
|
| 84 |
+
"cell_type": "code",
|
| 85 |
+
"execution_count": null,
|
| 86 |
+
"metadata": {
|
| 87 |
+
"id": "PQroYRRZzQiN",
|
| 88 |
+
"cellView": "form"
|
| 89 |
+
},
|
| 90 |
+
"outputs": [],
|
| 91 |
+
"source": [
|
| 92 |
+
"#@title #Run\n",
|
| 93 |
+
"#@markdown Once the installation is complete, you can use public URL that is displayed.\n",
|
| 94 |
+
"if 'arguments' in locals():\n",
|
| 95 |
+
" !python app.py --share {arguments}\n",
|
| 96 |
+
"else:\n",
|
| 97 |
+
" !python app.py --share"
|
| 98 |
+
]
|
| 99 |
+
}
|
| 100 |
+
],
|
| 101 |
+
"metadata": {
|
| 102 |
+
"colab": {
|
| 103 |
+
"provenance": [],
|
| 104 |
+
"gpuType": "T4"
|
| 105 |
+
},
|
| 106 |
+
"kernelspec": {
|
| 107 |
+
"display_name": "Python 3",
|
| 108 |
+
"name": "python3"
|
| 109 |
+
},
|
| 110 |
+
"language_info": {
|
| 111 |
+
"name": "python"
|
| 112 |
+
},
|
| 113 |
+
"accelerator": "GPU"
|
| 114 |
+
},
|
| 115 |
+
"nbformat": 4,
|
| 116 |
+
"nbformat_minor": 0
|
| 117 |
+
}
|