Browse Source

Fix negative notebook

pull/40/head
pharmapsychotic 2 years ago
parent
commit
2fe5a84b28
  1. 12
      clip_interrogator.ipynb

12
clip_interrogator.ipynb

@ -45,7 +45,7 @@
" install_cmds = [\n", " install_cmds = [\n",
" ['pip', 'install', 'gradio'],\n", " ['pip', 'install', 'gradio'],\n",
" ['pip', 'install', 'open_clip_torch'],\n", " ['pip', 'install', 'open_clip_torch'],\n",
" ['pip', 'install', '-e', 'git+https://github.com/pharmapsychotic/BLIP.git@lib#egg=blip'],\n", " ['pip', 'install', 'git+https://github.com/pharmapsychotic/BLIP.git'],\n",
" ['git', 'clone', '-b', 'negative', 'https://github.com/pharmapsychotic/clip-interrogator.git']\n", " ['git', 'clone', '-b', 'negative', 'https://github.com/pharmapsychotic/clip-interrogator.git']\n",
" ]\n", " ]\n",
" for cmd in install_cmds:\n", " for cmd in install_cmds:\n",
@ -75,6 +75,8 @@
"for url in CACHE_URLS:\n", "for url in CACHE_URLS:\n",
" print(subprocess.run(['wget', url, '-P', 'cache'], stdout=subprocess.PIPE).stdout.decode('utf-8'))\n", " print(subprocess.run(['wget', url, '-P', 'cache'], stdout=subprocess.PIPE).stdout.decode('utf-8'))\n",
"\n", "\n",
"import sys\n",
"sys.path.append('clip-interrogator')\n",
"\n", "\n",
"import gradio as gr\n", "import gradio as gr\n",
"from clip_interrogator import Config, Interrogator\n", "from clip_interrogator import Config, Interrogator\n",
@ -102,7 +104,7 @@
" flaves = flaves + ci.negative.labels\n", " flaves = flaves + ci.negative.labels\n",
" prompt = ci.chain(image_features, flaves, max_count=32, reverse=True, desc=\"Negative chain\")\n", " prompt = ci.chain(image_features, flaves, max_count=32, reverse=True, desc=\"Negative chain\")\n",
" sim = ci.similarity(ci.image_to_features(image), prompt)\n", " sim = ci.similarity(ci.image_to_features(image), prompt)\n",
" return prompt, sim\n" " return prompt, sim"
] ]
}, },
{ {
@ -259,7 +261,7 @@
"provenance": [] "provenance": []
}, },
"kernelspec": { "kernelspec": {
"display_name": "Python 3.7.15 ('py37')", "display_name": "ci",
"language": "python", "language": "python",
"name": "python3" "name": "python3"
}, },
@ -273,12 +275,12 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.7.15 (default, Nov 24 2022, 18:44:54) [MSC v.1916 64 bit (AMD64)]" "version": "3.8.10 (default, Nov 14 2022, 12:59:47) \n[GCC 9.4.0]"
}, },
"orig_nbformat": 4, "orig_nbformat": 4,
"vscode": { "vscode": {
"interpreter": { "interpreter": {
"hash": "1f51d5616d3bc2b87a82685314c5be1ec9a49b6e0cb1f707bfa2acb6c45f3e5f" "hash": "90daa5087f97972f35e673cab20894a33c1e0ca77092ccdd163e60b53596983a"
} }
} }
}, },

Loading…
Cancel
Save