added hugging face downloader
This commit is contained in:
@@ -96,6 +96,7 @@ from .nodes.FL_ClipScanner import FL_ClipScanner
|
||||
from .nodes.FL_SceneCut import FL_SceneCut
|
||||
from .nodes.FL_GeminiTextAPI import FL_GeminiTextAPI
|
||||
from .nodes.FL_JS import FL_JS
|
||||
from .nodes.FL_HFDatasetDownloader import FL_HFDatasetDownloader
|
||||
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
@@ -198,6 +199,7 @@ NODE_CLASS_MAPPINGS = {
|
||||
"FL_SceneCut": FL_SceneCut,
|
||||
"FL_GeminiTextAPI": FL_GeminiTextAPI,
|
||||
"FL_JS": FL_JS,
|
||||
"FL_HFDatasetDownloader": FL_HFDatasetDownloader,
|
||||
|
||||
}
|
||||
|
||||
@@ -301,6 +303,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"FL_SceneCut": "FL Scene Cut Detector",
|
||||
"FL_GeminiTextAPI": "FL Gemini Text API",
|
||||
"FL_JS": "FL JavaScript",
|
||||
"FL_HFDatasetDownloader": "FL HF Dataset Downloader",
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
import os
|
||||
from huggingface_hub import snapshot_download
|
||||
|
||||
class FL_HFDatasetDownloader:
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"required": {
|
||||
"repo_id": ("STRING", {
|
||||
"default": "jjuik2014/FaceVid-1K-Part",
|
||||
"multiline": False
|
||||
}),
|
||||
"repo_type": (["dataset", "model", "space"], {
|
||||
"default": "dataset"
|
||||
}),
|
||||
"local_dir": ("STRING", {
|
||||
"default": "./downloads",
|
||||
"multiline": False
|
||||
}),
|
||||
"max_workers": ("INT", {
|
||||
"default": 10,
|
||||
"min": 1,
|
||||
"max": 20,
|
||||
"step": 1
|
||||
}),
|
||||
"download_trigger": ("BOOLEAN", {
|
||||
"default": False,
|
||||
"label": "Start Download"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
RETURN_TYPES = ("STRING",)
|
||||
RETURN_NAMES = ("download_path",)
|
||||
FUNCTION = "download_repo"
|
||||
CATEGORY = "🏵️Fill Nodes/Hugging Face"
|
||||
|
||||
def download_repo(self, repo_id, repo_type, local_dir, max_workers, download_trigger):
|
||||
if not download_trigger:
|
||||
return (local_dir,)
|
||||
|
||||
try:
|
||||
# Ensure the directory exists
|
||||
os.makedirs(local_dir, exist_ok=True)
|
||||
|
||||
# Download the repository
|
||||
download_path = snapshot_download(
|
||||
repo_id=repo_id,
|
||||
repo_type=repo_type,
|
||||
local_dir=local_dir,
|
||||
max_workers=max_workers
|
||||
)
|
||||
|
||||
return (download_path,)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error downloading repository: {str(e)}")
|
||||
return (local_dir,)
|
||||
Reference in New Issue
Block a user