Spaces:
Sleeping
Sleeping
File size: 7,430 Bytes
1089e3f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"# TIRAL 2: GPT-J\n",
"\n",
"Link: https://huggingface.co/course/chapter9/5?fw=pt\n",
"\n",
"Lastest Update Date: Apr. 2, 2023\n",
"\n",
"## Loading models from the Hugging Face Hub"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"# IMPORTS\n",
"\n",
"import gradio as gr"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/zhilinzhou/anaconda3/lib/python3.10/site-packages/gradio/interface.py:93: UserWarning: gr.Intrerface.load() will be deprecated. Use gr.load() instead.\n",
" warnings.warn(\"gr.Intrerface.load() will be deprecated. Use gr.load() instead.\")\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Fetching model from: https://huggingface.co/EleutherAI/gpt-j-6B\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/zhilinzhou/anaconda3/lib/python3.10/site-packages/gradio/deprecation.py:40: UserWarning: `enable_queue` is deprecated in `Interface()`, please use it within `launch()` instead.\n",
" warnings.warn(value)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Running on local URL: http://127.0.0.1:7861\n",
"\n",
"To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7861/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": []
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"title = \"GPT-J-6B\"\n",
"description = \"Gradio Demo for GPT-J 6B, a transformer model trained using Ben Wang's Mesh Transformer JAX. 'GPT-J' refers to the class of model, while '6B' represents the number of trainable parameters. To use it, simply add your text, or click one of the examples to load them. Read more at the links below.\"\n",
"article = \"<p style='text-align: center'><a href='https://github.com/kingoflolz/mesh-transformer-jax' target='_blank'>GPT-J-6B: A 6 Billion Parameter Autoregressive Language Model</a></p>\"\n",
"examples = [\n",
" [\"The tower is 324 metres (1,063 ft) tall,\"],\n",
" [\"The Moon's orbit around Earth has\"],\n",
" [\"The smooth Borealis basin in the Northern Hemisphere covers 40%\"],\n",
"]\n",
"gr.load(\n",
" \"huggingface/EleutherAI/gpt-j-6B\",\n",
" inputs=gr.Textbox(lines=5, label=\"Input Text\"),\n",
" title=title,\n",
" description=description,\n",
" article=article,\n",
" examples=examples,\n",
" enable_queue=True,\n",
").launch()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"## Loading from Hugging Face Spaces\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/zhilinzhou/anaconda3/lib/python3.10/site-packages/gradio/interface.py:93: UserWarning: gr.Intrerface.load() will be deprecated. Use gr.load() instead.\n",
" warnings.warn(\"gr.Intrerface.load() will be deprecated. Use gr.load() instead.\")\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Fetching Space from: https://huggingface.co/spaces/abidlabs/remove-bg\n",
"Loaded as API: https://abidlabs-remove-bg.hf.space ✔\n",
"Running on local URL: http://127.0.0.1:7862\n",
"\n",
"To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7862/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": []
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gr.Interface.load(\"spaces/abidlabs/remove-bg\").launch()\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/zhilinzhou/anaconda3/lib/python3.10/site-packages/gradio/interface.py:93: UserWarning: gr.Intrerface.load() will be deprecated. Use gr.load() instead.\n",
" warnings.warn(\"gr.Intrerface.load() will be deprecated. Use gr.load() instead.\")\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Fetching Space from: https://huggingface.co/spaces/abidlabs/remove-bg\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/zhilinzhou/anaconda3/lib/python3.10/site-packages/gradio/external.py:445: UserWarning: You cannot override parameters for this Space by passing in kwargs. Instead, please load the Space as a function and use it to create a Blocks or Interface locally. You may find this Guide helpful: https://gradio.app/using_blocks_like_functions/\n",
" warnings.warn(\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loaded as API: https://abidlabs-remove-bg.hf.space ✔\n",
"Running on local URL: http://127.0.0.1:7863\n",
"\n",
"To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7863/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": []
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gr.Interface.load(\n",
" \"spaces/abidlabs/remove-bg\", inputs=\"webcam\", title=\"Remove your webcam background!\"\n",
").launch()\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "base",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
|