From 2511ef15947012e87ceb9d61e1f2b31425732015 Mon Sep 17 00:00:00 2001 From: Karl Hudgell Date: Mon, 16 Dec 2024 17:13:22 +0000 Subject: [PATCH] latest updated --- .gitignore | 4 +- INSTALL_VIEW_AND_FILTER.py | 35 ++++++++++++++++ comfy_fm_newgen.py | 4 +- readme.md | 86 +++++++++++++++++++++++++++++--------- 4 files changed, 106 insertions(+), 23 deletions(-) create mode 100644 INSTALL_VIEW_AND_FILTER.py diff --git a/.gitignore b/.gitignore index ccf0fc1..1fed40b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ config.cfg generated_*/* script.log **/*.pyc -*.rtf \ No newline at end of file +*.rtf +build/ +dist/ \ No newline at end of file diff --git a/INSTALL_VIEW_AND_FILTER.py b/INSTALL_VIEW_AND_FILTER.py new file mode 100644 index 0000000..5705830 --- /dev/null +++ b/INSTALL_VIEW_AND_FILTER.py @@ -0,0 +1,35 @@ +import os +import shutil +from pathlib import Path + + +def copy_folders_to_my_documents(): + # Get the current script's directory + script_dir = Path(__file__).parent.resolve() + + # Get the "My Documents" folder + my_documents = Path.home() / "Documents" + + # Define the target folder (KARL TEST) + target_folder = my_documents / f"Sports Interactive/Football Manager 2024" + + # Create the target folder if it doesn't exist + target_folder.mkdir(parents=True, exist_ok=True) + + # Define the source folders + source_folders = ["views", "filters"] + + for folder in source_folders: + source_path = script_dir / folder + target_path = target_folder / folder + + if source_path.exists() and source_path.is_dir(): + # Copy the folder and merge contents + shutil.copytree(source_path, target_path, dirs_exist_ok=True) + print(f"Copied '{folder}' to '{target_path}'") + else: + print(f"Source folder '{folder}' does not exist. Skipping.") + + +if __name__ == "__main__": + copy_folders_to_my_documents() diff --git a/comfy_fm_newgen.py b/comfy_fm_newgen.py index 5959cfb..ff1b6ec 100644 --- a/comfy_fm_newgen.py +++ b/comfy_fm_newgen.py @@ -23,8 +23,8 @@ from comfy_api_simplified import ComfyApiWrapper, ComfyWorkflowWrapper logging.config.dictConfig(LOGGING_CONFIG) -cut = 2 -update = True +cut = None +update = False use_gpu = False # Load user configurations diff --git a/readme.md b/readme.md index d916c13..91d4c01 100644 --- a/readme.md +++ b/readme.md @@ -1,34 +1,80 @@ + # Comfy UI NewGens + Use ComfyUI to generate NewGen images for Football Manager 2024 + # Intro -![enter image description here](https://preview.redd.it/comfy-fm24-newgens-v0-8vf2u79pn17e1.png?width=1080&crop=smart&auto=webp&s=e2e3d39d559507e7b2fee7150fc14cfdefb23c15) -- "There are 10000s of faces out there already" -- "There are tools that work the same already?" -- "Have you got nothing better to do with your time?" - + +![enter image description here](https://raw.githubusercontent.com/karl0ss/comfy_fm24_newgens/refs/heads/main/photo-collage.png) + +- "There are 10000s of faces out there already" +- "There are tools that work the same already?" +- "Have you got nothing better to do with your time?" + [Example video here](https://www.youtube.com/watch?v=mcGj3_nbV0A) -These are some of the questions I think you are going to ask me, but I present to you somehting I have been working on, **Comfy FM24 NewGens** -# The Idea -Taking some inspiration from [fm-ai-face-generator](https://github.com/emilmirzayev/fm-ai-face-generator), but not wanting to pay for a hosted service (I already have AI _stuff_ setup on my home server) I started to rewrite chunks to make compatible with a hosted Comfy UI instance, after awhile, I had rewritten so much, that this is now a new beast in itself.. + -Also taking inspiration from [NewGAN-Manager](https://github.com/franl08/NewGAN-Manager) and reworking some of thier code for my uses. +These are some of the questions I think you are going to ask me, but I present to you somehting I have been working on, **Comfy FM24 NewGens** + +# The Idea + +Taking some inspiration from [fm-ai-face-generator](https://github.com/emilmirzayev/fm-ai-face-generator), but not wanting to pay for a hosted service (I already have AI _stuff_ setup on my home server) I started to rewrite chunks to make compatible with a hosted Comfy UI instance, after awhile, I had rewritten so much, that this is now a new beast in itself.. + + + +Also taking inspiration from [NewGAN-Manager](https://github.com/franl08/NewGAN-Manager) and reworking some of thier code for my uses. + + Thanks to both! + + So what does this do? Why would you want to use it? (you probably wont but personally, I like a bit more personallisation from my NewGens, some, I get quite attached to :) ) - - This will create images for your NewGens, based off of information provided from the FM database, making a players image more unique to that player - - download the images to the specified output directory, all processed players image will be saved as their **uid** from the game - - remove all the background from the generated faces - - create the needed config file for FM to load the faces, - - you can then rename the generated folder and place it in your **graphics** folder as you would noramlly and voila! - + + +- This will create images for your NewGens, based off of information provided from the FM database, making a players image more unique to that player +- download the images to the specified output directory, all processed players image will be saved as their **uid** from the game +- remove all the background from the generated faces +- create the needed config file for FM to load the faces, +- you can then rename the generated folder and place it in your **graphics** folder as you would noramlly and voila! + + # Install Guide -- Use Git to checkout this repo -- You need to get a `rtf` file of the players you want to add images for, to do this you need the view and filter supplied with the project -- Copy the `filters` and `views` folder over to your `Football Manager 2024` data folder, this may create these folders, or may just add the contained files into your existing folders - - Included is the original `is newgen` filter created by the NewGAN-Manager team and a new view created by myself to get the needed data - - If you follow [this video](https://youtu.be/pmdIkhfmY6w?t=564) it will show you how to export the `rtf` file, you want to use our view, not the view in the video + +Things you will need that I will not be going over on how to setup. + + - Python installed + - Git installed + - A ComfyUI installation (On hosted server, or [portable](https://github.com/YanWenKun/ComfyUI-Windows-Portable)) + - My suggestion it to use the [Realistic Vision 6](https://civitai.com/models/4201/realistic-vision-v60-b1) model + +If you have that, then carry on for Windows instructions + - Use Git to checkout this repo + - You need to get a `rtf` file of the players you want to add images for, to do this you need the view and filter supplied with the project + - Copy the `filters` and `views` folder over to your `Football Manager 2024` data folder in `Documents`, this may create these folders, or may just add the contained files into your existing folders + - You can use `python INSTALL_VIEW_AND_FILTER.py` to do this automatically + - Included is the original `is newgen` filter created by the NewGAN-Manager team and a new view created by myself to get the needed data + - If you follow [this video](https://youtu.be/pmdIkhfmY6w?t=564) it will show you how to export the `rtf` file, you want to use our view, not the view in the video + - Once you have your `rtf` file add it to the root of the current repo + - Create a python virtual environment `python -m venv venv` + - Activate the venv `.\venv\Scripts\activate` + - Install the requirements `pip install -r requirements.txt` + - Copy the `user_config.cfg.sample` to `user_config.cfg` and make the needed changes + - football_manager_version - Version of FM to generate for. Defautls to `2024` + - output_dir - Where to save the generated set. Defaults to `./generated_images/` + - comfyui_url - HTTP location of your comfyui installation. + - model - Model to be used, by default `realisticVisionV60B1_v51HyperVAE.safetensors` is set, this is my suggested model at the moment. +- At this point you should be able to run and start to generate by running the command `python comfy_fm_newgen.py --rtf_file ExportedFile.rtf` + - ExportedFile is the name of the file that you exported and saved with your newgen list + + +You should get some console output of the progress, good luck! + +Open an issue here if your having problems + +Thanks \ No newline at end of file