Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,7 @@ import shutil
|
|
11 |
import httpx
|
12 |
import time
|
13 |
import base64
|
|
|
14 |
|
15 |
# 로깅 설정
|
16 |
logging.basicConfig(level=logging.INFO)
|
@@ -78,6 +79,7 @@ def load_gallery():
|
|
78 |
return []
|
79 |
|
80 |
|
|
|
81 |
def respond(image, prompt, steps, cfg_scale, eta, fs, seed, video_length):
|
82 |
logging.info(f"Received prompt: {prompt}, steps: {steps}, cfg_scale: {cfg_scale}, "
|
83 |
f"eta: {eta}, fs: {fs}, seed: {seed}, video_length: {video_length}")
|
@@ -85,28 +87,27 @@ def respond(image, prompt, steps, cfg_scale, eta, fs, seed, video_length):
|
|
85 |
try:
|
86 |
# 이미지 파일 처리
|
87 |
if image is not None:
|
88 |
-
|
89 |
-
image_data = base64.b64encode(f.read()).decode('utf-8')
|
90 |
else:
|
91 |
-
|
92 |
|
93 |
# 비디오 생성 요청
|
94 |
result = api_client.predict(
|
95 |
-
|
96 |
-
prompt,
|
97 |
-
steps,
|
98 |
-
cfg_scale,
|
99 |
-
eta,
|
100 |
-
fs,
|
101 |
-
seed,
|
102 |
-
video_length,
|
103 |
api_name="/infer"
|
104 |
)
|
105 |
logging.info("API response received: %s", result)
|
106 |
|
107 |
# 결과 확인 및 처리
|
108 |
-
if isinstance(result,
|
109 |
-
saved_video_path = save_to_gallery(result, prompt)
|
110 |
return saved_video_path
|
111 |
else:
|
112 |
raise ValueError("Unexpected API response format")
|
|
|
11 |
import httpx
|
12 |
import time
|
13 |
import base64
|
14 |
+
from gradio_client import Client, handle_file
|
15 |
|
16 |
# 로깅 설정
|
17 |
logging.basicConfig(level=logging.INFO)
|
|
|
79 |
return []
|
80 |
|
81 |
|
82 |
+
|
83 |
def respond(image, prompt, steps, cfg_scale, eta, fs, seed, video_length):
|
84 |
logging.info(f"Received prompt: {prompt}, steps: {steps}, cfg_scale: {cfg_scale}, "
|
85 |
f"eta: {eta}, fs: {fs}, seed: {seed}, video_length: {video_length}")
|
|
|
87 |
try:
|
88 |
# 이미지 파일 처리
|
89 |
if image is not None:
|
90 |
+
image_file = handle_file(image)
|
|
|
91 |
else:
|
92 |
+
image_file = None
|
93 |
|
94 |
# 비디오 생성 요청
|
95 |
result = api_client.predict(
|
96 |
+
image=image_file,
|
97 |
+
prompt=prompt,
|
98 |
+
steps=steps,
|
99 |
+
cfg_scale=cfg_scale,
|
100 |
+
eta=eta,
|
101 |
+
fs=fs,
|
102 |
+
seed=seed,
|
103 |
+
video_length=video_length,
|
104 |
api_name="/infer"
|
105 |
)
|
106 |
logging.info("API response received: %s", result)
|
107 |
|
108 |
# 결과 확인 및 처리
|
109 |
+
if isinstance(result, dict) and 'video' in result:
|
110 |
+
saved_video_path = save_to_gallery(result['video'], prompt)
|
111 |
return saved_video_path
|
112 |
else:
|
113 |
raise ValueError("Unexpected API response format")
|