-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Batch File upload/ Folder upload. Bulk Enhance #3540
Open
ChrisColeTech
wants to merge
26
commits into
lllyasviel:main
Choose a base branch
from
ChrisColeTech:dev
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
f1e9a5c
Batch File upload/ Folder upload. Bulk Enhance
ChrisColeTech ee4f442
remove unused imports
ChrisColeTech 9f535e8
Change to resolve GitHub Advanced Security check
ChrisColeTech 7a0b8ee
Rework Stop/Skip while bulk enhancing
ChrisColeTech 2ab91c9
Update bulk_enhance_helpers.py
ChrisColeTech ec177f2
Update bulk_enhance_helpers.py
ChrisColeTech ad18a93
Update async_worker.py
ChrisColeTech e268cd5
Merge branch 'lllyasviel:main' into dev
ChrisColeTech 83d0935
more code cleanup
ChrisColeTech 3db125a
To resolve github CodeQL warning
ChrisColeTech 4b90d70
Update async_worker.py
ChrisColeTech 67edbf2
Update bulk_enhance_helpers.py
ChrisColeTech e68d7b5
automatic tkinter installation
ChrisColeTech 1afc7b3
Update tkinter_installer.py
ChrisColeTech 672baf0
Update launch.py
ChrisColeTech 8921ac8
Remove code comments, added backend logic for perf monitor. renamed t…
ChrisColeTech 7722d2c
html front end component for resource monitor
ChrisColeTech 4848427
wired up perf monitor
ChrisColeTech 85429b0
Update launch.py
ChrisColeTech 4c32ebe
final touches on the perf monitor
ChrisColeTech 5774787
perf monitor 2.0 with dragging
ChrisColeTech f0fa022
fix invisible element
ChrisColeTech c5a290a
remove unused code
ChrisColeTech c8d4d2d
Merge branch 'dev' of https://github.com/ChrisColeTech/Fooocus into dev
ChrisColeTech ce74b6b
speed up animation
ChrisColeTech eb934c9
Using websockets for resource monitor instead of rest api
ChrisColeTech File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,3 +53,4 @@ user_path_config-deprecated.txt | |
/.coverage* | ||
/auth.json | ||
.DS_Store | ||
/.venv |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import gradio as gr | ||
import os | ||
import modules.config | ||
import modules.html | ||
import modules.meta_parser | ||
|
||
from tkinter import Tk, filedialog | ||
|
||
|
||
def process_directories(directory_paths): | ||
if not directory_paths: | ||
return "No directories selected." | ||
|
||
results = [] | ||
for directory in directory_paths: | ||
# List files in the directory | ||
files = os.listdir(directory) | ||
results.append(f"Contents of {directory}:\n" + "\n".join(files)) | ||
|
||
return "\n\n".join(results) | ||
|
||
|
||
def update_visibility(x): | ||
# Add more updates for other components | ||
return [gr.update(visible=x), gr.update(visible=x)] | ||
|
||
|
||
def list_to_string(filenames): | ||
# Join the filenames list into a comma-separated string | ||
file_list = ', '.join(filenames) | ||
return file_list | ||
|
||
|
||
def on_browse(data_type): | ||
root = Tk() | ||
root.attributes("-topmost", True) | ||
root.withdraw() | ||
if data_type == "Files": | ||
filenames = filedialog.askopenfilenames() | ||
if len(filenames) > 0: | ||
root.destroy() | ||
file_list = list_to_string(filenames) | ||
return file_list | ||
else: | ||
filename = "Files not seleceted" | ||
root.destroy() | ||
return None | ||
|
||
elif data_type == "Folder": | ||
filename = filedialog.askdirectory() | ||
if filename: | ||
if os.path.isdir(filename): | ||
root.destroy() | ||
return str(filename) | ||
else: | ||
root.destroy() | ||
return str(filename) | ||
else: | ||
filename = "Folder not seleceted" | ||
root.destroy() | ||
return None | ||
|
||
|
||
def on_file_change(files, data_type): | ||
if files and data_type == "Files": | ||
return gr.update(visible=True), gr.update(), gr.update(value=True) | ||
|
||
# If no files are selected, hide file explorer and clear input_path | ||
if not files and data_type == "Files": | ||
return gr.update(visible=False), gr.update(value=""), gr.update(value=False) | ||
|
||
if data_type == "Folder": | ||
return gr.update(visible=False), gr.update(), gr.update(value=True) | ||
|
||
return gr.update(visible=False), gr.update(), gr.update(value=False) | ||
|
||
|
||
def on_input_change(input_path, file_explorer): | ||
if input_path: | ||
# Verify with normalised version of path | ||
input_path = os.path.normpath(os.path.realpath(input_path)) | ||
|
||
if os.path.isdir(os.path.realpath(input_path)): | ||
# Return an empty list if input_path is a directory | ||
return None, gr.update(visible=True), gr.update(value=True) | ||
else: | ||
# Return an empty list if input_path is empty | ||
return None, gr.update(visible=False), gr.update(value=False) | ||
|
||
# Initialize a dictionary to track unique file names and their paths | ||
unique_file_paths = {} | ||
|
||
# Process the input_path string | ||
if input_path: | ||
# Clean up the input path string and split it into a list of file paths | ||
file_paths_list = input_path.strip("()").replace("'", "").split(", ") | ||
# Extract file names and ensure uniqueness | ||
for path in file_paths_list: | ||
file_name = os.path.basename(path) | ||
unique_file_paths[file_name] = path | ||
|
||
# Process file_explorer items if provided | ||
if file_explorer: | ||
# Extract 'orig_name' from each file_explorer object and ensure uniqueness | ||
for item in file_explorer: | ||
sanitized_path = item.orig_name | ||
file_name = os.path.basename(sanitized_path) | ||
# Store the path, replacing any existing path with the same file name | ||
unique_file_paths[file_name] = sanitized_path | ||
|
||
# Convert the dictionary values back to a list of unique file paths | ||
if len(unique_file_paths.values()) > 0: | ||
return list(unique_file_paths.values()), gr.update(visible=False), gr.update(value=True) | ||
else: | ||
return None, gr.update(visible=False), gr.update(value=False) | ||
|
||
|
||
def on_click_clear(): | ||
return None, None, gr.update(visible=False), gr.update(visible=False) | ||
|
||
# Function to set prompts based on the selected type | ||
|
||
|
||
def update_prompts(selected_type): | ||
# Ensure selected_type is a valid key and exists in the dictionary | ||
if selected_type in modules.config.default_enhance_prompts: | ||
positive_prompt = modules.config.default_enhance_prompts[selected_type]['positive'] | ||
negative_prompt = modules.config.default_enhance_prompts[selected_type]['negative'] | ||
return positive_prompt, negative_prompt | ||
else: | ||
# Returning default or empty values | ||
return "Default positive prompt", "Default negative prompt" | ||
|
||
|
||
def on_selection_change(selected_type): | ||
# Get prompts based on selected_type | ||
positive_prompt, negative_prompt = update_prompts(selected_type[0]) | ||
|
||
# Return the prompts | ||
return positive_prompt, negative_prompt |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / CodeQL
Uncontrolled data used in path expression
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was resolved:
ChrisColeTech@b5e73ff