Last active
November 23, 2023 07:28
-
-
Save garystafford/cc7bede777319f90fe5bb38902dd10f6 to your computer and use it in GitHub Desktop.
Revisions
-
garystafford revised this gist
Nov 23, 2023 . 1 changed file with 1 addition and 49 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,29 +1,3 @@ subject_prompt = """oue, photo of a oue electric scooter, sleek, smooth curves, colorful, daytime, urban, futuristic cityscape""" @@ -35,26 +9,4 @@ ultra sharp detail""" refiner_negative_prompt = """low quality, low-resolution, out of focus, blurry, grainy, artifacts, defects, jpeg artifacts, noise""" -
garystafford created this gist
Nov 23, 2023 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,60 @@ from diffusers import DiffusionPipeline, StableDiffusionXLImg2ImgPipeline import torch from tqdm.notebook import tqdm model_name_base = "stabilityai/stable-diffusion-xl-base-1.0" model_name_refiner = "stabilityai/stable-diffusion-xl-refiner-1.0" device = "cuda" # cpu or cuda pipeline = DiffusionPipeline.from_pretrained( model_name_base, torch_dtype=torch.float16, ) pipeline.to(device) pipeline.load_lora_weights( project_name, weight_name="pytorch_lora_weights.safetensors" ) refiner = StableDiffusionXLImg2ImgPipeline.from_pretrained( model_name_refiner, torch_dtype=torch.float16, ) refiner.to(device) subject_prompt = """oue, photo of a oue electric scooter, sleek, smooth curves, colorful, daytime, urban, futuristic cityscape""" subject_negative_prompt = """person, people, human, rider, floating objects, text, words, writing, letters, phrases, trademark, watermark, icon, logo, banner, signature, username, monochrome, cropped, cut-off, patterned background""" refiner_prompt = """ultra-high-definition, photorealistic, 8k uhd, high-quality, ultra sharp detail""" refiner_negative_prompt = """low quality, low-resolution, out of focus, blurry, grainy, artifacts, defects, jpeg artifacts, noise""" for seed in range(10): generator = torch.Generator(device).manual_seed(seed) base_image = pipeline( prompt=f"{subject_prompt}, {refiner_prompt}", negative_prompt=f"{subject_negative_prompt}, {refiner_negative_prompt}", num_inference_steps=100, generator=generator, height=1024, width=1024, output_type="latent", ).images[0] refined_image = refiner( prompt=refiner_prompt, negative_prompt=refiner_negative_prompt, num_inference_steps=20, generator=generator, image=base_image, ).images[0] refined_image.save(f"./generated_images/finetuned_scooter_marker_photo_square_{seed}.png")