Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- Dockerfile +7 -11
- README.md +2 -4
- app.py +3 -2
- scripts/publish_space.py +42 -15
Dockerfile
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
-
FROM python:3.
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 6 |
-
|
| 7 |
rm -rf /var/lib/apt/lists/*
|
| 8 |
|
| 9 |
COPY requirements.txt .
|
|
@@ -13,16 +13,12 @@ COPY . .
|
|
| 13 |
|
| 14 |
RUN mkdir -p data results/plots
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
RUN python scripts/
|
| 18 |
|
| 19 |
-
# Pre-generate all plots so Gradio loads instantly
|
| 20 |
-
RUN python scripts/generate_plots.py
|
| 21 |
-
|
| 22 |
-
EXPOSE 8000
|
| 23 |
EXPOSE 7860
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
|
| 28 |
-
CMD ["
|
|
|
|
| 1 |
+
FROM python:3.11-slim
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 6 |
+
build-essential curl git && \
|
| 7 |
rm -rf /var/lib/apt/lists/*
|
| 8 |
|
| 9 |
COPY requirements.txt .
|
|
|
|
| 13 |
|
| 14 |
RUN mkdir -p data results/plots
|
| 15 |
|
| 16 |
+
# Pre-generate all plots so Gradio loads instantly (falls back silently on failure)
|
| 17 |
+
RUN python scripts/generate_plots.py || echo "Plot pre-generation skipped"
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
EXPOSE 7860
|
| 20 |
|
| 21 |
+
ENV GRADIO_SERVER_NAME=0.0.0.0
|
| 22 |
+
ENV GRADIO_SERVER_PORT=7860
|
| 23 |
|
| 24 |
+
CMD ["python", "app.py"]
|
README.md
CHANGED
|
@@ -3,9 +3,7 @@ title: ECHO ULTIMATE
|
|
| 3 |
emoji: 🧠
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: purple
|
| 6 |
-
sdk:
|
| 7 |
-
sdk_version: 4.44.0
|
| 8 |
-
app_file: app.py
|
| 9 |
pinned: true
|
| 10 |
license: apache-2.0
|
| 11 |
---
|
|
@@ -42,7 +40,7 @@ pairing every answer with a calibrated probability estimate.
|
|
| 42 |
|
| 43 |
## EchoBench Dataset
|
| 44 |
|
| 45 |
-
The 7-domain benchmark
|
| 46 |
|
| 47 |
| Domain | Source |
|
| 48 |
|--------|--------|
|
|
|
|
| 3 |
emoji: 🧠
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: purple
|
| 6 |
+
sdk: docker
|
|
|
|
|
|
|
| 7 |
pinned: true
|
| 8 |
license: apache-2.0
|
| 9 |
---
|
|
|
|
| 40 |
|
| 41 |
## EchoBench Dataset
|
| 42 |
|
| 43 |
+
The 7-domain benchmark: [Vikaspandey582003/echobench](https://huggingface.co/datasets/Vikaspandey582003/echobench)
|
| 44 |
|
| 45 |
| Domain | Source |
|
| 46 |
|--------|--------|
|
app.py
CHANGED
|
@@ -2,13 +2,14 @@
|
|
| 2 |
import sys, os
|
| 3 |
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 4 |
|
| 5 |
-
from ui.app import build_app
|
| 6 |
-
|
| 7 |
import gradio as gr
|
|
|
|
| 8 |
|
| 9 |
demo = build_app()
|
| 10 |
demo.queue()
|
| 11 |
demo.launch(
|
|
|
|
|
|
|
| 12 |
theme=gr.themes.Soft(),
|
| 13 |
css=".gradio-container { background: #0d0d18 !important; }",
|
| 14 |
)
|
|
|
|
| 2 |
import sys, os
|
| 3 |
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
| 4 |
|
|
|
|
|
|
|
| 5 |
import gradio as gr
|
| 6 |
+
from ui.app import build_app
|
| 7 |
|
| 8 |
demo = build_app()
|
| 9 |
demo.queue()
|
| 10 |
demo.launch(
|
| 11 |
+
server_name=os.getenv("GRADIO_SERVER_NAME", "0.0.0.0"),
|
| 12 |
+
server_port=int(os.getenv("GRADIO_SERVER_PORT", "7860")),
|
| 13 |
theme=gr.themes.Soft(),
|
| 14 |
css=".gradio-container { background: #0d0d18 !important; }",
|
| 15 |
)
|
scripts/publish_space.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
"""
|
| 2 |
-
Publish ECHO ULTIMATE as a HuggingFace Space (
|
| 3 |
|
| 4 |
Usage:
|
| 5 |
python scripts/publish_space.py --token YOUR_HF_TOKEN
|
|
@@ -21,9 +21,7 @@ title: ECHO ULTIMATE
|
|
| 21 |
emoji: 🧠
|
| 22 |
colorFrom: blue
|
| 23 |
colorTo: purple
|
| 24 |
-
sdk:
|
| 25 |
-
sdk_version: 4.44.0
|
| 26 |
-
app_file: app.py
|
| 27 |
pinned: true
|
| 28 |
license: apache-2.0
|
| 29 |
---
|
|
@@ -60,7 +58,7 @@ pairing every answer with a calibrated probability estimate.
|
|
| 60 |
|
| 61 |
## EchoBench Dataset
|
| 62 |
|
| 63 |
-
The 7-domain benchmark
|
| 64 |
|
| 65 |
| Domain | Source |
|
| 66 |
|--------|--------|
|
|
@@ -85,10 +83,38 @@ The 7-domain benchmark used for training: [Vikaspandey582003/echobench](https://
|
|
| 85 |
```
|
| 86 |
"""
|
| 87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
_IGNORE = {
|
| 89 |
"__pycache__", ".git", ".gitignore", "data", "results",
|
| 90 |
"echo_lora_adapter", "adversarial_questions.json",
|
| 91 |
-
".env", "
|
| 92 |
}
|
| 93 |
|
| 94 |
|
|
@@ -99,8 +125,8 @@ def _should_skip(p: Path) -> bool:
|
|
| 99 |
return p.suffix == ".pyc"
|
| 100 |
|
| 101 |
|
| 102 |
-
def build_space_dir(src: Path, dst: Path
|
| 103 |
-
"""Copy project into dst, inject Space README and requirements."""
|
| 104 |
dst.mkdir(parents=True, exist_ok=True)
|
| 105 |
|
| 106 |
for item in src.rglob("*"):
|
|
@@ -114,10 +140,11 @@ def build_space_dir(src: Path, dst: Path, token: str):
|
|
| 114 |
target.parent.mkdir(parents=True, exist_ok=True)
|
| 115 |
shutil.copy2(item, target)
|
| 116 |
|
| 117 |
-
# Space
|
| 118 |
(dst / "README.md").write_text(_SPACE_README, encoding="utf-8")
|
|
|
|
| 119 |
|
| 120 |
-
# Use lighter
|
| 121 |
space_req = src / "space_requirements.txt"
|
| 122 |
if space_req.exists():
|
| 123 |
shutil.copy2(space_req, dst / "requirements.txt")
|
|
@@ -131,12 +158,12 @@ def publish(repo_id: str, token: str, src: Path):
|
|
| 131 |
|
| 132 |
api = HfApi(token=token)
|
| 133 |
|
| 134 |
-
print(f"Creating Space: {repo_id}")
|
| 135 |
try:
|
| 136 |
api.create_repo(
|
| 137 |
repo_id=repo_id,
|
| 138 |
repo_type="space",
|
| 139 |
-
space_sdk="
|
| 140 |
exist_ok=True,
|
| 141 |
private=False,
|
| 142 |
)
|
|
@@ -145,7 +172,7 @@ def publish(repo_id: str, token: str, src: Path):
|
|
| 145 |
print(f" Note: {exc}")
|
| 146 |
|
| 147 |
with tempfile.TemporaryDirectory() as tmp:
|
| 148 |
-
space_dir = build_space_dir(src, Path(tmp) / "space"
|
| 149 |
|
| 150 |
print("Uploading files to Space…")
|
| 151 |
api.upload_folder(
|
|
@@ -157,7 +184,7 @@ def publish(repo_id: str, token: str, src: Path):
|
|
| 157 |
|
| 158 |
url = f"https://huggingface.co/spaces/{repo_id}"
|
| 159 |
print(f"\n✅ Space published: {url}")
|
| 160 |
-
print("
|
| 161 |
return url
|
| 162 |
|
| 163 |
|
|
@@ -166,7 +193,7 @@ def main():
|
|
| 166 |
parser.add_argument("--token", required=True, help="HuggingFace API write token")
|
| 167 |
parser.add_argument("--repo", default="Vikaspandey582003/echo-ultimate",
|
| 168 |
help="Space repo ID (default: Vikaspandey582003/echo-ultimate)")
|
| 169 |
-
args = parser.
|
| 170 |
|
| 171 |
src = Path(__file__).parent.parent.resolve()
|
| 172 |
publish(args.repo, args.token, src)
|
|
|
|
| 1 |
"""
|
| 2 |
+
Publish ECHO ULTIMATE as a HuggingFace Space (Docker SDK, Python 3.11).
|
| 3 |
|
| 4 |
Usage:
|
| 5 |
python scripts/publish_space.py --token YOUR_HF_TOKEN
|
|
|
|
| 21 |
emoji: 🧠
|
| 22 |
colorFrom: blue
|
| 23 |
colorTo: purple
|
| 24 |
+
sdk: docker
|
|
|
|
|
|
|
| 25 |
pinned: true
|
| 26 |
license: apache-2.0
|
| 27 |
---
|
|
|
|
| 58 |
|
| 59 |
## EchoBench Dataset
|
| 60 |
|
| 61 |
+
The 7-domain benchmark: [Vikaspandey582003/echobench](https://huggingface.co/datasets/Vikaspandey582003/echobench)
|
| 62 |
|
| 63 |
| Domain | Source |
|
| 64 |
|--------|--------|
|
|
|
|
| 83 |
```
|
| 84 |
"""
|
| 85 |
|
| 86 |
+
# Dockerfile written into the Space — uses Python 3.11 to avoid audioop/pydub issue
|
| 87 |
+
_SPACE_DOCKERFILE = """\
|
| 88 |
+
FROM python:3.11-slim
|
| 89 |
+
|
| 90 |
+
WORKDIR /app
|
| 91 |
+
|
| 92 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \\
|
| 93 |
+
build-essential curl git && \\
|
| 94 |
+
rm -rf /var/lib/apt/lists/*
|
| 95 |
+
|
| 96 |
+
COPY requirements.txt .
|
| 97 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 98 |
+
|
| 99 |
+
COPY . .
|
| 100 |
+
|
| 101 |
+
RUN mkdir -p data results/plots
|
| 102 |
+
|
| 103 |
+
# Pre-generate all plots so Gradio loads instantly (falls back silently on failure)
|
| 104 |
+
RUN python scripts/generate_plots.py || echo "Plot pre-generation skipped"
|
| 105 |
+
|
| 106 |
+
EXPOSE 7860
|
| 107 |
+
|
| 108 |
+
ENV GRADIO_SERVER_NAME=0.0.0.0
|
| 109 |
+
ENV GRADIO_SERVER_PORT=7860
|
| 110 |
+
|
| 111 |
+
CMD ["python", "app.py"]
|
| 112 |
+
"""
|
| 113 |
+
|
| 114 |
_IGNORE = {
|
| 115 |
"__pycache__", ".git", ".gitignore", "data", "results",
|
| 116 |
"echo_lora_adapter", "adversarial_questions.json",
|
| 117 |
+
".env", "node_modules", ".DS_Store",
|
| 118 |
}
|
| 119 |
|
| 120 |
|
|
|
|
| 125 |
return p.suffix == ".pyc"
|
| 126 |
|
| 127 |
|
| 128 |
+
def build_space_dir(src: Path, dst: Path):
|
| 129 |
+
"""Copy project into dst, inject Space README, Dockerfile, and requirements."""
|
| 130 |
dst.mkdir(parents=True, exist_ok=True)
|
| 131 |
|
| 132 |
for item in src.rglob("*"):
|
|
|
|
| 140 |
target.parent.mkdir(parents=True, exist_ok=True)
|
| 141 |
shutil.copy2(item, target)
|
| 142 |
|
| 143 |
+
# Inject Space-specific files (override project versions)
|
| 144 |
(dst / "README.md").write_text(_SPACE_README, encoding="utf-8")
|
| 145 |
+
(dst / "Dockerfile").write_text(_SPACE_DOCKERFILE, encoding="utf-8")
|
| 146 |
|
| 147 |
+
# Use the lighter space_requirements.txt as requirements.txt
|
| 148 |
space_req = src / "space_requirements.txt"
|
| 149 |
if space_req.exists():
|
| 150 |
shutil.copy2(space_req, dst / "requirements.txt")
|
|
|
|
| 158 |
|
| 159 |
api = HfApi(token=token)
|
| 160 |
|
| 161 |
+
print(f"Creating Space: {repo_id} (Docker SDK)")
|
| 162 |
try:
|
| 163 |
api.create_repo(
|
| 164 |
repo_id=repo_id,
|
| 165 |
repo_type="space",
|
| 166 |
+
space_sdk="docker",
|
| 167 |
exist_ok=True,
|
| 168 |
private=False,
|
| 169 |
)
|
|
|
|
| 172 |
print(f" Note: {exc}")
|
| 173 |
|
| 174 |
with tempfile.TemporaryDirectory() as tmp:
|
| 175 |
+
space_dir = build_space_dir(src, Path(tmp) / "space")
|
| 176 |
|
| 177 |
print("Uploading files to Space…")
|
| 178 |
api.upload_folder(
|
|
|
|
| 184 |
|
| 185 |
url = f"https://huggingface.co/spaces/{repo_id}"
|
| 186 |
print(f"\n✅ Space published: {url}")
|
| 187 |
+
print(" Docker build takes ~5-10 minutes on HuggingFace.")
|
| 188 |
return url
|
| 189 |
|
| 190 |
|
|
|
|
| 193 |
parser.add_argument("--token", required=True, help="HuggingFace API write token")
|
| 194 |
parser.add_argument("--repo", default="Vikaspandey582003/echo-ultimate",
|
| 195 |
help="Space repo ID (default: Vikaspandey582003/echo-ultimate)")
|
| 196 |
+
args, _ = parser.parse_known_args()
|
| 197 |
|
| 198 |
src = Path(__file__).parent.parent.resolve()
|
| 199 |
publish(args.repo, args.token, src)
|