Spaces:
Running
Running
Rename
Browse files
app.py
CHANGED
@@ -19,7 +19,7 @@ TITLE = 'KichangKim/DeepDanbooru'
|
|
19 |
DESCRIPTION = 'This is an unofficial demo for https://github.com/KichangKim/DeepDanbooru.'
|
20 |
ARTICLE = '<center><img src="https://visitor-badge.glitch.me/badge?page_id=hysts.deepdanbooru" alt="visitor badge"/></center>'
|
21 |
|
22 |
-
|
23 |
MODEL_REPO = 'hysts/DeepDanbooru'
|
24 |
MODEL_FILENAME = 'model-resnet_custom_v3.h5'
|
25 |
LABEL_FILENAME = 'tags.txt'
|
@@ -47,7 +47,7 @@ def load_sample_image_paths() -> list[pathlib.Path]:
|
|
47 |
path = huggingface_hub.hf_hub_download(dataset_repo,
|
48 |
'images.tar.gz',
|
49 |
repo_type='dataset',
|
50 |
-
use_auth_token=
|
51 |
with tarfile.open(path) as f:
|
52 |
f.extractall()
|
53 |
return sorted(image_dir.glob('*'))
|
@@ -56,7 +56,7 @@ def load_sample_image_paths() -> list[pathlib.Path]:
|
|
56 |
def load_model() -> tf.keras.Model:
|
57 |
path = huggingface_hub.hf_hub_download(MODEL_REPO,
|
58 |
MODEL_FILENAME,
|
59 |
-
use_auth_token=
|
60 |
model = tf.keras.models.load_model(path)
|
61 |
return model
|
62 |
|
@@ -64,7 +64,7 @@ def load_model() -> tf.keras.Model:
|
|
64 |
def load_labels() -> list[str]:
|
65 |
path = huggingface_hub.hf_hub_download(MODEL_REPO,
|
66 |
LABEL_FILENAME,
|
67 |
-
use_auth_token=
|
68 |
with open(path) as f:
|
69 |
labels = [line.strip() for line in f.readlines()]
|
70 |
return labels
|
|
|
19 |
DESCRIPTION = 'This is an unofficial demo for https://github.com/KichangKim/DeepDanbooru.'
|
20 |
ARTICLE = '<center><img src="https://visitor-badge.glitch.me/badge?page_id=hysts.deepdanbooru" alt="visitor badge"/></center>'
|
21 |
|
22 |
+
HF_TOKEN = os.environ['HF_TOKEN']
|
23 |
MODEL_REPO = 'hysts/DeepDanbooru'
|
24 |
MODEL_FILENAME = 'model-resnet_custom_v3.h5'
|
25 |
LABEL_FILENAME = 'tags.txt'
|
|
|
47 |
path = huggingface_hub.hf_hub_download(dataset_repo,
|
48 |
'images.tar.gz',
|
49 |
repo_type='dataset',
|
50 |
+
use_auth_token=HF_TOKEN)
|
51 |
with tarfile.open(path) as f:
|
52 |
f.extractall()
|
53 |
return sorted(image_dir.glob('*'))
|
|
|
56 |
def load_model() -> tf.keras.Model:
|
57 |
path = huggingface_hub.hf_hub_download(MODEL_REPO,
|
58 |
MODEL_FILENAME,
|
59 |
+
use_auth_token=HF_TOKEN)
|
60 |
model = tf.keras.models.load_model(path)
|
61 |
return model
|
62 |
|
|
|
64 |
def load_labels() -> list[str]:
|
65 |
path = huggingface_hub.hf_hub_download(MODEL_REPO,
|
66 |
LABEL_FILENAME,
|
67 |
+
use_auth_token=HF_TOKEN)
|
68 |
with open(path) as f:
|
69 |
labels = [line.strip() for line in f.readlines()]
|
70 |
return labels
|