-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework - Adding parallel exec option, fixing unit tests, improving co…
…de, updating readme
- Loading branch information
1 parent
7e9bf66
commit ca365ad
Showing
9 changed files
with
213 additions
and
108 deletions.
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
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 |
---|---|---|
@@ -1,15 +1,50 @@ | ||
from sevsd.setup_pipeline import setup_pipeline | ||
from sevsd.process_task import process_task | ||
|
||
def do_work(configs, tasks, path, parallel_exec=True, **kwargs): | ||
task_dict = {task["task_id"]: [] for task in tasks} | ||
for task in tasks: | ||
task_dict[task["task_id"]].append(task) | ||
|
||
for config in configs: | ||
pipeline = setup_pipeline(config["model_info"], **kwargs) | ||
task_ids = config.get("task_ids", []) | ||
for task_id in task_ids: | ||
if task_id in task_dict: | ||
for task in task_dict[task_id]: | ||
process_task(task["details"], pipeline, path, parallel_exec) | ||
models = [ | ||
{ | ||
"name": "./model_cache/model1.safetensors", | ||
"executor": { | ||
"labels": [1], | ||
"num_of_exec": 1, | ||
"cfg_scale": 7, | ||
"inference_steps": 100, | ||
} | ||
}, | ||
{ | ||
"name": "./model_cache/model2.safetensors", | ||
"executor": { | ||
"labels": [2], | ||
"num_of_exec": 2, | ||
"cfg_scale": 6, | ||
"inference_steps": 50, | ||
} | ||
}, | ||
] | ||
|
||
jobs = [ | ||
{ | ||
"label": 1, | ||
"prompt": "A scenic landscape", | ||
"negative_prompt": "blurred image, black and white, watermarked image", | ||
}, | ||
{ | ||
"label": 2, | ||
"prompt": "A person wearing a mask", | ||
"negative_prompt": "deformed anatomy, hand-drawn image, blurred image", | ||
}, | ||
] | ||
|
||
def do_work(models, jobs, image_path, parallel_exec=True, **kwargs): | ||
job_dict = {job['label']: [] for job in jobs} | ||
for job in jobs: | ||
job_dict[job['label']].append(job) | ||
|
||
for model in models: | ||
pipeline = setup_pipeline(model["name"], **kwargs) | ||
labels = model.get("executor", {}).get("labels", []) | ||
for label in labels: | ||
if label in job_dict: | ||
for job in job_dict[label]: | ||
executor = model.get("executor", {}) | ||
process_task(job, pipeline, executor, image_path, parallel_exec) |
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
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
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
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
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
Oops, something went wrong.