Upload folder using huggingface_hub
Browse filesFiles changed (2)
35 unmodified lines36373839404142236 unmodified lines27928028128228328428537 unmodified lines32332432532632732832995 unmodified lines42542642742842943035 unmodified linesRUNS_DIR = os.path.join(BASE_DIR, "runs")PREDICTIONS_DIR = os.path.join(BASE_DIR, "predictions")TEMPLATE_DIR = os.path.join(BASE_DIR, "templates")os.makedirs(UPLOAD_DIR, exist_ok=True)os.makedirs(RUNS_DIR, exist_ok=True)os.makedirs(PREDICTIONS_DIR, exist_ok=True)236 unmodified linesspectral_file: UploadFile = File(...),labels_file: UploadFile = File(...),wavenumbers_file: UploadFile = File(...),model_file: UploadFile = File(...),label_mapping_file: Optional[UploadFile] = File(None),epochs: int = Form(60),lr: float = Form(1e-4),37 unmodified lines_save_upload(model_file, model_path)if label_mapping_file is not None:_save_upload(label_mapping_file, label_mapping_path)config = TrainConfig(epochs=epochs,lr=lr,95 unmodified lines):if _is_blank_upload(spectral_file):raise HTTPException(status_code=400, detail="Please choose a spectral file before running prediction.")if _is_blank_upload(model_file):raise HTTPException(status_code=400, detail="Please choose a saved model (.pth) before running prediction.")35 unmodified lines36373839404142236 unmodified lines27928028128228328428537 unmodified lines32332432532632732832995 unmodified lines42542642742842943043135 unmodified linesRUNS_DIR = os.path.join(BASE_DIR, "runs")PREDICTIONS_DIR = os.path.join(BASE_DIR, "predictions")TEMPLATE_DIR = os.path.join(BASE_DIR, "templates")DEFAULT_MODEL_PATH = os.path.join(BASE_DIR, "weights", "Fine_tuned.pth")os.makedirs(UPLOAD_DIR, exist_ok=True)os.makedirs(RUNS_DIR, exist_ok=True)os.makedirs(PREDICTIONS_DIR, exist_ok=True)236 unmodified linesspectral_file: UploadFile = File(...),labels_file: UploadFile = File(...),wavenumbers_file: UploadFile = File(...),model_file: UploadFile = File(None),label_mapping_file: Optional[UploadFile] = File(None),epochs: int = Form(60),lr: float = Form(1e-4),37 unmodified lines_save_upload(model_file, model_path)if label_mapping_file is not None:_save_upload(label_mapping_file, label_mapping_path)config = TrainConfig(epochs=epochs,lr=lr,95 unmodified lines):if _is_blank_upload(spectral_file):raise HTTPException(status_code=400, detail="Please choose a spectral file before running prediction.")if _is_blank_upload(model_file):raise HTTPException(status_code=400, detail="Please choose a saved model (.pth) before running prediction.")
239 unmodified lines240241242243244245246247248249250147 unmodified lines398399400401402403404239 unmodified lines</div></div><div class="file-field"><label>Pretrained Model (.pth)</label><div class="file-control"><button type="button" data-file-target="model_file">Choose file</button><span class="file-name" data-file-name="model_file">No file selected</span><input type="file" id="model_file" name="model_file" accept=".pth" required></div></div></div>147 unmodified linesconst originalLabel = submitButton ? submitButton.textContent : '';if (submitButton) {submitButton.disabled = true;submitButton.textContent = 'Starting...';}try {239 unmodified lines240241242243244245246247248249250251252253147 unmodified lines401402403404405406407239 unmodified lines</div></div><div class="file-field"><label>Pretrained Model (.pth) <span style="font-weight: normal; color: var(--muted);">- Optional</span></label><div class="file-control"><button type="button" data-file-target="model_file">Choose file</button><span class="file-name" data-file-name="model_file">No file selected</span><input type="file" id="model_file" name="model_file" accept=".pth"></div><div class="helper-note">💡 Leave empty to automatically use the built-in <strong>GEMS Foundation Model (~300MB)</strong>. Only upload if you want to resume training from your own checkpoint.</div></div></div>147 unmodified linesconst originalLabel = submitButton ? submitButton.textContent : '';if (submitButton) {submitButton.disabled = true;submitButton.textContent = 'Uploading data & Initializing...';}try {
webserver/app.py+4-3
webserver/templates/index.html+6-3