soiz1 commited on
Commit
190ec4f
·
verified ·
1 Parent(s): 602e236

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +61 -0
app.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import json
3
+ import shutil
4
+ import gradio as gr
5
+ from huggingface_hub import snapshot_download
6
+
7
+ def process_and_zip_folders(huggingface_dataset_url, output_dir):
8
+ # データセットをダウンロード
9
+ dataset_path = snapshot_download(huggingface_dataset_url)
10
+
11
+ # 処理対象のフォルダ
12
+ folders = [
13
+ "hololive-jp", "hololive-id", "hololive-en", "holostars",
14
+ "hololive-cn", "nijisanji", "nijisanji-en", "vshojo",
15
+ "phaseconnect", "indies", "other"
16
+ ]
17
+
18
+ zip_files = []
19
+
20
+ for folder in folders:
21
+ folder_path = os.path.join(dataset_path, folder)
22
+ if not os.path.exists(folder_path):
23
+ continue
24
+
25
+ # JSONファイルを探す
26
+ json_path = os.path.join(folder_path, "model_info.json")
27
+ if not os.path.exists(json_path):
28
+ continue
29
+
30
+ # JSONを読み込む
31
+ with open(json_path, "r", encoding="utf-8") as f:
32
+ model_info = json.load(f)
33
+
34
+ # ZIPに圧縮
35
+ zip_name = f"{folder}.zip"
36
+ zip_path = os.path.join(output_dir, zip_name)
37
+ shutil.make_archive(base_name=zip_path.replace('.zip', ''), format="zip", root_dir=folder_path)
38
+ zip_files.append(zip_path)
39
+
40
+ return zip_files
41
+
42
+ def gradio_interface():
43
+ def start_process(huggingface_url, output_directory):
44
+ zip_files = process_and_zip_folders(huggingface_url, output_directory)
45
+ return zip_files
46
+
47
+ interface = gr.Interface(
48
+ fn=start_process,
49
+ inputs=[
50
+ gr.Textbox(label="Hugging Face Dataset URL", placeholder="https://huggingface.co/datasets/soiz1/rvc-models"),
51
+ gr.Textbox(label="Output Directory", placeholder="/path/to/output")
52
+ ],
53
+ outputs=gr.File(label="Generated ZIP Files"),
54
+ title="Folder to ZIP Generator",
55
+ description="指定されたフォルダを取得してZIPに圧縮します。"
56
+ )
57
+
58
+ interface.launch()
59
+
60
+ if __name__ == "__main__":
61
+ gradio_interface()