Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,8 @@ import os
|
|
| 4 |
import logging
|
| 5 |
import json
|
| 6 |
from datetime import datetime
|
| 7 |
-
|
|
|
|
| 8 |
# 로깅 설정
|
| 9 |
logging.basicConfig(level=logging.INFO)
|
| 10 |
|
|
@@ -18,23 +19,16 @@ GALLERY_JSON = "/home/user/app/gallery.json"
|
|
| 18 |
# 갤러리 디렉토리 생성
|
| 19 |
os.makedirs(GALLERY_DIR, exist_ok=True)
|
| 20 |
|
| 21 |
-
def save_to_gallery(
|
| 22 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 23 |
-
|
| 24 |
-
thumbnail_path = os.path.join(GALLERY_DIR, f"{timestamp}_thumb.jpg")
|
| 25 |
-
|
| 26 |
-
# 비디오 파일 복사
|
| 27 |
-
shutil.copy2(video_path, new_video_path)
|
| 28 |
|
| 29 |
-
#
|
| 30 |
-
|
| 31 |
-
video.save_frame(thumbnail_path, t=0) # 첫 프레임을 썸네일로 저장
|
| 32 |
-
video.close()
|
| 33 |
|
| 34 |
# 갤러리 정보 저장
|
| 35 |
gallery_info = {
|
| 36 |
-
"
|
| 37 |
-
"thumbnail": thumbnail_path,
|
| 38 |
"prompt": prompt,
|
| 39 |
"timestamp": timestamp
|
| 40 |
}
|
|
@@ -50,13 +44,13 @@ def save_to_gallery(video_path, prompt):
|
|
| 50 |
with open(GALLERY_JSON, "w") as f:
|
| 51 |
json.dump(gallery, f, indent=2)
|
| 52 |
|
| 53 |
-
return
|
| 54 |
|
| 55 |
def load_gallery():
|
| 56 |
if os.path.exists(GALLERY_JSON):
|
| 57 |
with open(GALLERY_JSON, "r") as f:
|
| 58 |
gallery = json.load(f)
|
| 59 |
-
return [(item["
|
| 60 |
return []
|
| 61 |
|
| 62 |
def respond(message, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
|
|
|
|
| 4 |
import logging
|
| 5 |
import json
|
| 6 |
from datetime import datetime
|
| 7 |
+
import shutil
|
| 8 |
+
from moviepy.editor import VideoFileClip
|
| 9 |
# 로깅 설정
|
| 10 |
logging.basicConfig(level=logging.INFO)
|
| 11 |
|
|
|
|
| 19 |
# 갤러리 디렉토리 생성
|
| 20 |
os.makedirs(GALLERY_DIR, exist_ok=True)
|
| 21 |
|
| 22 |
+
def save_to_gallery(image_path, prompt):
|
| 23 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 24 |
+
new_image_path = os.path.join(GALLERY_DIR, f"{timestamp}.png")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
+
# 이미지 파일 복사
|
| 27 |
+
shutil.copy2(image_path, new_image_path)
|
|
|
|
|
|
|
| 28 |
|
| 29 |
# 갤러리 정보 저장
|
| 30 |
gallery_info = {
|
| 31 |
+
"image": new_image_path,
|
|
|
|
| 32 |
"prompt": prompt,
|
| 33 |
"timestamp": timestamp
|
| 34 |
}
|
|
|
|
| 44 |
with open(GALLERY_JSON, "w") as f:
|
| 45 |
json.dump(gallery, f, indent=2)
|
| 46 |
|
| 47 |
+
return new_image_path
|
| 48 |
|
| 49 |
def load_gallery():
|
| 50 |
if os.path.exists(GALLERY_JSON):
|
| 51 |
with open(GALLERY_JSON, "r") as f:
|
| 52 |
gallery = json.load(f)
|
| 53 |
+
return [(item["image"], item["prompt"]) for item in reversed(gallery)]
|
| 54 |
return []
|
| 55 |
|
| 56 |
def respond(message, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
|