Update app.py
Browse files
app.py
CHANGED
|
@@ -11,7 +11,6 @@ import torch
|
|
| 11 |
import gradio as gr
|
| 12 |
import spaces
|
| 13 |
|
| 14 |
-
from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor
|
| 15 |
|
| 16 |
# 尝试导入 qwen_vl_utils,若失败则提供降级实现(返回空的图像/视频输入)
|
| 17 |
try:
|
|
@@ -27,7 +26,9 @@ def replace_single_quotes(text):
|
|
| 27 |
return replaced_text
|
| 28 |
|
| 29 |
class PromptEnhancerV2:
|
|
|
|
| 30 |
def __init__(self, models_root_path, device_map="auto", torch_dtype="bfloat16"):#auto
|
|
|
|
| 31 |
if not logging.getLogger(__name__).handlers:
|
| 32 |
logging.basicConfig(level=logging.INFO)
|
| 33 |
self.logger = logging.getLogger(__name__)
|
|
@@ -48,7 +49,8 @@ class PromptEnhancerV2:
|
|
| 48 |
self.processor = AutoProcessor.from_pretrained(models_root_path)
|
| 49 |
|
| 50 |
# @torch.inference_mode()
|
| 51 |
-
@spaces.GPU
|
|
|
|
| 52 |
def predict(
|
| 53 |
self,
|
| 54 |
prompt_cot,
|
|
|
|
| 11 |
import gradio as gr
|
| 12 |
import spaces
|
| 13 |
|
|
|
|
| 14 |
|
| 15 |
# 尝试导入 qwen_vl_utils,若失败则提供降级实现(返回空的图像/视频输入)
|
| 16 |
try:
|
|
|
|
| 26 |
return replaced_text
|
| 27 |
|
| 28 |
class PromptEnhancerV2:
|
| 29 |
+
@zero.gpu
|
| 30 |
def __init__(self, models_root_path, device_map="auto", torch_dtype="bfloat16"):#auto
|
| 31 |
+
from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor
|
| 32 |
if not logging.getLogger(__name__).handlers:
|
| 33 |
logging.basicConfig(level=logging.INFO)
|
| 34 |
self.logger = logging.getLogger(__name__)
|
|
|
|
| 49 |
self.processor = AutoProcessor.from_pretrained(models_root_path)
|
| 50 |
|
| 51 |
# @torch.inference_mode()
|
| 52 |
+
# @spaces.GPU
|
| 53 |
+
@zero.gpu
|
| 54 |
def predict(
|
| 55 |
self,
|
| 56 |
prompt_cot,
|