mirror of
https://github.com/kodxana/madiator-docker-runpod.git
synced 2024-11-28 21:30:12 +01:00
138 lines
4.6 KiB
Text
138 lines
4.6 KiB
Text
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# ComfyUI utility notebook ( Run first 2 cells first!!!)\n",
|
|
"This notebook helps set up the ComfyUI environment and download models. For some tasks, manual intervention in a terminal is required."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Navigate to the workspace directory where ComfyUI is located.\n",
|
|
"%cd /workspace"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Set the default path for ComfyUI.\n",
|
|
"!comfy --skip-prompt --no-enable-telemetry set-default /workspace/ComfyUI/"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Fix and Restore Custom Nodes\n",
|
|
"This command restores dependencies for ComfyUI. Use this if you have updated templates or if the virtual environment is broken. After running this, restart ComfyUI from the manager or restart the pod. Sometimes, custom nodes won't show up until you refresh the page in your browser."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Restore dependencies for ComfyUI.\n",
|
|
"!comfy node restore-dependencies"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Model Downloader\n",
|
|
"Enter the model URL below. If the model is from CivitAI, check the box to provide your API token. Hugging Face models are also supported."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 7,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"application/vnd.jupyter.widget-view+json": {
|
|
"model_id": "8e25344b209c4f7d91503c08c6007dfe",
|
|
"version_major": 2,
|
|
"version_minor": 0
|
|
},
|
|
"text/plain": [
|
|
"VBox(children=(Text(value='', description='Model URL:', layout=Layout(width='80%')), Checkbox(value=False, des…"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"from ipywidgets import Text, Button, Checkbox, VBox, Output, Layout, Textarea\n",
|
|
"from IPython.display import display\n",
|
|
"\n",
|
|
"# Widgets for user input\n",
|
|
"url_input = Text(description='Model URL:', layout=Layout(width='80%'))\n",
|
|
"civitai_checkbox = Checkbox(description='CivitAI Model', layout=Layout(width='80%'))\n",
|
|
"token_input = Text(description='API Token:', placeholder='Enter CivitAI API token (if needed)', layout=Layout(width='80%'))\n",
|
|
"token_input.layout.visibility = 'hidden' # Initially hidden\n",
|
|
"output_area = Textarea(value='', placeholder='Generated command will appear here...', layout=Layout(width='80%', height='100px'))\n",
|
|
"\n",
|
|
"# Function to toggle API token input visibility\n",
|
|
"def toggle_token_input(change):\n",
|
|
" token_input.layout.visibility = 'visible' if change['new'] else 'hidden'\n",
|
|
"civitai_checkbox.observe(toggle_token_input, names='value')\n",
|
|
"\n",
|
|
"# Function to display the manual command\n",
|
|
"def display_command(b):\n",
|
|
" url = url_input.value\n",
|
|
" token = token_input.value if civitai_checkbox.value else ''\n",
|
|
" if not url:\n",
|
|
" output_area.value = \"Please enter a valid URL.\"\n",
|
|
" return\n",
|
|
" command = f\"comfy model download --url {url}\"\n",
|
|
" if token:\n",
|
|
" command += f\" --set-civitai-api-token {token}\"\n",
|
|
" output_area.value = command\n",
|
|
"\n",
|
|
"# Button to generate command\n",
|
|
"generate_button = Button(description='Generate Command')\n",
|
|
"generate_button.on_click(display_command)\n",
|
|
"\n",
|
|
"# Display the input widgets and output area\n",
|
|
"display(VBox([url_input, civitai_checkbox, token_input, generate_button, output_area]))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Instructions for Executing the Command\n",
|
|
"1. **Copy the generated command** from the output area above.\n",
|
|
"2. **Open a terminal** in your environment. In VS Code, you can do this by pressing `Ctrl + ~` or right-clicking an empty space in the Explorer and selecting 'Open in Integrated Terminal'.\n",
|
|
"3. **Paste and run the command** in the terminal.\n",
|
|
"4. **Follow any prompts** in the terminal for additional input, such as entering a filename."
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"name": "python",
|
|
"version": "3.11.9"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|