Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -434,7 +434,7 @@ def get_models():
|
|
434 |
return models
|
435 |
|
436 |
# 一時ファイルを使用する1フレーム推論実行関数
|
437 |
-
@spaces.GPU(duration=
|
438 |
@torch.no_grad()
|
439 |
def worker_with_temp_files(
|
440 |
image_mask_dict,
|
@@ -958,7 +958,7 @@ if not IN_HF_SPACE or 'spaces' not in globals():
|
|
958 |
|
959 |
# GPU環境用process_with_temp関数の内容を完成
|
960 |
if IN_HF_SPACE and 'spaces' in globals():
|
961 |
-
@spaces.GPU(duration=
|
962 |
def process_with_temp(image_mask_dict, lora_multiplier=1.0):
|
963 |
"""一時ファイルを使用する処理メインフロー(GPU対応)"""
|
964 |
global stream
|
@@ -1094,7 +1094,7 @@ if IN_HF_SPACE and 'spaces' in globals():
|
|
1094 |
|
1095 |
# GPU環境用end_process関数の内容を完成
|
1096 |
if IN_HF_SPACE and 'spaces' in globals():
|
1097 |
-
@spaces.GPU(duration=
|
1098 |
def end_process_with_cleanup():
|
1099 |
"""処理を中止し、一時ファイルを削除する(GPU対応)"""
|
1100 |
global stream
|
@@ -1113,10 +1113,10 @@ if IN_HF_SPACE and 'spaces' in globals():
|
|
1113 |
print(f"一時ディレクトリの削除中にエラーが発生しました: {e}")
|
1114 |
|
1115 |
|
1116 |
-
# Hugging Face Space環境のためにモデルを事前に初期化(@spaces.GPU(duration=
|
1117 |
if IN_HF_SPACE and 'spaces' in globals():
|
1118 |
# スタートアップ時のモデル初期化関数
|
1119 |
-
@spaces.GPU(duration=
|
1120 |
def initialize_models_on_startup():
|
1121 |
"""スタートアップ時にモデルを初期化する(GPU対応)"""
|
1122 |
try:
|
@@ -1188,7 +1188,7 @@ with block:
|
|
1188 |
|
1189 |
# HF Spaces環境用の起動関数
|
1190 |
if IN_HF_SPACE and 'spaces' in globals():
|
1191 |
-
@spaces.GPU(duration=
|
1192 |
def launch_server():
|
1193 |
"""Spaces環境でサーバーを起動(GPU対応)"""
|
1194 |
# Hugging Face Space環境ではサーバーを共有しない
|
|
|
434 |
return models
|
435 |
|
436 |
# 一時ファイルを使用する1フレーム推論実行関数
|
437 |
+
@spaces.GPU(duration=300)
|
438 |
@torch.no_grad()
|
439 |
def worker_with_temp_files(
|
440 |
image_mask_dict,
|
|
|
958 |
|
959 |
# GPU環境用process_with_temp関数の内容を完成
|
960 |
if IN_HF_SPACE and 'spaces' in globals():
|
961 |
+
@spaces.GPU(duration=300)
|
962 |
def process_with_temp(image_mask_dict, lora_multiplier=1.0):
|
963 |
"""一時ファイルを使用する処理メインフロー(GPU対応)"""
|
964 |
global stream
|
|
|
1094 |
|
1095 |
# GPU環境用end_process関数の内容を完成
|
1096 |
if IN_HF_SPACE and 'spaces' in globals():
|
1097 |
+
@spaces.GPU(duration=300)
|
1098 |
def end_process_with_cleanup():
|
1099 |
"""処理を中止し、一時ファイルを削除する(GPU対応)"""
|
1100 |
global stream
|
|
|
1113 |
print(f"一時ディレクトリの削除中にエラーが発生しました: {e}")
|
1114 |
|
1115 |
|
1116 |
+
# Hugging Face Space環境のためにモデルを事前に初期化(@spaces.GPU(duration=300)デコレータ追加)
|
1117 |
if IN_HF_SPACE and 'spaces' in globals():
|
1118 |
# スタートアップ時のモデル初期化関数
|
1119 |
+
@spaces.GPU(duration=300) # HF Spaces環境でGPUを使用するための必須デコレータ
|
1120 |
def initialize_models_on_startup():
|
1121 |
"""スタートアップ時にモデルを初期化する(GPU対応)"""
|
1122 |
try:
|
|
|
1188 |
|
1189 |
# HF Spaces環境用の起動関数
|
1190 |
if IN_HF_SPACE and 'spaces' in globals():
|
1191 |
+
@spaces.GPU(duration=300) # HF Spaces環境でGPUを使用するための必須デコレータ
|
1192 |
def launch_server():
|
1193 |
"""Spaces環境でサーバーを起動(GPU対応)"""
|
1194 |
# Hugging Face Space環境ではサーバーを共有しない
|