Thiago Hersan
commited on
Commit
•
4e3cfa9
1
Parent(s):
744c484
adds auth_token as env var
Browse files
app.ipynb
CHANGED
@@ -8,6 +8,7 @@
|
|
8 |
"source": [
|
9 |
"import gradio as gr\n",
|
10 |
"import numpy as np\n",
|
|
|
11 |
"from PIL import Image as PImage\n",
|
12 |
"from torchvision import transforms as T\n",
|
13 |
"from transformers import MaskFormerForInstanceSegmentation, MaskFormerImageProcessor"
|
@@ -40,7 +41,8 @@
|
|
40 |
" reduce_labels=False\n",
|
41 |
")\n",
|
42 |
"\n",
|
43 |
-
"
|
|
|
44 |
"\n",
|
45 |
"test_transform = T.Compose([\n",
|
46 |
" T.ToTensor(),\n",
|
|
|
8 |
"source": [
|
9 |
"import gradio as gr\n",
|
10 |
"import numpy as np\n",
|
11 |
+
"from os import environ\n",
|
12 |
"from PIL import Image as PImage\n",
|
13 |
"from torchvision import transforms as T\n",
|
14 |
"from transformers import MaskFormerForInstanceSegmentation, MaskFormerImageProcessor"
|
|
|
41 |
" reduce_labels=False\n",
|
42 |
")\n",
|
43 |
"\n",
|
44 |
+
"hf_token = environ.get('HFTOKEN') or True\n",
|
45 |
+
"model = MaskFormerForInstanceSegmentation.from_pretrained(model_id, use_auth_token=hf_token)\n",
|
46 |
"\n",
|
47 |
"test_transform = T.Compose([\n",
|
48 |
" T.ToTensor(),\n",
|
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
|
|
3 |
from torchvision import transforms as T
|
4 |
from transformers import MaskFormerForInstanceSegmentation, MaskFormerImageProcessor
|
5 |
|
@@ -23,7 +24,8 @@ preprocessor = MaskFormerImageProcessor(
|
|
23 |
reduce_labels=False
|
24 |
)
|
25 |
|
26 |
-
|
|
|
27 |
|
28 |
test_transform = T.Compose([
|
29 |
T.ToTensor(),
|
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
+
from os import environ
|
4 |
from torchvision import transforms as T
|
5 |
from transformers import MaskFormerForInstanceSegmentation, MaskFormerImageProcessor
|
6 |
|
|
|
24 |
reduce_labels=False
|
25 |
)
|
26 |
|
27 |
+
hf_token = environ.get('HFTOKEN')
|
28 |
+
model = MaskFormerForInstanceSegmentation.from_pretrained(model_id, use_auth_token=hf_token)
|
29 |
|
30 |
test_transform = T.Compose([
|
31 |
T.ToTensor(),
|