Upload app.py with huggingface_hub
Browse files
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"80.0"
|
| 14 |
+
subset = f"frac-1over32"
|
| 15 |
+
experiment_name = f"ImageNetTraining80.0-frac-1over32"
|
| 16 |
+
experiment_repo = f"datacomp/ImageNetTraining80.0-frac-1over32"
|
| 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/ImageNetTraining80.0-frac-1over32", repo_type="dataset",)
|
| 27 |
+
os.system(f"echo 'Created results output repository datacomp/ImageNetTraining80.0-frac-1over32'")
|
| 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-80.0-frac-1over32 --log-wandb --wandb-project ImageNetTraining80.0-frac-1over32 --experiment ImageNetTraining80.0-frac-1over32 --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/ImageNetTraining80.0-frac-1over32", repo_type="dataset",)
|
| 41 |
+
API.pause_space(experiment_repo)
|
| 42 |
+
|
| 43 |
+
def run():
|
| 44 |
+
with gr.Blocks() as app:
|
| 45 |
+
gr.Markdown(f"Randomization: 80.0")
|
| 46 |
+
gr.Markdown(f"Subset: frac-1over32")
|
| 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()
|