mr2along commited on
Commit
76de74c
verified
1 Parent(s): fd0f253

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -14
app.py CHANGED
@@ -3,25 +3,25 @@ import subprocess
3
  import shutil
4
  import os
5
  from datetime import datetime
6
- #from huggingface_hub import login, upload_file
7
 
8
  # --- Config ---
9
- #REPO_ID = "mr2along/Picture"
10
- #HF_TOKEN = os.environ.get("MAGIC")
11
  #print(HF_TOKEN)
12
  #if not HF_TOKEN:
13
  # print("鈿狅笍 Kh么ng t矛m th岷 bi岷縩 m么i tr瓢峄漬g '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=[]
@@ -34,7 +34,7 @@ def run_scripts(target, source):
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(
 
3
  import shutil
4
  import os
5
  from datetime import datetime
6
+ from huggingface_hub import login, upload_file
7
 
8
  # --- Config ---
9
+ REPO_ID = "mr2along/Picture"
10
+ HF_TOKEN = os.environ.get("MAGIC")
11
  #print(HF_TOKEN)
12
  #if not HF_TOKEN:
13
  # print("鈿狅笍 Kh么ng t矛m th岷 bi岷縩 m么i tr瓢峄漬g '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=[]
 
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(