meg HF staff commited on
Commit
7efa952
·
verified ·
1 Parent(s): 518f1c9

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +52 -0
app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import os
3
+ import gradio as gr
4
+
5
+ import wandb
6
+ from huggingface_hub import HfApi
7
+
8
+ TOKEN = os.environ.get("DATACOMP_TOKEN")
9
+ API = HfApi(token=TOKEN)
10
+ wandb_api_key = os.environ.get('wandb_api_key')
11
+ wandb.login(key=wandb_api_key)
12
+
13
+ random_num = f"60.0"
14
+ subset = f"frac-1over8"
15
+ experiment_name = f"ImageNetTraining60.0-frac-1over8"
16
+ experiment_repo = f"datacomp/ImageNetTraining60.0-frac-1over8"
17
+
18
+ def start_train():
19
+ os.system("echo '#### pwd'")
20
+ os.system("pwd")
21
+ os.system("echo '#### ls'")
22
+ os.system("ls")
23
+ # Create a place to put the output.
24
+ os.system("echo 'Creating results output repository in case it does not exist yet...'")
25
+ try:
26
+ API.create_repo(repo_id=f"datacomp/ImageNetTraining60.0-frac-1over8", repo_type="dataset",)
27
+ os.system(f"echo 'Created results output repository datacomp/ImageNetTraining60.0-frac-1over8'")
28
+ except:
29
+ os.system("echo 'Already there; skipping.'")
30
+ pass
31
+ os.system("echo 'Beginning processing.'")
32
+ # Handles CUDA OOM errors.
33
+ os.system(f"export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True")
34
+ os.system("echo 'Okay, trying training.'")
35
+ os.system(f"cd pytorch-image-models; ./train.sh 4 --dataset hfds/datacomp/imagenet-1k-random-60.0-frac-1over8 --log-wandb --wandb-project ImageNetTraining60.0-frac-1over8 --experiment ImageNetTraining60.0-frac-1over8 --model seresnet34 --sched cosine --epochs 150 --warmup-epochs 5 --lr 0.4 --reprob 0.5 --remode pixel --batch-size 256 --amp -j 4")
36
+ os.system("echo 'Done'.")
37
+ os.system("ls")
38
+ # Upload output to repository
39
+ os.system("echo 'trying to upload...'")
40
+ API.upload_folder(folder_path="/app", repo_id=f"datacomp/ImageNetTraining60.0-frac-1over8", repo_type="dataset",)
41
+ API.pause_space(experiment_repo)
42
+
43
+ def run():
44
+ with gr.Blocks() as app:
45
+ gr.Markdown(f"Randomization: 60.0")
46
+ gr.Markdown(f"Subset: frac-1over8")
47
+ start = gr.Button("Start")
48
+ start.click(start_train)
49
+ app.launch(server_name="0.0.0.0", server_port=7860)
50
+
51
+ if __name__ == '__main__':
52
+ run()