Spaces:
Runtime error
Runtime error
- scripts/generate_prompt.py +0 -5
- scripts/process_utils.py +2 -3
scripts/generate_prompt.py
CHANGED
@@ -2,15 +2,11 @@ import csv
|
|
2 |
import os
|
3 |
import cv2
|
4 |
import numpy as np
|
5 |
-
import tensorflow as tf
|
6 |
from tensorflow.keras.layers import TFSMLayer
|
7 |
from huggingface_hub import hf_hub_download
|
8 |
|
9 |
import spaces
|
10 |
|
11 |
-
# TensorFlowがGPUを使用しないように設定
|
12 |
-
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
|
13 |
-
|
14 |
# 画像サイズの設定
|
15 |
IMAGE_SIZE = 448
|
16 |
|
@@ -40,7 +36,6 @@ def download_model_files(repo_id, model_dir, sub_dir, files, sub_files):
|
|
40 |
for file in sub_files:
|
41 |
hf_hub_download(repo_id, file, subfolder=sub_dir, cache_dir=os.path.join(model_dir, sub_dir), force_download=True, force_filename=file)
|
42 |
|
43 |
-
@spaces.GPU
|
44 |
def load_wd14_tagger_model():
|
45 |
"""WD14タグ付けモデルをロード"""
|
46 |
model_dir = "wd14_tagger_model"
|
|
|
2 |
import os
|
3 |
import cv2
|
4 |
import numpy as np
|
|
|
5 |
from tensorflow.keras.layers import TFSMLayer
|
6 |
from huggingface_hub import hf_hub_download
|
7 |
|
8 |
import spaces
|
9 |
|
|
|
|
|
|
|
10 |
# 画像サイズの設定
|
11 |
IMAGE_SIZE = 448
|
12 |
|
|
|
36 |
for file in sub_files:
|
37 |
hf_hub_download(repo_id, file, subfolder=sub_dir, cache_dir=os.path.join(model_dir, sub_dir), force_download=True, force_filename=file)
|
38 |
|
|
|
39 |
def load_wd14_tagger_model():
|
40 |
"""WD14タグ付けモデルをロード"""
|
41 |
model_dir = "wd14_tagger_model"
|
scripts/process_utils.py
CHANGED
@@ -43,7 +43,7 @@ def initialize(_use_local=False, use_gpu=False, use_dotenv=False):
|
|
43 |
print(f"\nDevice: {device}, Local model: {_use_local}\n")
|
44 |
|
45 |
init_model(use_local)
|
46 |
-
model = load_wd14_tagger_model()
|
47 |
sotai_gen_pipe = initialize_sotai_model()
|
48 |
refine_gen_pipe = initialize_refine_model()
|
49 |
|
@@ -154,8 +154,7 @@ def initialize_refine_model():
|
|
154 |
def get_wd_tags(images: list) -> list:
|
155 |
global model
|
156 |
if model is None:
|
157 |
-
|
158 |
-
# initialize()
|
159 |
preprocessed_images = [wd14_preprocess_image(img) for img in images]
|
160 |
preprocessed_images = np.array(preprocessed_images)
|
161 |
return generate_tags(preprocessed_images, os.environ["wd_model_name"], model)
|
|
|
43 |
print(f"\nDevice: {device}, Local model: {_use_local}\n")
|
44 |
|
45 |
init_model(use_local)
|
46 |
+
# model = load_wd14_tagger_model()
|
47 |
sotai_gen_pipe = initialize_sotai_model()
|
48 |
refine_gen_pipe = initialize_refine_model()
|
49 |
|
|
|
154 |
def get_wd_tags(images: list) -> list:
|
155 |
global model
|
156 |
if model is None:
|
157 |
+
model = load_wd14_tagger_model()
|
|
|
158 |
preprocessed_images = [wd14_preprocess_image(img) for img in images]
|
159 |
preprocessed_images = np.array(preprocessed_images)
|
160 |
return generate_tags(preprocessed_images, os.environ["wd_model_name"], model)
|