Spaces:
Running
Running
seawolf2357
commited on
Commit
โข
9e25e78
1
Parent(s):
e2ad603
Update app.py
Browse files
app.py
CHANGED
@@ -1,36 +1,33 @@
|
|
1 |
-
import
|
2 |
-
import gradio as gr
|
3 |
import os
|
4 |
-
import tempfile
|
5 |
-
from pathlib import Path
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
file.write(input_file)
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
size = (width, height)
|
16 |
-
|
17 |
-
video_filename = os.path.join('/mnt/data', 'output_video.mp4')
|
18 |
-
|
19 |
-
out = cv2.VideoWriter(video_filename, cv2.VideoWriter_fourcc(*'mp4v'), fps, size)
|
20 |
-
out.write(frame)
|
21 |
-
out.release()
|
22 |
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
-
|
|
|
|
|
|
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
description="Upload an image to create a video."
|
34 |
-
)
|
35 |
|
36 |
-
|
|
|
|
|
|
1 |
+
from huggingface_hub import HfApi, HfFolder, Repository
|
|
|
2 |
import os
|
|
|
|
|
3 |
|
4 |
+
# Hugging Face ๊ณ์ ์ผ๋ก ๋ก๊ทธ์ธ (์ฒ์ ์คํ ์ ๋ก๊ทธ์ธ ์ ๋ณด ์
๋ ฅ)
|
5 |
+
hf_username = "seawolf2357" # ์ฌ๊ธฐ์ Hugging Face ์ฌ์ฉ์ ์ด๋ฆ ์
๋ ฅ
|
6 |
+
repo_name = "video" # ์ฌ๊ธฐ์ ๋ฆฌํฌ์งํ ๋ฆฌ ์ด๋ฆ ์
๋ ฅ (์์ผ๋ฉด ์์ฑ๋จ)
|
7 |
+
file_path = "your_file_path.mp4" # ์
๋ก๋ํ ํ์ผ์ ๊ฒฝ๋ก
|
|
|
8 |
|
9 |
+
# API ์ด๊ธฐํ
|
10 |
+
api = HfApi()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
# ๋ฆฌํฌ์งํ ๋ฆฌ ๊ฒฝ๋ก ์ค์
|
13 |
+
repo_url = api.create_repo(
|
14 |
+
name=repo_name,
|
15 |
+
token=HfFolder.get_token(),
|
16 |
+
private=False, # True๋ก ์ค์ ํ๋ฉด ๋น๊ณต๊ฐ ๋ฆฌํฌ์งํ ๋ฆฌ ์์ฑ
|
17 |
+
exist_ok=True # ์ด๋ฏธ ์กด์ฌํ๋ ๊ฒฝ์ฐ ์ค๋ฅ ๋ฐฉ์ง
|
18 |
+
)
|
19 |
|
20 |
+
# ๋ก์ปฌ์์ ๋ฆฌํฌ์งํ ๋ฆฌ ํด๋ก
|
21 |
+
repo_local_path = "./" + repo_name
|
22 |
+
repo = Repository(repo_local_path, clone_from=repo_url)
|
23 |
+
os.chdir(repo_local_path)
|
24 |
|
25 |
+
# ํ์ผ ์
๋ก๋
|
26 |
+
repo.lfs_track("*.mp4") # MP4 ํ์ผ LFS ์ถ์
|
27 |
+
repo.git_add(file_path) # ํ์ผ ์ถ๊ฐ
|
28 |
+
repo.git_commit("Upload MP4 file") # ์ปค๋ฐ ๋ฉ์์ง
|
29 |
+
repo.git_push() # ๋ณ๊ฒฝ ์ฌํญ ํธ์
|
|
|
|
|
30 |
|
31 |
+
# ์
๋ก๋๋ ํ์ผ์ URL ๋ฐํ
|
32 |
+
uploaded_file_url = f"https://huggingface.co/{hf_username}/{repo_name}/blob/main/{os.path.basename(file_path)}"
|
33 |
+
print("Uploaded file URL:", uploaded_file_url)
|