fix: restore HF Space Docker config at repo root
Browse files- Dockerfile +18 -0
- README.md +26 -126
- package.json +13 -0
- server.js +64 -0
Dockerfile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM node:22-slim
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
COPY package.json ./
|
| 6 |
+
COPY server.js ./
|
| 7 |
+
COPY studio ./studio
|
| 8 |
+
|
| 9 |
+
WORKDIR /app/studio
|
| 10 |
+
RUN npm ci
|
| 11 |
+
RUN npm run build
|
| 12 |
+
|
| 13 |
+
WORKDIR /app
|
| 14 |
+
RUN npm install --omit=dev
|
| 15 |
+
|
| 16 |
+
ENV PORT=7860
|
| 17 |
+
EXPOSE 7860
|
| 18 |
+
CMD ["node", "server.js"]
|
README.md
CHANGED
|
@@ -1,127 +1,27 @@
|
|
| 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 |
-
### Health
|
| 27 |
-
|
| 28 |
-
```bash
|
| 29 |
-
curl -sS http://127.0.0.1:8190/api/health
|
| 30 |
-
```
|
| 31 |
-
|
| 32 |
-
### LoRA training status
|
| 33 |
-
|
| 34 |
-
```bash
|
| 35 |
-
curl -sS http://127.0.0.1:8190/api/lora-training/status
|
| 36 |
-
curl -sS http://127.0.0.1:8190/api/lora-training/checkpoints
|
| 37 |
-
```
|
| 38 |
-
|
| 39 |
-
### Upload image
|
| 40 |
-
|
| 41 |
-
```bash
|
| 42 |
-
curl -sS -X POST http://127.0.0.1:8190/api/images/upload \
|
| 43 |
-
-F "file=@/path/to/source.png"
|
| 44 |
-
```
|
| 45 |
-
|
| 46 |
-
### Generate image-to-video
|
| 47 |
-
|
| 48 |
-
```bash
|
| 49 |
-
curl -sS -X POST http://127.0.0.1:8190/api/video/generate \
|
| 50 |
-
-H "Content-Type: application/json" \
|
| 51 |
-
-d '{
|
| 52 |
-
"mode": "i2v",
|
| 53 |
-
"image": "source.png",
|
| 54 |
-
"prompt": "cinematic shot, subject walking through neon rain",
|
| 55 |
-
"width": 1280,
|
| 56 |
-
"height": 720,
|
| 57 |
-
"length": 121,
|
| 58 |
-
"fps": 16
|
| 59 |
-
}'
|
| 60 |
-
```
|
| 61 |
-
|
| 62 |
-
### Generate text-to-video
|
| 63 |
-
|
| 64 |
-
```bash
|
| 65 |
-
curl -sS -X POST http://127.0.0.1:8190/api/video/generate \
|
| 66 |
-
-H "Content-Type: application/json" \
|
| 67 |
-
-d '{
|
| 68 |
-
"mode": "t2v",
|
| 69 |
-
"prompt": "cinematic tracking shot through a futuristic city at night",
|
| 70 |
-
"width": 1280,
|
| 71 |
-
"height": 720,
|
| 72 |
-
"length": 121,
|
| 73 |
-
"fps": 16
|
| 74 |
-
}'
|
| 75 |
-
```
|
| 76 |
-
|
| 77 |
-
### Check job
|
| 78 |
-
|
| 79 |
-
```bash
|
| 80 |
-
curl -sS http://127.0.0.1:8190/api/jobs/<prompt_id>
|
| 81 |
-
```
|
| 82 |
-
|
| 83 |
-
## Development
|
| 84 |
-
|
| 85 |
-
```bash
|
| 86 |
-
python3 -m venv .venv
|
| 87 |
-
. .venv/bin/activate
|
| 88 |
-
pip install -r requirements.txt
|
| 89 |
-
PYTHONPATH=app uvicorn nemoflix_amd.api:app --host 0.0.0.0 --port 8190
|
| 90 |
-
```
|
| 91 |
-
|
| 92 |
-
Point the API at a ComfyUI server with:
|
| 93 |
-
|
| 94 |
-
```bash
|
| 95 |
-
export COMFY_URL=http://127.0.0.1:8188
|
| 96 |
-
```
|
| 97 |
-
|
| 98 |
-
## Repo structure
|
| 99 |
-
|
| 100 |
-
```text
|
| 101 |
-
app/nemoflix_amd/ # API service and workflow builders
|
| 102 |
-
scripts/ # optional deployment/setup helpers
|
| 103 |
-
research/ # research notes
|
| 104 |
-
training/ # local training data and outputs, gitignored
|
| 105 |
-
datasets/ # prepared training datasets per run
|
| 106 |
-
output/ # LoRA / model training outputs
|
| 107 |
-
outputs/ # generated outputs, gitignored
|
| 108 |
-
```
|
| 109 |
-
|
| 110 |
-
## Hackathon infrastructure
|
| 111 |
-
|
| 112 |
-
This repo is being built for the AMD Developer Hackathon and currently targets the AMD GPU Developer Cloud environment available through DigitalOcean GPU Droplets.
|
| 113 |
-
|
| 114 |
-
Reference hardware:
|
| 115 |
-
|
| 116 |
-
| Resource | Spec |
|
| 117 |
| --- | --- |
|
| 118 |
-
|
|
| 119 |
-
| VRAM | 192 GB |
|
| 120 |
-
| vCPU | 20 |
|
| 121 |
-
| RAM | 240 GB |
|
| 122 |
-
| Boot disk | 720 GB NVMe SSD |
|
| 123 |
-
| Scratch disk | 5 TB NVMe SSD |
|
| 124 |
-
| GPU software | ROCm 7.2 image |
|
| 125 |
-
| Cost | About $1.99/GPU-hour |
|
| 126 |
-
|
| 127 |
-
The setup scripts assume a fresh Ubuntu ROCm droplet and install ComfyUI plus the Nemoflix API service.
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Nemoflix AMD Gallery
|
| 3 |
+
emoji: 🎬
|
| 4 |
+
colorFrom: red
|
| 5 |
+
colorTo: yellow
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
+
pinned: true
|
| 9 |
+
tags:
|
| 10 |
+
- amd
|
| 11 |
+
- amd-hackathon-2026
|
| 12 |
+
- comfyui
|
| 13 |
+
- video-generation
|
| 14 |
+
- lora
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
# Nemoflix AMD Gallery
|
| 18 |
+
|
| 19 |
+
Hosted Nemoflix Studio UI for the AMD MI300X hackathon demo.
|
| 20 |
+
|
| 21 |
+
This Space serves the real React/Vite Studio UI and proxies API/media requests to the Nemoflix AMD control-plane API.
|
| 22 |
+
|
| 23 |
+
## Required Space secret
|
| 24 |
+
|
| 25 |
+
| Secret | Description |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
| --- | --- |
|
| 27 |
+
| `NEMOFLIX_API_URL` | URL for the Nemoflix API|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "nemoflix-amd-space",
|
| 3 |
+
"private": true,
|
| 4 |
+
"type": "module",
|
| 5 |
+
"scripts": {
|
| 6 |
+
"start": "node server.js"
|
| 7 |
+
},
|
| 8 |
+
"dependencies": {
|
| 9 |
+
"@fastify/static": "latest",
|
| 10 |
+
"fastify": "latest",
|
| 11 |
+
"http-proxy-middleware": "latest"
|
| 12 |
+
}
|
| 13 |
+
}
|
server.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Fastify from "fastify";
|
| 2 |
+
import fastifyStatic from "@fastify/static";
|
| 3 |
+
import { createProxyMiddleware } from "http-proxy-middleware";
|
| 4 |
+
import { fileURLToPath } from "node:url";
|
| 5 |
+
import path from "node:path";
|
| 6 |
+
import fs from "node:fs";
|
| 7 |
+
|
| 8 |
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
| 9 |
+
const port = Number(process.env.PORT || 7860);
|
| 10 |
+
|
| 11 |
+
function normalizeApiUrl(value) {
|
| 12 |
+
let url = String(value || "").trim().replace(/\/+$/, "");
|
| 13 |
+
if (!url) return "";
|
| 14 |
+
if (!/^https?:\/\//i.test(url)) url = `http://${url}`;
|
| 15 |
+
const parsed = new URL(url);
|
| 16 |
+
if (!parsed.port) parsed.port = "8190";
|
| 17 |
+
return parsed.toString().replace(/\/+$/, "");
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
const apiTarget = normalizeApiUrl(process.env.NEMOFLIX_API_URL || process.env.NEMOFLIX_AMD_API_URL || "");
|
| 21 |
+
const app = Fastify({ logger: true });
|
| 22 |
+
const distDir = path.join(__dirname, "studio", "dist");
|
| 23 |
+
|
| 24 |
+
const backendProxy = apiTarget
|
| 25 |
+
? createProxyMiddleware({
|
| 26 |
+
target: apiTarget,
|
| 27 |
+
changeOrigin: true,
|
| 28 |
+
ws: true,
|
| 29 |
+
logLevel: "warn",
|
| 30 |
+
timeout: 30_000,
|
| 31 |
+
proxyTimeout: 30_000,
|
| 32 |
+
on: {
|
| 33 |
+
error: (err, _req, res) => {
|
| 34 |
+
app.log.error({ err, apiTarget }, "backend proxy error");
|
| 35 |
+
if (!res.headersSent) {
|
| 36 |
+
res.writeHead(502, { "Content-Type": "application/json" });
|
| 37 |
+
}
|
| 38 |
+
res.end(JSON.stringify({ detail: `Backend unavailable: ${err.message}` }));
|
| 39 |
+
},
|
| 40 |
+
},
|
| 41 |
+
})
|
| 42 |
+
: null;
|
| 43 |
+
|
| 44 |
+
app.addHook("onRequest", async (request, reply) => {
|
| 45 |
+
if (request.url.startsWith("/api/") || request.url === "/api" || request.url.startsWith("/media/") || request.url === "/media") {
|
| 46 |
+
if (!backendProxy) {
|
| 47 |
+
return reply.code(503).send({ detail: "NEMOFLIX_API_URL is not configured" });
|
| 48 |
+
}
|
| 49 |
+
await new Promise((resolve, reject) => backendProxy(request.raw, reply.raw, (err) => err ? reject(err) : resolve()));
|
| 50 |
+
reply.hijack();
|
| 51 |
+
}
|
| 52 |
+
});
|
| 53 |
+
|
| 54 |
+
app.get("/space-health", async () => ({ ok: true, apiConfigured: Boolean(apiTarget), apiTarget: apiTarget || null }));
|
| 55 |
+
|
| 56 |
+
await app.register(fastifyStatic, { root: distDir, prefix: "/" });
|
| 57 |
+
|
| 58 |
+
app.setNotFoundHandler((request, reply) => {
|
| 59 |
+
const index = path.join(distDir, "index.html");
|
| 60 |
+
if (fs.existsSync(index)) return reply.type("text/html").send(fs.createReadStream(index));
|
| 61 |
+
return reply.code(404).send("Studio build not found");
|
| 62 |
+
});
|
| 63 |
+
|
| 64 |
+
app.listen({ host: "0.0.0.0", port });
|