File size: 2,508 Bytes
cb40f1e
 
86c24cb
 
cb40f1e
 
86c24cb
cb40f1e
 
86c24cb
cb40f1e
 
86c24cb
 
2a62959
86c24cb
2a62959
86c24cb
2a62959
86c24cb
2a62959
 
 
 
 
 
86c24cb
2a62959
86c24cb
2a62959
 
 
 
 
86c24cb
2a62959
 
 
 
 
 
 
 
 
 
 
86c24cb
2a62959
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
title: MidasMap
emoji: 🔬
colorFrom: gray
colorTo: blue
sdk: gradio
sdk_version: 4.44.1
app_file: app.py
pinned: false
license: mit
---

# MidasMap Space

Gradio demo for **[MidasMap](https://github.com/AnikS22/MidasMap)** (immunogold particle detection in TEM synapse images).

## Deploy from your laptop

From the **MidasMap** repo root:

```bash
export HF_TOKEN=hf_...   # write token
# Recommended: do not upload the ~100MB checkpoint into the Space (avoids LFS / size issues).
export HF_SPACE_SKIP_CHECKPOINT=1
./scripts/upload_hf_space.sh
```

If **`upload_hf_space.sh` fails**, use **git + LFS** instead (often more reliable):

```bash
brew install git-lfs && git lfs install   # once
export HF_TOKEN=hf_...
./scripts/push_hf_space_git.sh
```

Full options: [docs/DEPLOY.md](../docs/DEPLOY.md) in the main repo.

Create the Space once if needed (Gradio SDK required for auto-create):

```bash
huggingface-cli repo create MidasMap --type space --space_sdk gradio -y
```

Weights are loaded from the **model** repo `AnikS22/MidasMap` at `checkpoints/final/final_model.pth` when the file is not in the Space. Override with Space secrets / env: `MIDASMAP_HF_WEIGHTS_REPO`, `MIDASMAP_HF_WEIGHTS_FILE`.

To bundle the checkpoint in the Space instead (larger upload):

```bash
export HF_SPACE_SKIP_CHECKPOINT=0
./scripts/upload_hf_space.sh
```

## Troubleshooting uploads

| Symptom | What to do |
|--------|----------------|
| **401 / not logged in** | `export HF_TOKEN=hf_...` with a token that has **write** access, or `huggingface-cli login`. |
| **LFS / authorization / upload stuck** | Use `HF_SPACE_SKIP_CHECKPOINT=1` so only code uploads; ensure the **model** repo (not the Space) contains `checkpoints/final/final_model.pth`. |
| **Space does not exist** | Create it in the HF web UI (**New Space****Gradio**) or run `huggingface-cli repo create ... --type space --space_sdk gradio`. |
| **“No space_sdk provided”** | The Space repo must be created as **Gradio** (or pass `--space_sdk gradio` when using `repo create`). |
| **Model not found on Space** | First boot downloads weights from the Hub; public repos need no token. Private model repo: add `HF_TOKEN` as a Space **secret** (read). |
| **Still failing** | Try `pip install hf_transfer` and `export HF_HUB_ENABLE_HF_TRANSFER=1` before upload. Or use **git** + **git lfs** clone of the Space, copy files, commit, push. |

## Vercel embed

`https://yoursite.vercel.app/?embed=https://huggingface.co/spaces/YOUR_USER/YOUR_SPACE`