Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -20,7 +20,7 @@ from funcs import (
|
|
20 |
get_latent_z,
|
21 |
save_videos
|
22 |
)
|
23 |
-
from transformers import pipeline
|
24 |
from diffusers import StableDiffusionXLPipeline
|
25 |
|
26 |
print("PyTorch version:", torch.__version__)
|
@@ -29,6 +29,19 @@ print("CUDA available:", torch.cuda.is_available())
|
|
29 |
def is_tensor(x):
|
30 |
return torch.is_tensor(x)
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
os.environ['KERAS_BACKEND'] = 'pytorch'
|
33 |
|
34 |
def download_model():
|
@@ -56,17 +69,7 @@ model.eval()
|
|
56 |
model = torch.nn.DataParallel(model)
|
57 |
model = model.cuda()
|
58 |
|
59 |
-
# 번역 모델 로드
|
60 |
-
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en", device=0 if torch.cuda.is_available() else -1, framework="pt")
|
61 |
|
62 |
-
# 이미지 생성 모델 로드
|
63 |
-
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
64 |
-
pipe = StableDiffusionXLPipeline.from_pretrained(
|
65 |
-
"SG161222/RealVisXL_V4.0",
|
66 |
-
torch_dtype=torch.float32,
|
67 |
-
use_safetensors=True,
|
68 |
-
add_watermarker=False
|
69 |
-
).to(device)
|
70 |
|
71 |
def generate_image(prompt: str):
|
72 |
# 한글 입력 감지 및 번역
|
@@ -158,12 +161,12 @@ def infer(prompt, steps=50, cfg_scale=7.5, eta=1.0, fs=3, seed=123, frames=64):
|
|
158 |
torch.cuda.empty_cache()
|
159 |
|
160 |
return video_path
|
|
|
161 |
except Exception as e:
|
162 |
print(f"Error occurred: {e}")
|
163 |
return None
|
164 |
finally:
|
165 |
-
torch.cuda.empty_cache()
|
166 |
-
|
167 |
|
168 |
i2v_examples = [
|
169 |
['우주인 복장으로 기타를 치는 남자', 30, 7.5, 1.0, 6, 123, 64],
|
|
|
20 |
get_latent_z,
|
21 |
save_videos
|
22 |
)
|
23 |
+
from transformers import pipeline, AutoTokenizer, AutoModelForSeq2SeqLT
|
24 |
from diffusers import StableDiffusionXLPipeline
|
25 |
|
26 |
print("PyTorch version:", torch.__version__)
|
|
|
29 |
def is_tensor(x):
|
30 |
return torch.is_tensor(x)
|
31 |
|
32 |
+
# 번역 모델 로드 (PyTorch 버전 사용)
|
33 |
+
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en", device=0 if torch.cuda.is_available() else -1, framework="pt")
|
34 |
+
|
35 |
+
# 이미지 생성 모델 로드
|
36 |
+
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
37 |
+
pipe = StableDiffusionXLPipeline.from_pretrained(
|
38 |
+
"SG161222/RealVisXL_V4.0",
|
39 |
+
torch_dtype=torch.float32,
|
40 |
+
use_safetensors=True,
|
41 |
+
add_watermarker=False
|
42 |
+
).to(device)
|
43 |
+
|
44 |
+
|
45 |
os.environ['KERAS_BACKEND'] = 'pytorch'
|
46 |
|
47 |
def download_model():
|
|
|
69 |
model = torch.nn.DataParallel(model)
|
70 |
model = model.cuda()
|
71 |
|
|
|
|
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
def generate_image(prompt: str):
|
75 |
# 한글 입력 감지 및 번역
|
|
|
161 |
torch.cuda.empty_cache()
|
162 |
|
163 |
return video_path
|
164 |
+
|
165 |
except Exception as e:
|
166 |
print(f"Error occurred: {e}")
|
167 |
return None
|
168 |
finally:
|
169 |
+
torch.cuda.empty_cache()
|
|
|
170 |
|
171 |
i2v_examples = [
|
172 |
['우주인 복장으로 기타를 치는 남자', 30, 7.5, 1.0, 6, 123, 64],
|