Update app.py
Browse files
app.py
CHANGED
@@ -13,18 +13,16 @@ if not HF_TOKEN:
|
|
13 |
print("⚠️ Không tìm thấy biến môi trường 'MAGIC'")
|
14 |
login(HF_TOKEN)
|
15 |
# --- Upload function ---
|
16 |
-
def
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
return f"❌ Lỗi upload: {str(e)}"
|
27 |
-
|
28 |
def run_scripts(target, source):
|
29 |
outputfile=[]
|
30 |
for target_file in target :
|
@@ -36,6 +34,7 @@ def run_scripts(target, source):
|
|
36 |
subprocess.run(cmd1)
|
37 |
outputfile.append(output_path1)
|
38 |
print(output_path1)
|
|
|
39 |
return outputfile
|
40 |
|
41 |
iface = gr.Interface(
|
|
|
13 |
print("⚠️ Không tìm thấy biến môi trường 'MAGIC'")
|
14 |
login(HF_TOKEN)
|
15 |
# --- Upload function ---
|
16 |
+
def upload_to_hf(filepath):
|
17 |
+
filename = os.path.basename(filepath)
|
18 |
+
upload_file(
|
19 |
+
path_or_fileobj=filepath,
|
20 |
+
path_in_repo=filename,
|
21 |
+
repo_id=REPO_ID,
|
22 |
+
repo_type="dataset"
|
23 |
+
)
|
24 |
+
return f"https://huggingface.co/datasets/{REPO_ID}/blob/main/{filename}"
|
25 |
+
|
|
|
|
|
26 |
def run_scripts(target, source):
|
27 |
outputfile=[]
|
28 |
for target_file in target :
|
|
|
34 |
subprocess.run(cmd1)
|
35 |
outputfile.append(output_path1)
|
36 |
print(output_path1)
|
37 |
+
upload_to_hf(output_path1)
|
38 |
return outputfile
|
39 |
|
40 |
iface = gr.Interface(
|