Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Upload 103 files
Browse files- ui/src/app/api/hf-hub/route.ts +6 -6
- ui/src/app/api/hf-jobs/route.ts +2 -2
- ui/src/paths.ts +7 -4
ui/src/app/api/hf-hub/route.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
| 1 |
import { NextRequest, NextResponse } from 'next/server';
|
| 2 |
import { whoAmI, createRepo, uploadFiles, datasetInfo } from '@huggingface/hub';
|
| 3 |
-
import { readdir, stat } from 'fs/promises';
|
| 4 |
import path from 'path';
|
| 5 |
-
import { pathToFileURL } from 'url';
|
| 6 |
|
| 7 |
export async function POST(request: NextRequest) {
|
| 8 |
try {
|
|
@@ -73,8 +72,9 @@ export async function POST(request: NextRequest) {
|
|
| 73 |
filesToUpload.push({ path: normalizedRepoPath, content });
|
| 74 |
};
|
| 75 |
|
| 76 |
-
const addUploadFile = (absolutePath: string, repoFilePath: string) => {
|
| 77 |
-
|
|
|
|
| 78 |
};
|
| 79 |
|
| 80 |
const walkDirectory = async (basePath: string, repoPrefix: string) => {
|
|
@@ -86,7 +86,7 @@ export async function POST(request: NextRequest) {
|
|
| 86 |
await walkDirectory(entryPath, nextPrefix);
|
| 87 |
} else if (entry.isFile()) {
|
| 88 |
const repoFilePath = repoPrefix ? `${repoPrefix}/${entry.name}` : entry.name;
|
| 89 |
-
addUploadFile(entryPath, repoFilePath);
|
| 90 |
}
|
| 91 |
}
|
| 92 |
};
|
|
@@ -111,7 +111,7 @@ export async function POST(request: NextRequest) {
|
|
| 111 |
} else if (!path.posix.extname(destination)) {
|
| 112 |
destination = `${destination}/${path.basename(resolvedPath)}`;
|
| 113 |
}
|
| 114 |
-
addUploadFile(resolvedPath, destination);
|
| 115 |
} else {
|
| 116 |
throw new Error(`Unsupported artifact type for path: ${localPath}`);
|
| 117 |
}
|
|
|
|
| 1 |
import { NextRequest, NextResponse } from 'next/server';
|
| 2 |
import { whoAmI, createRepo, uploadFiles, datasetInfo } from '@huggingface/hub';
|
| 3 |
+
import { readdir, stat, readFile } from 'fs/promises';
|
| 4 |
import path from 'path';
|
|
|
|
| 5 |
|
| 6 |
export async function POST(request: NextRequest) {
|
| 7 |
try {
|
|
|
|
| 72 |
filesToUpload.push({ path: normalizedRepoPath, content });
|
| 73 |
};
|
| 74 |
|
| 75 |
+
const addUploadFile = async (absolutePath: string, repoFilePath: string) => {
|
| 76 |
+
const buffer = await readFile(absolutePath);
|
| 77 |
+
addUploadContent(repoFilePath, buffer);
|
| 78 |
};
|
| 79 |
|
| 80 |
const walkDirectory = async (basePath: string, repoPrefix: string) => {
|
|
|
|
| 86 |
await walkDirectory(entryPath, nextPrefix);
|
| 87 |
} else if (entry.isFile()) {
|
| 88 |
const repoFilePath = repoPrefix ? `${repoPrefix}/${entry.name}` : entry.name;
|
| 89 |
+
await addUploadFile(entryPath, repoFilePath);
|
| 90 |
}
|
| 91 |
}
|
| 92 |
};
|
|
|
|
| 111 |
} else if (!path.posix.extname(destination)) {
|
| 112 |
destination = `${destination}/${path.basename(resolvedPath)}`;
|
| 113 |
}
|
| 114 |
+
await addUploadFile(resolvedPath, destination);
|
| 115 |
} else {
|
| 116 |
throw new Error(`Unsupported artifact type for path: ${localPath}`);
|
| 117 |
}
|
ui/src/app/api/hf-jobs/route.ts
CHANGED
|
@@ -615,9 +615,9 @@ def generate_model_card_readme(repo_id: str, config: dict, model_name: str, cura
|
|
| 615 |
})
|
| 616 |
prompt_bullets.append(f"- {prompt_text}")
|
| 617 |
|
| 618 |
-
gallery_section = "
|
| 619 |
if prompt_bullets:
|
| 620 |
-
gallery_section
|
| 621 |
|
| 622 |
# Determine torch dtype based on model
|
| 623 |
dtype = "torch.bfloat16" if "flux" in arch.lower() else "torch.float16"
|
|
|
|
| 615 |
})
|
| 616 |
prompt_bullets.append(f"- {prompt_text}")
|
| 617 |
|
| 618 |
+
gallery_section = ""
|
| 619 |
if prompt_bullets:
|
| 620 |
+
gallery_section = "<Gallery />\n\n" + "### Prompts\n\n" + "\n".join(prompt_bullets) + "\n\n"
|
| 621 |
|
| 622 |
# Determine torch dtype based on model
|
| 623 |
dtype = "torch.bfloat16" if "flux" in arch.lower() else "torch.float16"
|
ui/src/paths.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
| 1 |
import path from 'path';
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
export const
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import path from 'path';
|
| 2 |
+
|
| 3 |
+
const WORKSPACE_ROOT = path.resolve(process.cwd(), '..');
|
| 4 |
+
|
| 5 |
+
export const TOOLKIT_ROOT = WORKSPACE_ROOT;
|
| 6 |
+
export const defaultTrainFolder = path.join(WORKSPACE_ROOT, 'output');
|
| 7 |
+
export const defaultDatasetsFolder = path.join(WORKSPACE_ROOT, 'datasets');
|
| 8 |
+
export const defaultDataRoot = path.join(WORKSPACE_ROOT, 'data');
|