CoolFace
Modelpublic

diffusers/tools

sourceHugging Facecreativeml-openrail-mupdated 3y agoView on Hugging Face
11likes28downloads
README_t2i.py101 linesDownload Raw Back to root
1import sys2 3model_name = sys.argv[1]4 5model_card = f"""---6language:7- en8license: creativeml-openrail-m9tags:10- stable-diffusion11- stable-diffusion-diffusers12- text-to-image13- art14- artistic15- diffusers16- absolute_realism17---18 19# {model_name.split("/")[-1].replace("-", " ").capitalize()}20 21`{model_name}` is a Stable Diffusion model that has been fine-tuned on [runwayml/stable-diffusion-v1-5](https://huggingface.co/runwayml/stable-diffusion-v1-5).22 23Please consider supporting me: 24- on [Patreon](https://www.patreon.com/Lykon275)25- or [buy me a coffee](https://snipfeed.co/lykon)26 27## Diffusers28 29For more general information on how to run text-to-image models with 🧨 Diffusers, see [the docs](https://huggingface.co/docs/diffusers/using-diffusers/conditional_image_generation).30 311. Installation32 33```34pip install diffusers transformers accelerate35```36 372. Run38```py39from diffusers import AutoPipelineForText2Image, DEISMultistepScheduler40import torch41 42pipe = AutoPipelineForText2Image.from_pretrained('{model_name}', torch_dtype=torch.float16, variant="fp16")43pipe.scheduler = DEISMultistepScheduler.from_config(pipe.scheduler.config)44pipe = pipe.to("cuda")45 46prompt = "portrait photo of muscular bearded guy in a worn mech suit, light bokeh, intricate, steel metal, elegant, sharp focus, soft lighting, vibrant colors"47 48generator = torch.manual_seed(33)49image = pipe(prompt, generator=generator, num_inference_steps=25).images[0]  50image.save("./image.png")51```52"""53 54"""55## Notes56 57- **Version 8** focuses on improving what V7 started. Might be harder to do photorealism compared to realism focused models, as it might be hard to do anime compared to anime focused models, but it can do both pretty well if you're skilled enough. Check the examples!58- **Version 7** improves lora support, NSFW and realism. If you're interested in "absolute" realism, try AbsoluteReality.59- **Version 6** adds more lora support and more style in general. It should also be better at generating directly at 1024 height (but be careful with it). 6.x are all improvements.60- **Version 5** is the best at photorealism and has noise offset.61- **Version 4** is much better with anime (can do them with no LoRA) and booru tags. It might be harder to control if you're used to caption style, so you might still want to use version 3.31. V4 is also better with eyes at lower resolutions. Overall is like a "fix" of V3 and shouldn't be too much different.62"""63from huggingface_hub import HfApi64api = HfApi()65 66read_me_path = "./README.md"67with open(read_me_path, "w") as f:68    f.write(model_card)69 70api.upload_file(71    path_or_fileobj=read_me_path,72    path_in_repo=read_me_path,73    repo_id=model_name,74    repo_type="model",75)76 77from diffusers import AutoPipelineForText2Image, DEISMultistepScheduler78import torch79 80pipe = AutoPipelineForText2Image.from_pretrained(model_name, torch_dtype=torch.float16)81pipe.scheduler = DEISMultistepScheduler.from_config(pipe.scheduler.config)82 83pipe = pipe.to("cuda")84 85prompt = "portrait photo of muscular bearded guy in a worn mech suit, light bokeh, intricate, steel metal, elegant, sharp focus, soft lighting, vibrant colors"86 87generator = torch.manual_seed(33)88image = pipe(prompt, generator=generator, num_inference_steps=25).images[0]  89image_path = "./image.png"90 91image.save(image_path)92 93api.upload_file(94    path_or_fileobj=image_path,95    path_in_repo=image_path,96    repo_id=model_name,97    repo_type="model",98)99 100pipe.push_to_hub(model_name, variant="fp16")101